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/basewidget/fwl_tooltipctrlimp.h" | 7 #include "xfa/fwl/basewidget/fwl_tooltipctrlimp.h" |
8 | 8 |
9 #include "xfa/fde/tto/fde_textout.h" | 9 #include "xfa/fde/tto/fde_textout.h" |
10 #include "xfa/fwl/basewidget/ifwl_tooltip.h" | 10 #include "xfa/fwl/basewidget/ifwl_tooltip.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 } | 41 } |
42 | 42 |
43 IFWL_ToolTip::IFWL_ToolTip() {} | 43 IFWL_ToolTip::IFWL_ToolTip() {} |
44 | 44 |
45 CFWL_ToolTipImp::CFWL_ToolTipImp(const CFWL_WidgetImpProperties& properties, | 45 CFWL_ToolTipImp::CFWL_ToolTipImp(const CFWL_WidgetImpProperties& properties, |
46 IFWL_Widget* pOuter) | 46 IFWL_Widget* pOuter) |
47 : CFWL_FormImp(properties, pOuter), | 47 : CFWL_FormImp(properties, pOuter), |
48 m_bBtnDown(FALSE), | 48 m_bBtnDown(FALSE), |
49 m_dwTTOStyles(FDE_TTOSTYLE_SingleLine), | 49 m_dwTTOStyles(FDE_TTOSTYLE_SingleLine), |
50 m_iTTOAlign(FDE_TTOALIGNMENT_Center), | 50 m_iTTOAlign(FDE_TTOALIGNMENT_Center), |
51 m_hTimerShow(NULL), | 51 m_pTimerInfoShow(nullptr), |
52 m_hTimerHide(NULL), | 52 m_pTimerInfoHide(nullptr), |
53 m_pTimer(NULL) { | 53 m_pTimer(nullptr) { |
54 m_rtClient.Set(0, 0, 0, 0); | 54 m_rtClient.Set(0, 0, 0, 0); |
55 m_rtCaption.Set(0, 0, 0, 0); | 55 m_rtCaption.Set(0, 0, 0, 0); |
56 m_rtAnchor.Set(0, 0, 0, 0); | 56 m_rtAnchor.Set(0, 0, 0, 0); |
57 m_TimerShow.m_pToolTip = this; | 57 m_TimerShow.m_pToolTip = this; |
58 m_TimerHide.m_pToolTip = this; | 58 m_TimerHide.m_pToolTip = this; |
59 } | 59 } |
60 | 60 |
61 CFWL_ToolTipImp::~CFWL_ToolTipImp() { | 61 CFWL_ToolTipImp::~CFWL_ToolTipImp() { |
62 if (m_pTimer) { | 62 delete m_pTimer; |
63 delete m_pTimer; | 63 m_pTimer = nullptr; |
64 m_pTimer = NULL; | |
65 } | |
66 } | 64 } |
67 | 65 |
68 FWL_Error CFWL_ToolTipImp::GetClassName(CFX_WideString& wsClass) const { | 66 FWL_Error CFWL_ToolTipImp::GetClassName(CFX_WideString& wsClass) const { |
69 wsClass = FWL_CLASS_ToolTip; | 67 wsClass = FWL_CLASS_ToolTip; |
70 return FWL_Error::Succeeded; | 68 return FWL_Error::Succeeded; |
71 } | 69 } |
72 | 70 |
73 FWL_Type CFWL_ToolTipImp::GetClassID() const { | 71 FWL_Type CFWL_ToolTipImp::GetClassID() const { |
74 return FWL_Type::ToolTip; | 72 return FWL_Type::ToolTip; |
75 } | 73 } |
76 | 74 |
77 FWL_Error CFWL_ToolTipImp::Initialize() { | 75 FWL_Error CFWL_ToolTipImp::Initialize() { |
78 m_pProperties->m_dwStyles |= FWL_WGTSTYLE_Popup; | 76 m_pProperties->m_dwStyles |= FWL_WGTSTYLE_Popup; |
79 m_pProperties->m_dwStyles &= ~FWL_WGTSTYLE_Child; | 77 m_pProperties->m_dwStyles &= ~FWL_WGTSTYLE_Child; |
80 if (CFWL_WidgetImp::Initialize() != FWL_Error::Succeeded) | 78 if (CFWL_WidgetImp::Initialize() != FWL_Error::Succeeded) |
81 return FWL_Error::Indefinite; | 79 return FWL_Error::Indefinite; |
82 | 80 |
83 m_pDelegate = new CFWL_ToolTipImpDelegate(this); | 81 m_pDelegate = new CFWL_ToolTipImpDelegate(this); |
84 return FWL_Error::Succeeded; | 82 return FWL_Error::Succeeded; |
85 } | 83 } |
86 | 84 |
87 FWL_Error CFWL_ToolTipImp::Finalize() { | 85 FWL_Error CFWL_ToolTipImp::Finalize() { |
88 delete m_pDelegate; | 86 delete m_pDelegate; |
89 m_pDelegate = nullptr; | 87 m_pDelegate = nullptr; |
90 return CFWL_WidgetImp::Finalize(); | 88 return CFWL_WidgetImp::Finalize(); |
91 } | 89 } |
92 FWL_Error CFWL_ToolTipImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { | 90 FWL_Error CFWL_ToolTipImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { |
93 if (bAutoSize) { | 91 if (bAutoSize) { |
94 rect.Set(0, 0, 0, 0); | 92 rect.Set(0, 0, 0, 0); |
95 if (m_pProperties->m_pThemeProvider == NULL) { | 93 if (!m_pProperties->m_pThemeProvider) { |
96 m_pProperties->m_pThemeProvider = GetAvailableTheme(); | 94 m_pProperties->m_pThemeProvider = GetAvailableTheme(); |
97 } | 95 } |
98 CFX_WideString wsCaption; | 96 CFX_WideString wsCaption; |
99 IFWL_ToolTipDP* pData = | 97 IFWL_ToolTipDP* pData = |
100 static_cast<IFWL_ToolTipDP*>(m_pProperties->m_pDataProvider); | 98 static_cast<IFWL_ToolTipDP*>(m_pProperties->m_pDataProvider); |
101 if (pData) { | 99 if (pData) { |
102 pData->GetCaption(m_pInterface, wsCaption); | 100 pData->GetCaption(m_pInterface, wsCaption); |
103 } | 101 } |
104 int32_t iLen = wsCaption.GetLength(); | 102 int32_t iLen = wsCaption.GetLength(); |
105 if (iLen > 0) { | 103 if (iLen > 0) { |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 | 212 |
215 void CFWL_ToolTipImp::SetAnchor(const CFX_RectF& rtAnchor) { | 213 void CFWL_ToolTipImp::SetAnchor(const CFX_RectF& rtAnchor) { |
216 m_rtAnchor = rtAnchor; | 214 m_rtAnchor = rtAnchor; |
217 } | 215 } |
218 | 216 |
219 void CFWL_ToolTipImp::Show() { | 217 void CFWL_ToolTipImp::Show() { |
220 IFWL_ToolTipDP* pData = | 218 IFWL_ToolTipDP* pData = |
221 static_cast<IFWL_ToolTipDP*>(m_pProperties->m_pDataProvider); | 219 static_cast<IFWL_ToolTipDP*>(m_pProperties->m_pDataProvider); |
222 int32_t nInitDelay = pData->GetInitialDelay(m_pInterface); | 220 int32_t nInitDelay = pData->GetInitialDelay(m_pInterface); |
223 if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Invisible)) | 221 if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Invisible)) |
224 m_hTimerShow = FWL_StartTimer(&m_TimerShow, nInitDelay, FALSE); | 222 m_pTimerInfoShow = m_TimerShow.StartTimer(nInitDelay, false); |
225 } | 223 } |
226 | 224 |
227 void CFWL_ToolTipImp::Hide() { | 225 void CFWL_ToolTipImp::Hide() { |
228 SetStates(FWL_WGTSTATE_Invisible, TRUE); | 226 SetStates(FWL_WGTSTATE_Invisible, TRUE); |
229 if (m_hTimerHide) { | 227 if (m_pTimerInfoHide) { |
230 FWL_StopTimer(m_hTimerHide); | 228 m_pTimerInfoHide->StopTimer(); |
231 m_hTimerHide = nullptr; | 229 m_pTimerInfoHide = nullptr; |
232 } | 230 } |
233 if (m_hTimerShow) { | 231 if (m_pTimerInfoShow) { |
234 FWL_StopTimer(m_hTimerShow); | 232 m_pTimerInfoShow->StopTimer(); |
235 m_hTimerShow = nullptr; | 233 m_pTimerInfoShow = nullptr; |
236 } | 234 } |
237 } | 235 } |
238 | 236 |
239 void CFWL_ToolTipImp::SetStates(uint32_t dwStates, FX_BOOL bSet) { | 237 void CFWL_ToolTipImp::SetStates(uint32_t dwStates, FX_BOOL bSet) { |
240 if ((dwStates & FWL_WGTSTATE_Invisible) && !bSet) { | 238 if ((dwStates & FWL_WGTSTATE_Invisible) && !bSet) { |
241 IFWL_ToolTipDP* pData = | 239 IFWL_ToolTipDP* pData = |
242 static_cast<IFWL_ToolTipDP*>(m_pProperties->m_pDataProvider); | 240 static_cast<IFWL_ToolTipDP*>(m_pProperties->m_pDataProvider); |
243 int32_t nAutoPopDelay = pData->GetAutoPopDelay(m_pInterface); | 241 int32_t nAutoPopDelay = pData->GetAutoPopDelay(m_pInterface); |
244 m_hTimerHide = FWL_StartTimer(&m_TimerHide, nAutoPopDelay, FALSE); | 242 m_pTimerInfoHide = m_TimerHide.StartTimer(nAutoPopDelay, false); |
245 } | 243 } |
246 CFWL_WidgetImp::SetStates(dwStates, bSet); | 244 CFWL_WidgetImp::SetStates(dwStates, bSet); |
247 } | 245 } |
248 | 246 |
249 void CFWL_ToolTipImp::RefreshToolTipPos() { | 247 void CFWL_ToolTipImp::RefreshToolTipPos() { |
250 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_TTP_NoAnchor) == 0) { | 248 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_TTP_NoAnchor) == 0) { |
251 CFX_RectF rtPopup; | 249 CFX_RectF rtPopup; |
252 CFX_RectF rtWidget(m_pProperties->m_rtWidget); | 250 CFX_RectF rtWidget(m_pProperties->m_rtWidget); |
253 CFX_RectF rtAnchor(m_rtAnchor); | 251 CFX_RectF rtAnchor(m_rtAnchor); |
254 rtPopup.Set(0, 0, 0, 0); | 252 rtPopup.Set(0, 0, 0, 0); |
(...skipping 14 matching lines...) Expand all Loading... |
269 } | 267 } |
270 if (rtPopup.top < 0) { | 268 if (rtPopup.top < 0) { |
271 rtPopup.Offset(0, 0 - rtPopup.top); | 269 rtPopup.Offset(0, 0 - rtPopup.top); |
272 } | 270 } |
273 SetWidgetRect(rtPopup); | 271 SetWidgetRect(rtPopup); |
274 Update(); | 272 Update(); |
275 } | 273 } |
276 } | 274 } |
277 CFWL_ToolTipImp::CFWL_ToolTipTimer::CFWL_ToolTipTimer(CFWL_ToolTipImp* pToolTip) | 275 CFWL_ToolTipImp::CFWL_ToolTipTimer::CFWL_ToolTipTimer(CFWL_ToolTipImp* pToolTip) |
278 : m_pToolTip(pToolTip) {} | 276 : m_pToolTip(pToolTip) {} |
279 int32_t CFWL_ToolTipImp::CFWL_ToolTipTimer::Run(FWL_HTIMER hTimer) { | 277 |
280 if (m_pToolTip->m_hTimerShow == hTimer && m_pToolTip->m_hTimerShow) { | 278 void CFWL_ToolTipImp::CFWL_ToolTipTimer::Run(IFWL_TimerInfo* pTimerInfo) { |
| 279 if (m_pToolTip->m_pTimerInfoShow == pTimerInfo && |
| 280 m_pToolTip->m_pTimerInfoShow) { |
281 if (m_pToolTip->GetStates() & FWL_WGTSTATE_Invisible) { | 281 if (m_pToolTip->GetStates() & FWL_WGTSTATE_Invisible) { |
282 m_pToolTip->SetStates(FWL_WGTSTATE_Invisible, FALSE); | 282 m_pToolTip->SetStates(FWL_WGTSTATE_Invisible, FALSE); |
283 m_pToolTip->RefreshToolTipPos(); | 283 m_pToolTip->RefreshToolTipPos(); |
284 FWL_StopTimer(m_pToolTip->m_hTimerShow); | 284 m_pToolTip->m_pTimerInfoShow->StopTimer(); |
285 m_pToolTip->m_hTimerShow = NULL; | 285 m_pToolTip->m_pTimerInfoShow = nullptr; |
286 return TRUE; | 286 return; |
287 } | 287 } |
288 } | 288 } |
289 if (m_pToolTip->m_hTimerHide == hTimer && m_pToolTip->m_hTimerHide) { | 289 if (m_pToolTip->m_pTimerInfoHide == pTimerInfo && |
| 290 m_pToolTip->m_pTimerInfoHide) { |
290 m_pToolTip->SetStates(FWL_WGTSTATE_Invisible, TRUE); | 291 m_pToolTip->SetStates(FWL_WGTSTATE_Invisible, TRUE); |
291 FWL_StopTimer(m_pToolTip->m_hTimerHide); | 292 m_pToolTip->m_pTimerInfoHide->StopTimer(); |
292 m_pToolTip->m_hTimerHide = NULL; | 293 m_pToolTip->m_pTimerInfoHide = nullptr; |
293 return TRUE; | |
294 } | 294 } |
295 return TRUE; | |
296 } | 295 } |
297 | 296 |
298 CFWL_ToolTipImpDelegate::CFWL_ToolTipImpDelegate(CFWL_ToolTipImp* pOwner) | 297 CFWL_ToolTipImpDelegate::CFWL_ToolTipImpDelegate(CFWL_ToolTipImp* pOwner) |
299 : m_pOwner(pOwner) {} | 298 : m_pOwner(pOwner) {} |
300 | 299 |
301 void CFWL_ToolTipImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { | 300 void CFWL_ToolTipImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { |
302 CFWL_WidgetImpDelegate::OnProcessMessage(pMessage); | 301 CFWL_WidgetImpDelegate::OnProcessMessage(pMessage); |
303 } | 302 } |
304 | 303 |
305 void CFWL_ToolTipImpDelegate::OnProcessEvent(CFWL_Event* pEvent) {} | 304 void CFWL_ToolTipImpDelegate::OnProcessEvent(CFWL_Event* pEvent) {} |
306 | 305 |
307 void CFWL_ToolTipImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics, | 306 void CFWL_ToolTipImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics, |
308 const CFX_Matrix* pMatrix) { | 307 const CFX_Matrix* pMatrix) { |
309 m_pOwner->DrawWidget(pGraphics, pMatrix); | 308 m_pOwner->DrawWidget(pGraphics, pMatrix); |
310 } | 309 } |
OLD | NEW |