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_caret.h" | 7 #include "xfa/fwl/core/ifwl_caret.h" |
8 | 8 |
9 #include "xfa/fwl/core/cfwl_themebackground.h" | 9 #include "xfa/fwl/core/cfwl_themebackground.h" |
10 #include "xfa/fwl/core/cfwl_widgetimpproperties.h" | 10 #include "xfa/fwl/core/cfwl_widgetimpproperties.h" |
11 #include "xfa/fwl/core/fwl_noteimp.h" | 11 #include "xfa/fwl/core/fwl_noteimp.h" |
12 #include "xfa/fwl/core/ifwl_caret.h" | 12 #include "xfa/fwl/core/ifwl_caret.h" |
13 #include "xfa/fwl/core/ifwl_themeprovider.h" | 13 #include "xfa/fwl/core/ifwl_themeprovider.h" |
14 | 14 |
15 IFWL_Caret::IFWL_Caret(const CFWL_WidgetImpProperties& properties, | 15 IFWL_Caret::IFWL_Caret(const IFWL_App* app, |
| 16 const CFWL_WidgetImpProperties& properties, |
16 IFWL_Widget* pOuter) | 17 IFWL_Widget* pOuter) |
17 : IFWL_Widget(properties, pOuter), | 18 : IFWL_Widget(app, properties, pOuter), |
18 m_pTimer(new CFWL_CaretTimer(this)), | 19 m_pTimer(new IFWL_Caret::Timer(this)), |
19 m_pTimerInfo(nullptr), | 20 m_pTimerInfo(nullptr), |
20 m_dwElapse(400), | 21 m_dwElapse(400), |
21 m_bSetColor(FALSE) { | 22 m_bSetColor(FALSE) { |
22 SetStates(FWL_STATE_CAT_HightLight); | 23 SetStates(FWL_STATE_CAT_HightLight); |
23 } | 24 } |
24 | 25 |
25 IFWL_Caret::~IFWL_Caret() {} | 26 IFWL_Caret::~IFWL_Caret() {} |
26 | 27 |
27 FWL_Type IFWL_Caret::GetClassID() const { | 28 FWL_Type IFWL_Caret::GetClassID() const { |
28 return FWL_Type::Caret; | 29 return FWL_Type::Caret; |
29 } | 30 } |
30 | 31 |
31 FWL_Error IFWL_Caret::Initialize() { | 32 void IFWL_Caret::Initialize() { |
32 if (IFWL_Widget::Initialize() != FWL_Error::Succeeded) | 33 IFWL_Widget::Initialize(); |
33 return FWL_Error::Indefinite; | |
34 | |
35 m_pDelegate = new CFWL_CaretImpDelegate(this); | 34 m_pDelegate = new CFWL_CaretImpDelegate(this); |
36 return FWL_Error::Succeeded; | |
37 } | 35 } |
38 | 36 |
39 void IFWL_Caret::Finalize() { | 37 void IFWL_Caret::Finalize() { |
40 if (m_pTimerInfo) { | 38 if (m_pTimerInfo) { |
41 m_pTimerInfo->StopTimer(); | 39 m_pTimerInfo->StopTimer(); |
42 m_pTimerInfo = nullptr; | 40 m_pTimerInfo = nullptr; |
43 } | 41 } |
44 delete m_pDelegate; | 42 delete m_pDelegate; |
45 m_pDelegate = nullptr; | 43 m_pDelegate = nullptr; |
46 IFWL_Widget::Finalize(); | 44 IFWL_Widget::Finalize(); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 return; | 100 return; |
103 | 101 |
104 param.m_iPart = CFWL_Part::Background; | 102 param.m_iPart = CFWL_Part::Background; |
105 param.m_dwStates = CFWL_PartState_HightLight; | 103 param.m_dwStates = CFWL_PartState_HightLight; |
106 if (pMatrix) | 104 if (pMatrix) |
107 param.m_matrix.Concat(*pMatrix); | 105 param.m_matrix.Concat(*pMatrix); |
108 | 106 |
109 pTheme->DrawBackground(¶m); | 107 pTheme->DrawBackground(¶m); |
110 } | 108 } |
111 | 109 |
112 IFWL_Caret::CFWL_CaretTimer::CFWL_CaretTimer(IFWL_Caret* pCaret) | 110 IFWL_Caret::Timer::Timer(IFWL_Caret* pCaret) : IFWL_Timer(pCaret) {} |
113 : m_pCaret(pCaret) {} | |
114 | 111 |
115 void IFWL_Caret::CFWL_CaretTimer::Run(IFWL_TimerInfo* pTimerInfo) { | 112 void IFWL_Caret::Timer::Run(IFWL_TimerInfo* pTimerInfo) { |
116 bool toggle = !(m_pCaret->GetStates() & FWL_STATE_CAT_HightLight); | 113 IFWL_Caret* pCaret = static_cast<IFWL_Caret*>(m_pWidget); |
117 m_pCaret->SetStates(FWL_STATE_CAT_HightLight, toggle); | 114 bool toggle = !(pCaret->GetStates() & FWL_STATE_CAT_HightLight); |
| 115 pCaret->SetStates(FWL_STATE_CAT_HightLight, toggle); |
118 | 116 |
119 CFX_RectF rt; | 117 CFX_RectF rt; |
120 m_pCaret->GetWidgetRect(rt); | 118 pCaret->GetWidgetRect(rt); |
121 rt.Set(0, 0, rt.width + 1, rt.height); | 119 rt.Set(0, 0, rt.width + 1, rt.height); |
122 m_pCaret->Repaint(&rt); | 120 pCaret->Repaint(&rt); |
123 } | 121 } |
124 | 122 |
125 CFWL_CaretImpDelegate::CFWL_CaretImpDelegate(IFWL_Caret* pOwner) | 123 CFWL_CaretImpDelegate::CFWL_CaretImpDelegate(IFWL_Caret* pOwner) |
126 : m_pOwner(pOwner) {} | 124 : m_pOwner(pOwner) {} |
127 | 125 |
128 void CFWL_CaretImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {} | 126 void CFWL_CaretImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {} |
129 | 127 |
130 void CFWL_CaretImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics, | 128 void CFWL_CaretImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics, |
131 const CFX_Matrix* pMatrix) { | 129 const CFX_Matrix* pMatrix) { |
132 m_pOwner->DrawWidget(pGraphics, pMatrix); | 130 m_pOwner->DrawWidget(pGraphics, pMatrix); |
133 } | 131 } |
OLD | NEW |