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/cfwl_caret.h" | 7 #include "xfa/fwl/core/cfwl_caret.h" |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 if (!m_pProperties->m_pThemeProvider) | 52 if (!m_pProperties->m_pThemeProvider) |
53 return; | 53 return; |
54 | 54 |
55 DrawCaretBK(pGraphics, m_pProperties->m_pThemeProvider, pMatrix); | 55 DrawCaretBK(pGraphics, m_pProperties->m_pThemeProvider, pMatrix); |
56 } | 56 } |
57 | 57 |
58 void CFWL_Caret::ShowCaret() { | 58 void CFWL_Caret::ShowCaret() { |
59 if (m_pTimerInfo) | 59 if (m_pTimerInfo) |
60 m_pTimerInfo->StopTimer(); | 60 m_pTimerInfo->StopTimer(); |
61 m_pTimerInfo = m_pTimer->StartTimer(kFrequency, true); | 61 m_pTimerInfo = m_pTimer->StartTimer(kFrequency, true); |
62 SetStates(FWL_WGTSTATE_Invisible, false); | 62 RemoveStates(FWL_WGTSTATE_Invisible); |
63 } | 63 } |
64 | 64 |
65 void CFWL_Caret::HideCaret() { | 65 void CFWL_Caret::HideCaret() { |
66 if (m_pTimerInfo) { | 66 if (m_pTimerInfo) { |
67 m_pTimerInfo->StopTimer(); | 67 m_pTimerInfo->StopTimer(); |
68 m_pTimerInfo = nullptr; | 68 m_pTimerInfo = nullptr; |
69 } | 69 } |
70 SetStates(FWL_WGTSTATE_Invisible, true); | 70 SetStates(FWL_WGTSTATE_Invisible); |
71 } | 71 } |
72 | 72 |
73 void CFWL_Caret::DrawCaretBK(CFX_Graphics* pGraphics, | 73 void CFWL_Caret::DrawCaretBK(CFX_Graphics* pGraphics, |
74 IFWL_ThemeProvider* pTheme, | 74 IFWL_ThemeProvider* pTheme, |
75 const CFX_Matrix* pMatrix) { | 75 const CFX_Matrix* pMatrix) { |
76 if (!(m_pProperties->m_dwStates & FWL_STATE_CAT_HightLight)) | 76 if (!(m_pProperties->m_dwStates & FWL_STATE_CAT_HightLight)) |
77 return; | 77 return; |
78 | 78 |
79 CFX_RectF rect; | 79 CFX_RectF rect; |
80 GetWidgetRect(rect); | 80 GetWidgetRect(rect, false); |
81 rect.Set(0, 0, rect.width, rect.height); | 81 rect.Set(0, 0, rect.width, rect.height); |
82 | 82 |
83 CFWL_ThemeBackground param; | 83 CFWL_ThemeBackground param; |
84 param.m_pWidget = this; | 84 param.m_pWidget = this; |
85 param.m_pGraphics = pGraphics; | 85 param.m_pGraphics = pGraphics; |
86 param.m_rtPart = rect; | 86 param.m_rtPart = rect; |
87 param.m_iPart = CFWL_Part::Background; | 87 param.m_iPart = CFWL_Part::Background; |
88 param.m_dwStates = CFWL_PartState_HightLight; | 88 param.m_dwStates = CFWL_PartState_HightLight; |
89 if (pMatrix) | 89 if (pMatrix) |
90 param.m_matrix.Concat(*pMatrix); | 90 param.m_matrix.Concat(*pMatrix); |
91 pTheme->DrawBackground(¶m); | 91 pTheme->DrawBackground(¶m); |
92 } | 92 } |
93 | 93 |
94 void CFWL_Caret::OnProcessMessage(CFWL_Message* pMessage) {} | 94 void CFWL_Caret::OnProcessMessage(CFWL_Message* pMessage) {} |
95 | 95 |
96 void CFWL_Caret::OnDrawWidget(CFX_Graphics* pGraphics, | 96 void CFWL_Caret::OnDrawWidget(CFX_Graphics* pGraphics, |
97 const CFX_Matrix* pMatrix) { | 97 const CFX_Matrix* pMatrix) { |
98 DrawWidget(pGraphics, pMatrix); | 98 DrawWidget(pGraphics, pMatrix); |
99 } | 99 } |
100 | 100 |
101 CFWL_Caret::Timer::Timer(CFWL_Caret* pCaret) : CFWL_Timer(pCaret) {} | 101 CFWL_Caret::Timer::Timer(CFWL_Caret* pCaret) : CFWL_Timer(pCaret) {} |
102 | 102 |
103 void CFWL_Caret::Timer::Run(CFWL_TimerInfo* pTimerInfo) { | 103 void CFWL_Caret::Timer::Run(CFWL_TimerInfo* pTimerInfo) { |
104 CFWL_Caret* pCaret = static_cast<CFWL_Caret*>(m_pWidget); | 104 CFWL_Caret* pCaret = static_cast<CFWL_Caret*>(m_pWidget); |
105 pCaret->SetStates(FWL_STATE_CAT_HightLight, | 105 if (!(pCaret->GetStates() & FWL_STATE_CAT_HightLight)) |
106 !(pCaret->GetStates() & FWL_STATE_CAT_HightLight)); | 106 pCaret->SetStates(FWL_STATE_CAT_HightLight); |
| 107 else |
| 108 pCaret->RemoveStates(FWL_STATE_CAT_HightLight); |
107 | 109 |
108 CFX_RectF rt; | 110 CFX_RectF rt; |
109 pCaret->GetWidgetRect(rt); | 111 pCaret->GetWidgetRect(rt, false); |
110 rt.Set(0, 0, rt.width + 1, rt.height); | 112 rt.Set(0, 0, rt.width + 1, rt.height); |
111 pCaret->Repaint(&rt); | 113 pCaret->Repaint(&rt); |
112 } | 114 } |
OLD | NEW |