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 "fpdfsdk/include/pdfwindow/PDFWindow.h" | |
8 #include "fpdfsdk/include/pdfwindow/PWL_Caret.h" | 7 #include "fpdfsdk/include/pdfwindow/PWL_Caret.h" |
9 #include "fpdfsdk/include/pdfwindow/PWL_Utils.h" | 8 #include "fpdfsdk/include/pdfwindow/PWL_Utils.h" |
10 #include "fpdfsdk/include/pdfwindow/PWL_Wnd.h" | 9 #include "fpdfsdk/include/pdfwindow/PWL_Wnd.h" |
11 | 10 |
12 #define PWL_CARET_FLASHINTERVAL 500 | 11 #define PWL_CARET_FLASHINTERVAL 500 |
13 | 12 |
14 ////////////////////////////////////////////////////////////////////// | |
15 // Construction/Destruction | |
16 ////////////////////////////////////////////////////////////////////// | |
17 | |
18 CPWL_Caret::CPWL_Caret() | 13 CPWL_Caret::CPWL_Caret() |
19 : m_bFlash(FALSE), | 14 : m_bFlash(FALSE), |
20 m_ptHead(0, 0), | 15 m_ptHead(0, 0), |
21 m_ptFoot(0, 0), | 16 m_ptFoot(0, 0), |
22 m_fWidth(0.4f), | 17 m_fWidth(0.4f), |
23 m_nDelay(0) {} | 18 m_nDelay(0) {} |
24 | 19 |
25 CPWL_Caret::~CPWL_Caret() {} | 20 CPWL_Caret::~CPWL_Caret() {} |
26 | 21 |
27 CFX_ByteString CPWL_Caret::GetClassName() const { | 22 CFX_ByteString CPWL_Caret::GetClassName() const { |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 const CPDF_Point& ptHead, | 113 const CPDF_Point& ptHead, |
119 const CPDF_Point& ptFoot) { | 114 const CPDF_Point& ptFoot) { |
120 if (bVisible) { | 115 if (bVisible) { |
121 if (IsVisible()) { | 116 if (IsVisible()) { |
122 if (m_ptHead.x != ptHead.x || m_ptHead.y != ptHead.y || | 117 if (m_ptHead.x != ptHead.x || m_ptHead.y != ptHead.y || |
123 m_ptFoot.x != ptFoot.x || m_ptFoot.y != ptFoot.y) { | 118 m_ptFoot.x != ptFoot.x || m_ptFoot.y != ptFoot.y) { |
124 m_ptHead = ptHead; | 119 m_ptHead = ptHead; |
125 m_ptFoot = ptFoot; | 120 m_ptFoot = ptFoot; |
126 | 121 |
127 m_bFlash = TRUE; | 122 m_bFlash = TRUE; |
128 // Move(GetCaretRect(),FALSE,TRUE); | |
129 Move(m_rcInvalid, FALSE, TRUE); | 123 Move(m_rcInvalid, FALSE, TRUE); |
130 } | 124 } |
131 } else { | 125 } else { |
132 m_ptHead = ptHead; | 126 m_ptHead = ptHead; |
133 m_ptFoot = ptFoot; | 127 m_ptFoot = ptFoot; |
134 | 128 |
135 EndTimer(); | 129 EndTimer(); |
136 BeginTimer(PWL_CARET_FLASHINTERVAL); | 130 BeginTimer(PWL_CARET_FLASHINTERVAL); |
137 | 131 |
138 CPWL_Wnd::SetVisible(TRUE); | 132 CPWL_Wnd::SetVisible(TRUE); |
139 m_bFlash = TRUE; | 133 m_bFlash = TRUE; |
140 | 134 |
141 // Move(GetCaretRect(),FALSE,TRUE); | |
142 Move(m_rcInvalid, FALSE, TRUE); | 135 Move(m_rcInvalid, FALSE, TRUE); |
143 } | 136 } |
144 } else { | 137 } else { |
145 m_ptHead = CPDF_Point(0, 0); | 138 m_ptHead = CPDF_Point(0, 0); |
146 m_ptFoot = CPDF_Point(0, 0); | 139 m_ptFoot = CPDF_Point(0, 0); |
147 | 140 |
148 m_bFlash = FALSE; | 141 m_bFlash = FALSE; |
149 if (IsVisible()) { | 142 if (IsVisible()) { |
150 EndTimer(); | 143 EndTimer(); |
151 CPWL_Wnd::SetVisible(FALSE); | 144 CPWL_Wnd::SetVisible(FALSE); |
152 } | 145 } |
153 } | 146 } |
154 } | 147 } |
155 | 148 |
156 void CPWL_Caret::InvalidateRect(CPDF_Rect* pRect) { | 149 void CPWL_Caret::InvalidateRect(CPDF_Rect* pRect) { |
157 if (pRect) { | 150 if (pRect) { |
158 CPDF_Rect rcRefresh = CPWL_Utils::InflateRect(*pRect, 0.5f); | 151 CPDF_Rect rcRefresh = CPWL_Utils::InflateRect(*pRect, 0.5f); |
159 rcRefresh.top += 1; | 152 rcRefresh.top += 1; |
160 rcRefresh.bottom -= 1; | 153 rcRefresh.bottom -= 1; |
161 | 154 |
162 CPWL_Wnd::InvalidateRect(&rcRefresh); | 155 CPWL_Wnd::InvalidateRect(&rcRefresh); |
163 } else | 156 } else { |
164 CPWL_Wnd::InvalidateRect(pRect); | 157 CPWL_Wnd::InvalidateRect(pRect); |
| 158 } |
165 } | 159 } |
OLD | NEW |