OLD | NEW |
| (Empty) |
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 | |
7 #include "xfa/fwl/lightwidget/cfwl_tooltip.h" | |
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_widgetimp.h" | |
14 | |
15 CFWL_ToolTip* CFWL_ToolTip::Create() { | |
16 return new CFWL_ToolTip; | |
17 } | |
18 | |
19 FWL_Error CFWL_ToolTip::Initialize(const CFWL_WidgetProperties* pProperties) { | |
20 if (m_pIface) | |
21 return FWL_Error::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_Error ret = pToolTip->Initialize(); | |
28 if (ret != FWL_Error::Succeeded) { | |
29 return ret; | |
30 } | |
31 m_pIface = pToolTip.release(); | |
32 CFWL_Widget::Initialize(); | |
33 return FWL_Error::Succeeded; | |
34 } | |
35 | |
36 void CFWL_ToolTip::GetCaption(CFX_WideString& wsCaption) { | |
37 wsCaption = m_tooltipData.m_wsCaption; | |
38 } | |
39 | |
40 void CFWL_ToolTip::SetCaption(const CFX_WideStringC& wsCaption) { | |
41 m_tooltipData.m_wsCaption = wsCaption; | |
42 } | |
43 | |
44 int32_t CFWL_ToolTip::GetInitialDelay() { | |
45 return m_tooltipData.m_nInitDelayTime; | |
46 } | |
47 | |
48 void CFWL_ToolTip::SetInitialDelay(int32_t nDelayTime) { | |
49 m_tooltipData.m_nInitDelayTime = nDelayTime; | |
50 } | |
51 | |
52 int32_t CFWL_ToolTip::GetAutoPopDelay() { | |
53 return m_tooltipData.m_nAutoPopDelayTime; | |
54 } | |
55 | |
56 void CFWL_ToolTip::SetAutoPopDelay(int32_t nDelayTime) { | |
57 m_tooltipData.m_nAutoPopDelayTime = nDelayTime; | |
58 } | |
59 | |
60 CFX_DIBitmap* CFWL_ToolTip::GetToolTipIcon() { | |
61 return m_tooltipData.m_pBitmap; | |
62 } | |
63 | |
64 void CFWL_ToolTip::SetToolTipIcon(CFX_DIBitmap* pBitmap) { | |
65 m_tooltipData.m_pBitmap = pBitmap; | |
66 } | |
67 | |
68 CFX_SizeF CFWL_ToolTip::GetToolTipIconSize() { | |
69 return m_tooltipData.m_fIconSize; | |
70 } | |
71 | |
72 void CFWL_ToolTip::SetToolTipIconSize(CFX_SizeF fSize) { | |
73 m_tooltipData.m_fIconSize = fSize; | |
74 } | |
75 | |
76 void CFWL_ToolTip::SetAnchor(const CFX_RectF& rtAnchor) { | |
77 static_cast<IFWL_ToolTip*>(m_pIface)->SetAnchor(rtAnchor); | |
78 } | |
79 | |
80 void CFWL_ToolTip::Show() { | |
81 static_cast<IFWL_ToolTip*>(m_pIface)->Show(); | |
82 } | |
83 | |
84 void CFWL_ToolTip::Hide() { | |
85 static_cast<IFWL_ToolTip*>(m_pIface)->Hide(); | |
86 } | |
87 | |
88 CFWL_ToolTip::CFWL_ToolTip() {} | |
89 | |
90 CFWL_ToolTip::~CFWL_ToolTip() {} | |
91 | |
92 CFWL_ToolTip::CFWL_ToolTipDP::CFWL_ToolTipDP() : m_pBitmap(NULL) { | |
93 m_wsCaption = L""; | |
94 m_nInitDelayTime = 500; | |
95 m_nAutoPopDelayTime = 50000; | |
96 m_fAnchor.Set(0.0, 0.0, 0.0, 0.0); | |
97 } | |
98 | |
99 FWL_Error CFWL_ToolTip::CFWL_ToolTipDP::GetCaption(IFWL_Widget* pWidget, | |
100 CFX_WideString& wsCaption) { | |
101 wsCaption = m_wsCaption; | |
102 return FWL_Error::Succeeded; | |
103 } | |
104 | |
105 int32_t CFWL_ToolTip::CFWL_ToolTipDP::GetInitialDelay(IFWL_Widget* pWidget) { | |
106 return m_nInitDelayTime; | |
107 } | |
108 | |
109 int32_t CFWL_ToolTip::CFWL_ToolTipDP::GetAutoPopDelay(IFWL_Widget* pWidget) { | |
110 return m_nAutoPopDelayTime; | |
111 } | |
112 | |
113 CFX_DIBitmap* CFWL_ToolTip::CFWL_ToolTipDP::GetToolTipIcon( | |
114 IFWL_Widget* pWidget) { | |
115 return m_pBitmap; | |
116 } | |
117 | |
118 CFX_SizeF CFWL_ToolTip::CFWL_ToolTipDP::GetToolTipIconSize( | |
119 IFWL_Widget* pWidget) { | |
120 return m_fIconSize; | |
121 } | |
122 | |
123 CFX_RectF CFWL_ToolTip::CFWL_ToolTipDP::GetAnchor() { | |
124 return m_fAnchor; | |
125 } | |
OLD | NEW |