Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 1 | // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame] | 7 | #include "xfa/fwl/lightwidget/cfwl_tooltip.h" |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 8 | |
| 9 | #include <memory> |
| 10 | |
| 11 | #include "xfa/fwl/core/fwl_formimp.h" |
| 12 | #include "xfa/fwl/core/fwl_noteimp.h" |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 13 | #include "xfa/fwl/core/fwl_widgetimp.h" |
| 14 | |
| 15 | CFWL_ToolTip* CFWL_ToolTip::Create() { |
| 16 | return new CFWL_ToolTip; |
| 17 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame] | 18 | |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 19 | FWL_ERR CFWL_ToolTip::Initialize(const CFWL_WidgetProperties* pProperties) { |
| 20 | if (m_pIface) |
| 21 | return FWL_ERR_Indefinite; |
| 22 | if (pProperties) { |
| 23 | *m_pProperties = *pProperties; |
| 24 | } |
| 25 | std::unique_ptr<IFWL_ToolTip> pToolTip(IFWL_ToolTip::Create( |
| 26 | m_pProperties->MakeWidgetImpProperties(&m_tooltipData), nullptr)); |
| 27 | FWL_ERR ret = pToolTip->Initialize(); |
| 28 | if (ret != FWL_ERR_Succeeded) { |
| 29 | return ret; |
| 30 | } |
| 31 | m_pIface = pToolTip.release(); |
| 32 | CFWL_Widget::Initialize(); |
| 33 | return FWL_ERR_Succeeded; |
| 34 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame] | 35 | |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 36 | FWL_ERR CFWL_ToolTip::GetCaption(CFX_WideString& wsCaption) { |
| 37 | wsCaption = m_tooltipData.m_wsCaption; |
| 38 | return FWL_ERR_Succeeded; |
| 39 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame] | 40 | |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 41 | FWL_ERR CFWL_ToolTip::SetCaption(const CFX_WideStringC& wsCaption) { |
| 42 | m_tooltipData.m_wsCaption = wsCaption; |
| 43 | return FWL_ERR_Succeeded; |
| 44 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame] | 45 | |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 46 | int32_t CFWL_ToolTip::GetInitialDelay() { |
| 47 | return m_tooltipData.m_nInitDelayTime; |
| 48 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame] | 49 | |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 50 | int32_t CFWL_ToolTip::SetInitialDelay(int32_t nDelayTime) { |
| 51 | m_tooltipData.m_nInitDelayTime = nDelayTime; |
| 52 | return FWL_ERR_Succeeded; |
| 53 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame] | 54 | |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 55 | int32_t CFWL_ToolTip::GetAutoPopDelay() { |
| 56 | return m_tooltipData.m_nAutoPopDelayTime; |
| 57 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame] | 58 | |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 59 | int32_t CFWL_ToolTip::SetAutoPopDelay(int32_t nDelayTime) { |
| 60 | m_tooltipData.m_nAutoPopDelayTime = nDelayTime; |
| 61 | return FWL_ERR_Succeeded; |
| 62 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame] | 63 | |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 64 | CFX_DIBitmap* CFWL_ToolTip::GetToolTipIcon() { |
| 65 | return m_tooltipData.m_pBitmap; |
| 66 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame] | 67 | |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 68 | FWL_ERR CFWL_ToolTip::SetToolTipIcon(CFX_DIBitmap* pBitmap) { |
| 69 | m_tooltipData.m_pBitmap = pBitmap; |
| 70 | return FWL_ERR_Succeeded; |
| 71 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame] | 72 | |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 73 | CFX_SizeF CFWL_ToolTip::GetToolTipIconSize() { |
| 74 | return m_tooltipData.m_fIconSize; |
| 75 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame] | 76 | |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 77 | FWL_ERR CFWL_ToolTip::SetToolTipIconSize(CFX_SizeF fSize) { |
| 78 | m_tooltipData.m_fIconSize = fSize; |
| 79 | return FWL_ERR_Succeeded; |
| 80 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame] | 81 | |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 82 | FWL_ERR CFWL_ToolTip::SetAnchor(const CFX_RectF& rtAnchor) { |
| 83 | return static_cast<IFWL_ToolTip*>(m_pIface)->SetAnchor(rtAnchor); |
| 84 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame] | 85 | |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 86 | FWL_ERR CFWL_ToolTip::Show() { |
| 87 | return static_cast<IFWL_ToolTip*>(m_pIface)->Show(); |
| 88 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame] | 89 | |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 90 | FWL_ERR CFWL_ToolTip::Hide() { |
| 91 | return static_cast<IFWL_ToolTip*>(m_pIface)->Hide(); |
| 92 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame] | 93 | |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 94 | CFWL_ToolTip::CFWL_ToolTip() {} |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame] | 95 | |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 96 | CFWL_ToolTip::~CFWL_ToolTip() {} |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame] | 97 | |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 98 | CFWL_ToolTip::CFWL_ToolTipDP::CFWL_ToolTipDP() : m_pBitmap(NULL) { |
| 99 | m_wsCaption = L""; |
| 100 | m_nInitDelayTime = 500; |
| 101 | m_nAutoPopDelayTime = 50000; |
| 102 | m_fAnchor.Set(0.0, 0.0, 0.0, 0.0); |
| 103 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame] | 104 | |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 105 | FWL_ERR CFWL_ToolTip::CFWL_ToolTipDP::GetCaption(IFWL_Widget* pWidget, |
| 106 | CFX_WideString& wsCaption) { |
| 107 | wsCaption = m_wsCaption; |
| 108 | return FWL_ERR_Succeeded; |
| 109 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame] | 110 | |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 111 | int32_t CFWL_ToolTip::CFWL_ToolTipDP::GetInitialDelay(IFWL_Widget* pWidget) { |
| 112 | return m_nInitDelayTime; |
| 113 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame] | 114 | |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 115 | int32_t CFWL_ToolTip::CFWL_ToolTipDP::GetAutoPopDelay(IFWL_Widget* pWidget) { |
| 116 | return m_nAutoPopDelayTime; |
| 117 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame] | 118 | |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 119 | CFX_DIBitmap* CFWL_ToolTip::CFWL_ToolTipDP::GetToolTipIcon( |
| 120 | IFWL_Widget* pWidget) { |
| 121 | return m_pBitmap; |
| 122 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame] | 123 | |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 124 | CFX_SizeF CFWL_ToolTip::CFWL_ToolTipDP::GetToolTipIconSize( |
| 125 | IFWL_Widget* pWidget) { |
| 126 | return m_fIconSize; |
| 127 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame] | 128 | |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 129 | CFX_RectF CFWL_ToolTip::CFWL_ToolTipDP::GetAnchor() { |
| 130 | return m_fAnchor; |
| 131 | } |