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_caretimp.h" | 7 #include "xfa/fwl/basewidget/fwl_caretimp.h" |
8 | 8 |
9 #include "xfa/fwl/basewidget/ifwl_caret.h" | 9 #include "xfa/fwl/basewidget/ifwl_caret.h" |
10 #include "xfa/fwl/core/cfwl_themebackground.h" | 10 #include "xfa/fwl/core/cfwl_themebackground.h" |
11 #include "xfa/fwl/core/fwl_noteimp.h" | 11 #include "xfa/fwl/core/fwl_noteimp.h" |
12 #include "xfa/fwl/core/fwl_targetimp.h" | 12 #include "xfa/fwl/core/fwl_targetimp.h" |
13 #include "xfa/fwl/core/fwl_widgetimp.h" | 13 #include "xfa/fwl/core/fwl_widgetimp.h" |
14 #include "xfa/fwl/core/ifwl_themeprovider.h" | 14 #include "xfa/fwl/core/ifwl_themeprovider.h" |
15 | 15 |
16 // static | 16 // static |
17 IFWL_Caret* IFWL_Caret::Create(const CFWL_WidgetImpProperties& properties, | 17 IFWL_Caret* IFWL_Caret::Create(const CFWL_WidgetImpProperties& properties, |
18 IFWL_Widget* pOuter) { | 18 IFWL_Widget* pOuter) { |
19 IFWL_Caret* pCaret = new IFWL_Caret; | 19 IFWL_Caret* pCaret = new IFWL_Caret; |
20 CFWL_CaretImp* pCaretImpl = new CFWL_CaretImp(properties, pOuter); | 20 CFWL_CaretImp* pCaretImpl = new CFWL_CaretImp(properties, pOuter); |
21 pCaret->SetImpl(pCaretImpl); | 21 pCaret->SetImpl(pCaretImpl); |
22 pCaretImpl->SetInterface(pCaret); | 22 pCaretImpl->SetInterface(pCaret); |
23 return pCaret; | 23 return pCaret; |
24 } | 24 } |
25 IFWL_Caret::IFWL_Caret() {} | 25 IFWL_Caret::IFWL_Caret() {} |
26 FWL_ERR IFWL_Caret::ShowCaret(FX_BOOL bFlag) { | 26 FWL_ERR IFWL_Caret::ShowCaret(FX_BOOL bFlag) { |
27 return static_cast<CFWL_CaretImp*>(GetImpl())->ShowCaret(bFlag); | 27 return static_cast<CFWL_CaretImp*>(GetImpl())->ShowCaret(bFlag); |
28 } | 28 } |
29 FWL_ERR IFWL_Caret::GetFrequency(FX_DWORD& elapse) { | 29 FWL_ERR IFWL_Caret::GetFrequency(uint32_t& elapse) { |
30 return static_cast<CFWL_CaretImp*>(GetImpl())->GetFrequency(elapse); | 30 return static_cast<CFWL_CaretImp*>(GetImpl())->GetFrequency(elapse); |
31 } | 31 } |
32 FWL_ERR IFWL_Caret::SetFrequency(FX_DWORD elapse) { | 32 FWL_ERR IFWL_Caret::SetFrequency(uint32_t elapse) { |
33 return static_cast<CFWL_CaretImp*>(GetImpl())->SetFrequency(elapse); | 33 return static_cast<CFWL_CaretImp*>(GetImpl())->SetFrequency(elapse); |
34 } | 34 } |
35 FWL_ERR IFWL_Caret::SetColor(CFX_Color crFill) { | 35 FWL_ERR IFWL_Caret::SetColor(CFX_Color crFill) { |
36 return static_cast<CFWL_CaretImp*>(GetImpl())->SetColor(crFill); | 36 return static_cast<CFWL_CaretImp*>(GetImpl())->SetColor(crFill); |
37 } | 37 } |
38 | 38 |
39 CFWL_CaretImp::CFWL_CaretImp(const CFWL_WidgetImpProperties& properties, | 39 CFWL_CaretImp::CFWL_CaretImp(const CFWL_WidgetImpProperties& properties, |
40 IFWL_Widget* pOuter) | 40 IFWL_Widget* pOuter) |
41 : CFWL_WidgetImp(properties, pOuter), | 41 : CFWL_WidgetImp(properties, pOuter), |
42 m_hTimer(nullptr), | 42 m_hTimer(nullptr), |
43 m_dwElapse(400), | 43 m_dwElapse(400), |
44 m_bSetColor(FALSE) { | 44 m_bSetColor(FALSE) { |
45 m_pTimer = new CFWL_CaretTimer(this); | 45 m_pTimer = new CFWL_CaretTimer(this); |
46 SetStates(FWL_STATE_CAT_HightLight); | 46 SetStates(FWL_STATE_CAT_HightLight); |
47 } | 47 } |
48 CFWL_CaretImp::~CFWL_CaretImp() { | 48 CFWL_CaretImp::~CFWL_CaretImp() { |
49 if (m_pTimer) { | 49 if (m_pTimer) { |
50 delete m_pTimer; | 50 delete m_pTimer; |
51 m_pTimer = NULL; | 51 m_pTimer = NULL; |
52 } | 52 } |
53 } | 53 } |
54 FWL_ERR CFWL_CaretImp::GetClassName(CFX_WideString& wsClass) const { | 54 FWL_ERR CFWL_CaretImp::GetClassName(CFX_WideString& wsClass) const { |
55 wsClass = FWL_CLASS_Caret; | 55 wsClass = FWL_CLASS_Caret; |
56 return FWL_ERR_Succeeded; | 56 return FWL_ERR_Succeeded; |
57 } | 57 } |
58 FX_DWORD CFWL_CaretImp::GetClassID() const { | 58 uint32_t CFWL_CaretImp::GetClassID() const { |
59 return FWL_CLASSHASH_Caret; | 59 return FWL_CLASSHASH_Caret; |
60 } | 60 } |
61 FWL_ERR CFWL_CaretImp::Initialize() { | 61 FWL_ERR CFWL_CaretImp::Initialize() { |
62 if (CFWL_WidgetImp::Initialize() != FWL_ERR_Succeeded) | 62 if (CFWL_WidgetImp::Initialize() != FWL_ERR_Succeeded) |
63 return FWL_ERR_Indefinite; | 63 return FWL_ERR_Indefinite; |
64 m_pDelegate = new CFWL_CaretImpDelegate(this); | 64 m_pDelegate = new CFWL_CaretImpDelegate(this); |
65 return FWL_ERR_Succeeded; | 65 return FWL_ERR_Succeeded; |
66 } | 66 } |
67 FWL_ERR CFWL_CaretImp::Finalize() { | 67 FWL_ERR CFWL_CaretImp::Finalize() { |
68 if (m_hTimer) { | 68 if (m_hTimer) { |
(...skipping 18 matching lines...) Expand all Loading... |
87 FWL_ERR CFWL_CaretImp::ShowCaret(FX_BOOL bFlag) { | 87 FWL_ERR CFWL_CaretImp::ShowCaret(FX_BOOL bFlag) { |
88 if (m_hTimer) { | 88 if (m_hTimer) { |
89 FWL_StopTimer(m_hTimer); | 89 FWL_StopTimer(m_hTimer); |
90 m_hTimer = NULL; | 90 m_hTimer = NULL; |
91 } | 91 } |
92 if (bFlag) { | 92 if (bFlag) { |
93 m_hTimer = FWL_StartTimer(m_pTimer, m_dwElapse); | 93 m_hTimer = FWL_StartTimer(m_pTimer, m_dwElapse); |
94 } | 94 } |
95 return SetStates(FWL_WGTSTATE_Invisible, !bFlag); | 95 return SetStates(FWL_WGTSTATE_Invisible, !bFlag); |
96 } | 96 } |
97 FWL_ERR CFWL_CaretImp::GetFrequency(FX_DWORD& elapse) { | 97 FWL_ERR CFWL_CaretImp::GetFrequency(uint32_t& elapse) { |
98 elapse = m_dwElapse; | 98 elapse = m_dwElapse; |
99 return FWL_ERR_Succeeded; | 99 return FWL_ERR_Succeeded; |
100 } | 100 } |
101 FWL_ERR CFWL_CaretImp::SetFrequency(FX_DWORD elapse) { | 101 FWL_ERR CFWL_CaretImp::SetFrequency(uint32_t elapse) { |
102 m_dwElapse = elapse; | 102 m_dwElapse = elapse; |
103 return FWL_ERR_Succeeded; | 103 return FWL_ERR_Succeeded; |
104 } | 104 } |
105 FWL_ERR CFWL_CaretImp::SetColor(CFX_Color crFill) { | 105 FWL_ERR CFWL_CaretImp::SetColor(CFX_Color crFill) { |
106 m_bSetColor = TRUE; | 106 m_bSetColor = TRUE; |
107 m_crFill = crFill; | 107 m_crFill = crFill; |
108 return FWL_ERR_Succeeded; | 108 return FWL_ERR_Succeeded; |
109 } | 109 } |
110 FX_BOOL CFWL_CaretImp::DrawCaretBK(CFX_Graphics* pGraphics, | 110 FX_BOOL CFWL_CaretImp::DrawCaretBK(CFX_Graphics* pGraphics, |
111 IFWL_ThemeProvider* pTheme, | 111 IFWL_ThemeProvider* pTheme, |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 } | 149 } |
150 CFWL_CaretImpDelegate::CFWL_CaretImpDelegate(CFWL_CaretImp* pOwner) | 150 CFWL_CaretImpDelegate::CFWL_CaretImpDelegate(CFWL_CaretImp* pOwner) |
151 : m_pOwner(pOwner) {} | 151 : m_pOwner(pOwner) {} |
152 int32_t CFWL_CaretImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { | 152 int32_t CFWL_CaretImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { |
153 return 1; | 153 return 1; |
154 } | 154 } |
155 FWL_ERR CFWL_CaretImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics, | 155 FWL_ERR CFWL_CaretImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics, |
156 const CFX_Matrix* pMatrix) { | 156 const CFX_Matrix* pMatrix) { |
157 return m_pOwner->DrawWidget(pGraphics, pMatrix); | 157 return m_pOwner->DrawWidget(pGraphics, pMatrix); |
158 } | 158 } |
OLD | NEW |