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 "third_party/base/ptr_util.h" | 9 #include "third_party/base/ptr_util.h" |
10 #include "xfa/fwl/core/cfwl_themebackground.h" | 10 #include "xfa/fwl/core/cfwl_themebackground.h" |
11 #include "xfa/fwl/core/cfwl_widgetproperties.h" | 11 #include "xfa/fwl/core/cfwl_widgetproperties.h" |
12 #include "xfa/fwl/core/fwl_noteimp.h" | 12 #include "xfa/fwl/core/fwl_noteimp.h" |
13 #include "xfa/fwl/core/ifwl_caret.h" | 13 #include "xfa/fwl/core/ifwl_caret.h" |
14 #include "xfa/fwl/core/ifwl_themeprovider.h" | 14 #include "xfa/fwl/core/ifwl_themeprovider.h" |
15 | 15 |
16 namespace { | |
17 | |
18 const int kFrequency = 400; | |
npm
2016/11/14 15:19:30
nit: uint32_t
dsinclair
2016/11/14 16:40:37
Done.
| |
19 | |
20 } // namespace | |
21 | |
16 IFWL_Caret::IFWL_Caret(const IFWL_App* app, | 22 IFWL_Caret::IFWL_Caret(const IFWL_App* app, |
17 std::unique_ptr<CFWL_WidgetProperties> properties, | 23 std::unique_ptr<CFWL_WidgetProperties> properties, |
18 IFWL_Widget* pOuter) | 24 IFWL_Widget* pOuter) |
19 : IFWL_Widget(app, std::move(properties), pOuter), | 25 : IFWL_Widget(app, std::move(properties), pOuter), |
20 m_pTimer(new IFWL_Caret::Timer(this)), | 26 m_pTimer(new IFWL_Caret::Timer(this)), |
21 m_pTimerInfo(nullptr), | 27 m_pTimerInfo(nullptr) { |
22 m_dwElapse(400), | |
23 m_bSetColor(false) { | |
24 SetStates(FWL_STATE_CAT_HightLight); | 28 SetStates(FWL_STATE_CAT_HightLight); |
25 } | 29 } |
26 | 30 |
27 IFWL_Caret::~IFWL_Caret() { | 31 IFWL_Caret::~IFWL_Caret() { |
28 if (m_pTimerInfo) { | 32 if (m_pTimerInfo) { |
29 m_pTimerInfo->StopTimer(); | 33 m_pTimerInfo->StopTimer(); |
30 m_pTimerInfo = nullptr; | 34 m_pTimerInfo = nullptr; |
31 } | 35 } |
32 } | 36 } |
33 | 37 |
(...skipping 12 matching lines...) Expand all Loading... | |
46 | 50 |
47 DrawCaretBK(pGraphics, m_pProperties->m_pThemeProvider, pMatrix); | 51 DrawCaretBK(pGraphics, m_pProperties->m_pThemeProvider, pMatrix); |
48 } | 52 } |
49 | 53 |
50 void IFWL_Caret::ShowCaret(bool bFlag) { | 54 void IFWL_Caret::ShowCaret(bool bFlag) { |
51 if (m_pTimerInfo) { | 55 if (m_pTimerInfo) { |
52 m_pTimerInfo->StopTimer(); | 56 m_pTimerInfo->StopTimer(); |
53 m_pTimerInfo = nullptr; | 57 m_pTimerInfo = nullptr; |
54 } | 58 } |
55 if (bFlag) | 59 if (bFlag) |
56 m_pTimerInfo = m_pTimer->StartTimer(m_dwElapse, true); | 60 m_pTimerInfo = m_pTimer->StartTimer(kFrequency, true); |
57 | 61 |
58 SetStates(FWL_WGTSTATE_Invisible, !bFlag); | 62 SetStates(FWL_WGTSTATE_Invisible, !bFlag); |
59 } | 63 } |
60 | 64 |
61 FWL_Error IFWL_Caret::GetFrequency(uint32_t& elapse) { | |
62 elapse = m_dwElapse; | |
63 return FWL_Error::Succeeded; | |
64 } | |
65 | |
66 FWL_Error IFWL_Caret::SetFrequency(uint32_t elapse) { | |
67 m_dwElapse = elapse; | |
68 return FWL_Error::Succeeded; | |
69 } | |
70 | |
71 FWL_Error IFWL_Caret::SetColor(CFX_Color crFill) { | |
72 m_bSetColor = true; | |
73 m_crFill = crFill; | |
74 return FWL_Error::Succeeded; | |
75 } | |
76 | |
77 void IFWL_Caret::DrawCaretBK(CFX_Graphics* pGraphics, | 65 void IFWL_Caret::DrawCaretBK(CFX_Graphics* pGraphics, |
78 IFWL_ThemeProvider* pTheme, | 66 IFWL_ThemeProvider* pTheme, |
79 const CFX_Matrix* pMatrix) { | 67 const CFX_Matrix* pMatrix) { |
80 CFX_RectF rect; | 68 CFX_RectF rect; |
81 GetWidgetRect(rect); | 69 GetWidgetRect(rect); |
82 rect.Set(0, 0, rect.width, rect.height); | 70 rect.Set(0, 0, rect.width, rect.height); |
83 CFWL_ThemeBackground param; | 71 CFWL_ThemeBackground param; |
84 param.m_pWidget = this; | 72 param.m_pWidget = this; |
85 param.m_pGraphics = pGraphics; | 73 param.m_pGraphics = pGraphics; |
86 param.m_rtPart = rect; | 74 param.m_rtPart = rect; |
87 if (m_bSetColor) | |
88 param.m_pData = &m_crFill; | |
89 if (!(m_pProperties->m_dwStates & FWL_STATE_CAT_HightLight)) | 75 if (!(m_pProperties->m_dwStates & FWL_STATE_CAT_HightLight)) |
90 return; | 76 return; |
91 | 77 |
92 param.m_iPart = CFWL_Part::Background; | 78 param.m_iPart = CFWL_Part::Background; |
93 param.m_dwStates = CFWL_PartState_HightLight; | 79 param.m_dwStates = CFWL_PartState_HightLight; |
94 if (pMatrix) | 80 if (pMatrix) |
95 param.m_matrix.Concat(*pMatrix); | 81 param.m_matrix.Concat(*pMatrix); |
96 | 82 |
97 pTheme->DrawBackground(¶m); | 83 pTheme->DrawBackground(¶m); |
98 } | 84 } |
(...skipping 10 matching lines...) Expand all Loading... | |
109 void IFWL_Caret::Timer::Run(IFWL_TimerInfo* pTimerInfo) { | 95 void IFWL_Caret::Timer::Run(IFWL_TimerInfo* pTimerInfo) { |
110 IFWL_Caret* pCaret = static_cast<IFWL_Caret*>(m_pWidget); | 96 IFWL_Caret* pCaret = static_cast<IFWL_Caret*>(m_pWidget); |
111 bool toggle = !(pCaret->GetStates() & FWL_STATE_CAT_HightLight); | 97 bool toggle = !(pCaret->GetStates() & FWL_STATE_CAT_HightLight); |
112 pCaret->SetStates(FWL_STATE_CAT_HightLight, toggle); | 98 pCaret->SetStates(FWL_STATE_CAT_HightLight, toggle); |
113 | 99 |
114 CFX_RectF rt; | 100 CFX_RectF rt; |
115 pCaret->GetWidgetRect(rt); | 101 pCaret->GetWidgetRect(rt); |
116 rt.Set(0, 0, rt.width + 1, rt.height); | 102 rt.Set(0, 0, rt.width + 1, rt.height); |
117 pCaret->Repaint(&rt); | 103 pCaret->Repaint(&rt); |
118 } | 104 } |
OLD | NEW |