OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include "xfa/fwl/core/ifwl_tooltip.h" | 7 #include "xfa/fwl/core/ifwl_tooltip.h" |
8 | 8 |
9 #include "third_party/base/ptr_util.h" | 9 #include "third_party/base/ptr_util.h" |
10 #include "xfa/fde/tto/fde_textout.h" | 10 #include "xfa/fde/tto/fde_textout.h" |
11 #include "xfa/fwl/core/cfwl_themebackground.h" | 11 #include "xfa/fwl/core/cfwl_themebackground.h" |
12 #include "xfa/fwl/core/cfwl_themepart.h" | 12 #include "xfa/fwl/core/cfwl_themepart.h" |
13 #include "xfa/fwl/core/cfwl_themetext.h" | 13 #include "xfa/fwl/core/cfwl_themetext.h" |
14 #include "xfa/fwl/core/fwl_noteimp.h" | 14 #include "xfa/fwl/core/fwl_noteimp.h" |
15 #include "xfa/fwl/core/ifwl_themeprovider.h" | 15 #include "xfa/fwl/core/ifwl_themeprovider.h" |
16 #include "xfa/fwl/core/ifwl_tooltip.h" | 16 #include "xfa/fwl/core/ifwl_tooltip.h" |
17 #include "xfa/fwl/theme/cfwl_widgettp.h" | 17 #include "xfa/fwl/theme/cfwl_widgettp.h" |
18 | 18 |
19 IFWL_ToolTip::IFWL_ToolTip(const IFWL_App* app, | 19 IFWL_ToolTip::IFWL_ToolTip(const IFWL_App* app, |
20 std::unique_ptr<CFWL_WidgetProperties> properties, | 20 std::unique_ptr<CFWL_WidgetProperties> properties, |
21 IFWL_Widget* pOuter) | 21 IFWL_Widget* pOuter) |
22 : IFWL_Form(app, std::move(properties), pOuter), | 22 : IFWL_Form(app, std::move(properties), pOuter), |
23 m_bBtnDown(false), | |
24 m_dwTTOStyles(FDE_TTOSTYLE_SingleLine), | 23 m_dwTTOStyles(FDE_TTOSTYLE_SingleLine), |
25 m_iTTOAlign(FDE_TTOALIGNMENT_Center), | 24 m_iTTOAlign(FDE_TTOALIGNMENT_Center), |
26 m_pTimerInfoShow(nullptr), | 25 m_pTimerInfoShow(nullptr), |
27 m_pTimerInfoHide(nullptr), | 26 m_pTimerInfoHide(nullptr), |
28 m_TimerShow(this), | 27 m_TimerShow(this), |
29 m_TimerHide(this) { | 28 m_TimerHide(this) { |
30 m_rtClient.Set(0, 0, 0, 0); | 29 m_rtClient.Set(0, 0, 0, 0); |
31 m_rtCaption.Set(0, 0, 0, 0); | 30 m_rtCaption.Set(0, 0, 0, 0); |
32 m_rtAnchor.Set(0, 0, 0, 0); | 31 m_rtAnchor.Set(0, 0, 0, 0); |
33 m_pProperties->m_dwStyles &= ~FWL_WGTSTYLE_Child; | 32 m_pProperties->m_dwStyles &= ~FWL_WGTSTYLE_Child; |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 m_iTTOAlign = FDE_TTOALIGNMENT_Center; | 151 m_iTTOAlign = FDE_TTOALIGNMENT_Center; |
153 m_dwTTOStyles = FDE_TTOSTYLE_SingleLine; | 152 m_dwTTOStyles = FDE_TTOSTYLE_SingleLine; |
154 if (m_pProperties->m_dwStyleExes & FWL_WGTSTYLE_RTLReading) { | 153 if (m_pProperties->m_dwStyleExes & FWL_WGTSTYLE_RTLReading) { |
155 m_dwTTOStyles |= FDE_TTOSTYLE_RTL; | 154 m_dwTTOStyles |= FDE_TTOSTYLE_RTL; |
156 } | 155 } |
157 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_TTP_Multiline) { | 156 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_TTP_Multiline) { |
158 m_dwTTOStyles &= ~FDE_TTOSTYLE_SingleLine; | 157 m_dwTTOStyles &= ~FDE_TTOSTYLE_SingleLine; |
159 } | 158 } |
160 } | 159 } |
161 | 160 |
162 void IFWL_ToolTip::SetAnchor(const CFX_RectF& rtAnchor) { | |
163 m_rtAnchor = rtAnchor; | |
164 } | |
165 | |
166 void IFWL_ToolTip::Show() { | |
167 IFWL_ToolTipDP* pData = | |
168 static_cast<IFWL_ToolTipDP*>(m_pProperties->m_pDataProvider); | |
169 int32_t nInitDelay = pData->GetInitialDelay(this); | |
170 if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Invisible)) | |
171 m_pTimerInfoShow = m_TimerShow.StartTimer(nInitDelay, false); | |
172 } | |
173 | |
174 void IFWL_ToolTip::Hide() { | |
175 SetStates(FWL_WGTSTATE_Invisible, true); | |
176 if (m_pTimerInfoHide) { | |
177 m_pTimerInfoHide->StopTimer(); | |
178 m_pTimerInfoHide = nullptr; | |
179 } | |
180 if (m_pTimerInfoShow) { | |
181 m_pTimerInfoShow->StopTimer(); | |
182 m_pTimerInfoShow = nullptr; | |
183 } | |
184 } | |
185 | |
186 void IFWL_ToolTip::SetStates(uint32_t dwStates, bool bSet) { | 161 void IFWL_ToolTip::SetStates(uint32_t dwStates, bool bSet) { |
187 if ((dwStates & FWL_WGTSTATE_Invisible) && !bSet) { | 162 if ((dwStates & FWL_WGTSTATE_Invisible) && !bSet) { |
188 IFWL_ToolTipDP* pData = | 163 IFWL_ToolTipDP* pData = |
189 static_cast<IFWL_ToolTipDP*>(m_pProperties->m_pDataProvider); | 164 static_cast<IFWL_ToolTipDP*>(m_pProperties->m_pDataProvider); |
190 int32_t nAutoPopDelay = pData->GetAutoPopDelay(this); | 165 int32_t nAutoPopDelay = pData->GetAutoPopDelay(this); |
191 m_pTimerInfoHide = m_TimerHide.StartTimer(nAutoPopDelay, false); | 166 m_pTimerInfoHide = m_TimerHide.StartTimer(nAutoPopDelay, false); |
192 } | 167 } |
193 IFWL_Widget::SetStates(dwStates, bSet); | 168 IFWL_Widget::SetStates(dwStates, bSet); |
194 } | 169 } |
195 | 170 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 pToolTip->m_pTimerInfoShow = nullptr; | 213 pToolTip->m_pTimerInfoShow = nullptr; |
239 return; | 214 return; |
240 } | 215 } |
241 } | 216 } |
242 if (pToolTip->m_pTimerInfoHide == pTimerInfo && pToolTip->m_pTimerInfoHide) { | 217 if (pToolTip->m_pTimerInfoHide == pTimerInfo && pToolTip->m_pTimerInfoHide) { |
243 pToolTip->SetStates(FWL_WGTSTATE_Invisible, true); | 218 pToolTip->SetStates(FWL_WGTSTATE_Invisible, true); |
244 pToolTip->m_pTimerInfoHide->StopTimer(); | 219 pToolTip->m_pTimerInfoHide->StopTimer(); |
245 pToolTip->m_pTimerInfoHide = nullptr; | 220 pToolTip->m_pTimerInfoHide = nullptr; |
246 } | 221 } |
247 } | 222 } |
OLD | NEW |