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" |
| 13 | #include "xfa/fwl/core/fwl_panelimp.h" |
| 14 | #include "xfa/fwl/core/fwl_targetimp.h" |
| 15 | #include "xfa/fwl/core/fwl_threadimp.h" |
| 16 | #include "xfa/fwl/core/fwl_widgetimp.h" |
| 17 | |
| 18 | CFWL_ToolTip* CFWL_ToolTip::Create() { |
| 19 | return new CFWL_ToolTip; |
| 20 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame^] | 21 | |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 22 | FWL_ERR CFWL_ToolTip::Initialize(const CFWL_WidgetProperties* pProperties) { |
| 23 | if (m_pIface) |
| 24 | return FWL_ERR_Indefinite; |
| 25 | if (pProperties) { |
| 26 | *m_pProperties = *pProperties; |
| 27 | } |
| 28 | std::unique_ptr<IFWL_ToolTip> pToolTip(IFWL_ToolTip::Create( |
| 29 | m_pProperties->MakeWidgetImpProperties(&m_tooltipData), nullptr)); |
| 30 | FWL_ERR ret = pToolTip->Initialize(); |
| 31 | if (ret != FWL_ERR_Succeeded) { |
| 32 | return ret; |
| 33 | } |
| 34 | m_pIface = pToolTip.release(); |
| 35 | CFWL_Widget::Initialize(); |
| 36 | return FWL_ERR_Succeeded; |
| 37 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame^] | 38 | |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 39 | FWL_ERR CFWL_ToolTip::GetCaption(CFX_WideString& wsCaption) { |
| 40 | wsCaption = m_tooltipData.m_wsCaption; |
| 41 | return FWL_ERR_Succeeded; |
| 42 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame^] | 43 | |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 44 | FWL_ERR CFWL_ToolTip::SetCaption(const CFX_WideStringC& wsCaption) { |
| 45 | m_tooltipData.m_wsCaption = wsCaption; |
| 46 | return FWL_ERR_Succeeded; |
| 47 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame^] | 48 | |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 49 | int32_t CFWL_ToolTip::GetInitialDelay() { |
| 50 | return m_tooltipData.m_nInitDelayTime; |
| 51 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame^] | 52 | |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 53 | int32_t CFWL_ToolTip::SetInitialDelay(int32_t nDelayTime) { |
| 54 | m_tooltipData.m_nInitDelayTime = nDelayTime; |
| 55 | return FWL_ERR_Succeeded; |
| 56 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame^] | 57 | |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 58 | int32_t CFWL_ToolTip::GetAutoPopDelay() { |
| 59 | return m_tooltipData.m_nAutoPopDelayTime; |
| 60 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame^] | 61 | |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 62 | int32_t CFWL_ToolTip::SetAutoPopDelay(int32_t nDelayTime) { |
| 63 | m_tooltipData.m_nAutoPopDelayTime = nDelayTime; |
| 64 | return FWL_ERR_Succeeded; |
| 65 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame^] | 66 | |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 67 | CFX_DIBitmap* CFWL_ToolTip::GetToolTipIcon() { |
| 68 | return m_tooltipData.m_pBitmap; |
| 69 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame^] | 70 | |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 71 | FWL_ERR CFWL_ToolTip::SetToolTipIcon(CFX_DIBitmap* pBitmap) { |
| 72 | m_tooltipData.m_pBitmap = pBitmap; |
| 73 | return FWL_ERR_Succeeded; |
| 74 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame^] | 75 | |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 76 | CFX_SizeF CFWL_ToolTip::GetToolTipIconSize() { |
| 77 | return m_tooltipData.m_fIconSize; |
| 78 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame^] | 79 | |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 80 | FWL_ERR CFWL_ToolTip::SetToolTipIconSize(CFX_SizeF fSize) { |
| 81 | m_tooltipData.m_fIconSize = fSize; |
| 82 | return FWL_ERR_Succeeded; |
| 83 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame^] | 84 | |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 85 | FWL_ERR CFWL_ToolTip::SetAnchor(const CFX_RectF& rtAnchor) { |
| 86 | return static_cast<IFWL_ToolTip*>(m_pIface)->SetAnchor(rtAnchor); |
| 87 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame^] | 88 | |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 89 | FWL_ERR CFWL_ToolTip::Show() { |
| 90 | return static_cast<IFWL_ToolTip*>(m_pIface)->Show(); |
| 91 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame^] | 92 | |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 93 | FWL_ERR CFWL_ToolTip::Hide() { |
| 94 | return static_cast<IFWL_ToolTip*>(m_pIface)->Hide(); |
| 95 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame^] | 96 | |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 97 | CFWL_ToolTip::CFWL_ToolTip() {} |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame^] | 98 | |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 99 | CFWL_ToolTip::~CFWL_ToolTip() {} |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame^] | 100 | |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 101 | CFWL_ToolTip::CFWL_ToolTipDP::CFWL_ToolTipDP() : m_pBitmap(NULL) { |
| 102 | m_wsCaption = L""; |
| 103 | m_nInitDelayTime = 500; |
| 104 | m_nAutoPopDelayTime = 50000; |
| 105 | m_fAnchor.Set(0.0, 0.0, 0.0, 0.0); |
| 106 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame^] | 107 | |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 108 | FWL_ERR CFWL_ToolTip::CFWL_ToolTipDP::GetCaption(IFWL_Widget* pWidget, |
| 109 | CFX_WideString& wsCaption) { |
| 110 | wsCaption = m_wsCaption; |
| 111 | return FWL_ERR_Succeeded; |
| 112 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame^] | 113 | |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 114 | int32_t CFWL_ToolTip::CFWL_ToolTipDP::GetInitialDelay(IFWL_Widget* pWidget) { |
| 115 | return m_nInitDelayTime; |
| 116 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame^] | 117 | |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 118 | int32_t CFWL_ToolTip::CFWL_ToolTipDP::GetAutoPopDelay(IFWL_Widget* pWidget) { |
| 119 | return m_nAutoPopDelayTime; |
| 120 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame^] | 121 | |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 122 | CFX_DIBitmap* CFWL_ToolTip::CFWL_ToolTipDP::GetToolTipIcon( |
| 123 | IFWL_Widget* pWidget) { |
| 124 | return m_pBitmap; |
| 125 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame^] | 126 | |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 127 | CFX_SizeF CFWL_ToolTip::CFWL_ToolTipDP::GetToolTipIconSize( |
| 128 | IFWL_Widget* pWidget) { |
| 129 | return m_fIconSize; |
| 130 | } |
dsinclair | 7f432a1 | 2016-03-29 12:38:01 -0700 | [diff] [blame^] | 131 | |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 132 | CFX_RectF CFWL_ToolTip::CFWL_ToolTipDP::GetAnchor() { |
| 133 | return m_fAnchor; |
| 134 | } |