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/formfiller/cffl_formfiller.h" | 7 #include "fpdfsdk/formfiller/cffl_formfiller.h" |
8 | 8 |
9 #include "core/fpdfapi/fpdf_page/include/cpdf_page.h" | 9 #include "core/fpdfapi/fpdf_page/include/cpdf_page.h" |
10 #include "core/fxge/include/cfx_renderdevice.h" | 10 #include "core/fxge/include/cfx_renderdevice.h" |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 CPDFSDK_Annot* pAnnot) {} | 118 CPDFSDK_Annot* pAnnot) {} |
119 | 119 |
120 void CFFL_FormFiller::OnMouseExit(CPDFSDK_PageView* pPageView, | 120 void CFFL_FormFiller::OnMouseExit(CPDFSDK_PageView* pPageView, |
121 CPDFSDK_Annot* pAnnot) { | 121 CPDFSDK_Annot* pAnnot) { |
122 EndTimer(); | 122 EndTimer(); |
123 ASSERT(m_pWidget); | 123 ASSERT(m_pWidget); |
124 } | 124 } |
125 | 125 |
126 FX_BOOL CFFL_FormFiller::OnLButtonDown(CPDFSDK_PageView* pPageView, | 126 FX_BOOL CFFL_FormFiller::OnLButtonDown(CPDFSDK_PageView* pPageView, |
127 CPDFSDK_Annot* pAnnot, | 127 CPDFSDK_Annot* pAnnot, |
128 FX_UINT nFlags, | 128 uint32_t nFlags, |
129 const CFX_FloatPoint& point) { | 129 const CFX_FloatPoint& point) { |
130 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, TRUE)) { | 130 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, TRUE)) { |
131 m_bValid = TRUE; | 131 m_bValid = TRUE; |
132 FX_RECT rect = GetViewBBox(pPageView, pAnnot); | 132 FX_RECT rect = GetViewBBox(pPageView, pAnnot); |
133 InvalidateRect(rect.left, rect.top, rect.right, rect.bottom); | 133 InvalidateRect(rect.left, rect.top, rect.right, rect.bottom); |
134 | 134 |
135 if (!rect.Contains((int)point.x, (int)point.y)) | 135 if (!rect.Contains((int)point.x, (int)point.y)) |
136 return FALSE; | 136 return FALSE; |
137 | 137 |
138 return pWnd->OnLButtonDown(WndtoPWL(pPageView, point), nFlags); | 138 return pWnd->OnLButtonDown(WndtoPWL(pPageView, point), nFlags); |
139 } | 139 } |
140 | 140 |
141 return FALSE; | 141 return FALSE; |
142 } | 142 } |
143 | 143 |
144 FX_BOOL CFFL_FormFiller::OnLButtonUp(CPDFSDK_PageView* pPageView, | 144 FX_BOOL CFFL_FormFiller::OnLButtonUp(CPDFSDK_PageView* pPageView, |
145 CPDFSDK_Annot* pAnnot, | 145 CPDFSDK_Annot* pAnnot, |
146 FX_UINT nFlags, | 146 uint32_t nFlags, |
147 const CFX_FloatPoint& point) { | 147 const CFX_FloatPoint& point) { |
148 CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE); | 148 CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE); |
149 if (!pWnd) | 149 if (!pWnd) |
150 return FALSE; | 150 return FALSE; |
151 | 151 |
152 FX_RECT rcFFL = GetViewBBox(pPageView, pAnnot); | 152 FX_RECT rcFFL = GetViewBBox(pPageView, pAnnot); |
153 InvalidateRect(rcFFL.left, rcFFL.top, rcFFL.right, rcFFL.bottom); | 153 InvalidateRect(rcFFL.left, rcFFL.top, rcFFL.right, rcFFL.bottom); |
154 pWnd->OnLButtonUp(WndtoPWL(pPageView, point), nFlags); | 154 pWnd->OnLButtonUp(WndtoPWL(pPageView, point), nFlags); |
155 return TRUE; | 155 return TRUE; |
156 } | 156 } |
157 | 157 |
158 FX_BOOL CFFL_FormFiller::OnLButtonDblClk(CPDFSDK_PageView* pPageView, | 158 FX_BOOL CFFL_FormFiller::OnLButtonDblClk(CPDFSDK_PageView* pPageView, |
159 CPDFSDK_Annot* pAnnot, | 159 CPDFSDK_Annot* pAnnot, |
160 FX_UINT nFlags, | 160 uint32_t nFlags, |
161 const CFX_FloatPoint& point) { | 161 const CFX_FloatPoint& point) { |
162 CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE); | 162 CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE); |
163 if (!pWnd) | 163 if (!pWnd) |
164 return FALSE; | 164 return FALSE; |
165 | 165 |
166 pWnd->OnLButtonDblClk(WndtoPWL(pPageView, point), nFlags); | 166 pWnd->OnLButtonDblClk(WndtoPWL(pPageView, point), nFlags); |
167 return TRUE; | 167 return TRUE; |
168 } | 168 } |
169 | 169 |
170 FX_BOOL CFFL_FormFiller::OnMouseMove(CPDFSDK_PageView* pPageView, | 170 FX_BOOL CFFL_FormFiller::OnMouseMove(CPDFSDK_PageView* pPageView, |
171 CPDFSDK_Annot* pAnnot, | 171 CPDFSDK_Annot* pAnnot, |
172 FX_UINT nFlags, | 172 uint32_t nFlags, |
173 const CFX_FloatPoint& point) { | 173 const CFX_FloatPoint& point) { |
174 if (m_ptOldPos != point) | 174 if (m_ptOldPos != point) |
175 m_ptOldPos = point; | 175 m_ptOldPos = point; |
176 | 176 |
177 CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE); | 177 CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE); |
178 if (!pWnd) | 178 if (!pWnd) |
179 return FALSE; | 179 return FALSE; |
180 | 180 |
181 pWnd->OnMouseMove(WndtoPWL(pPageView, point), nFlags); | 181 pWnd->OnMouseMove(WndtoPWL(pPageView, point), nFlags); |
182 return TRUE; | 182 return TRUE; |
183 } | 183 } |
184 | 184 |
185 FX_BOOL CFFL_FormFiller::OnMouseWheel(CPDFSDK_PageView* pPageView, | 185 FX_BOOL CFFL_FormFiller::OnMouseWheel(CPDFSDK_PageView* pPageView, |
186 CPDFSDK_Annot* pAnnot, | 186 CPDFSDK_Annot* pAnnot, |
187 FX_UINT nFlags, | 187 uint32_t nFlags, |
188 short zDelta, | 188 short zDelta, |
189 const CFX_FloatPoint& point) { | 189 const CFX_FloatPoint& point) { |
190 if (!IsValid()) | 190 if (!IsValid()) |
191 return FALSE; | 191 return FALSE; |
192 | 192 |
193 CPWL_Wnd* pWnd = GetPDFWindow(pPageView, TRUE); | 193 CPWL_Wnd* pWnd = GetPDFWindow(pPageView, TRUE); |
194 return pWnd && pWnd->OnMouseWheel(zDelta, WndtoPWL(pPageView, point), nFlags); | 194 return pWnd && pWnd->OnMouseWheel(zDelta, WndtoPWL(pPageView, point), nFlags); |
195 } | 195 } |
196 | 196 |
197 FX_BOOL CFFL_FormFiller::OnRButtonDown(CPDFSDK_PageView* pPageView, | 197 FX_BOOL CFFL_FormFiller::OnRButtonDown(CPDFSDK_PageView* pPageView, |
198 CPDFSDK_Annot* pAnnot, | 198 CPDFSDK_Annot* pAnnot, |
199 FX_UINT nFlags, | 199 uint32_t nFlags, |
200 const CFX_FloatPoint& point) { | 200 const CFX_FloatPoint& point) { |
201 CPWL_Wnd* pWnd = GetPDFWindow(pPageView, TRUE); | 201 CPWL_Wnd* pWnd = GetPDFWindow(pPageView, TRUE); |
202 if (!pWnd) | 202 if (!pWnd) |
203 return FALSE; | 203 return FALSE; |
204 | 204 |
205 pWnd->OnRButtonDown(WndtoPWL(pPageView, point), nFlags); | 205 pWnd->OnRButtonDown(WndtoPWL(pPageView, point), nFlags); |
206 return TRUE; | 206 return TRUE; |
207 } | 207 } |
208 | 208 |
209 FX_BOOL CFFL_FormFiller::OnRButtonUp(CPDFSDK_PageView* pPageView, | 209 FX_BOOL CFFL_FormFiller::OnRButtonUp(CPDFSDK_PageView* pPageView, |
210 CPDFSDK_Annot* pAnnot, | 210 CPDFSDK_Annot* pAnnot, |
211 FX_UINT nFlags, | 211 uint32_t nFlags, |
212 const CFX_FloatPoint& point) { | 212 const CFX_FloatPoint& point) { |
213 CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE); | 213 CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE); |
214 if (!pWnd) | 214 if (!pWnd) |
215 return FALSE; | 215 return FALSE; |
216 | 216 |
217 pWnd->OnRButtonUp(WndtoPWL(pPageView, point), nFlags); | 217 pWnd->OnRButtonUp(WndtoPWL(pPageView, point), nFlags); |
218 return TRUE; | 218 return TRUE; |
219 } | 219 } |
220 | 220 |
221 FX_BOOL CFFL_FormFiller::OnKeyDown(CPDFSDK_Annot* pAnnot, | 221 FX_BOOL CFFL_FormFiller::OnKeyDown(CPDFSDK_Annot* pAnnot, |
222 FX_UINT nKeyCode, | 222 uint32_t nKeyCode, |
223 FX_UINT nFlags) { | 223 uint32_t nFlags) { |
224 if (IsValid()) { | 224 if (IsValid()) { |
225 CPDFSDK_PageView* pPageView = GetCurPageView(true); | 225 CPDFSDK_PageView* pPageView = GetCurPageView(true); |
226 ASSERT(pPageView); | 226 ASSERT(pPageView); |
227 | 227 |
228 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE)) { | 228 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE)) { |
229 return pWnd->OnKeyDown(nKeyCode, nFlags); | 229 return pWnd->OnKeyDown(nKeyCode, nFlags); |
230 } | 230 } |
231 } | 231 } |
232 | 232 |
233 return FALSE; | 233 return FALSE; |
234 } | 234 } |
235 | 235 |
236 FX_BOOL CFFL_FormFiller::OnChar(CPDFSDK_Annot* pAnnot, | 236 FX_BOOL CFFL_FormFiller::OnChar(CPDFSDK_Annot* pAnnot, |
237 FX_UINT nChar, | 237 uint32_t nChar, |
238 FX_UINT nFlags) { | 238 uint32_t nFlags) { |
239 if (IsValid()) { | 239 if (IsValid()) { |
240 CPDFSDK_PageView* pPageView = GetCurPageView(true); | 240 CPDFSDK_PageView* pPageView = GetCurPageView(true); |
241 ASSERT(pPageView); | 241 ASSERT(pPageView); |
242 | 242 |
243 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE)) { | 243 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE)) { |
244 return pWnd->OnChar(nChar, nFlags); | 244 return pWnd->OnChar(nChar, nFlags); |
245 } | 245 } |
246 } | 246 } |
247 | 247 |
248 return FALSE; | 248 return FALSE; |
249 } | 249 } |
250 | 250 |
251 void CFFL_FormFiller::SetFocusForAnnot(CPDFSDK_Annot* pAnnot, FX_UINT nFlag) { | 251 void CFFL_FormFiller::SetFocusForAnnot(CPDFSDK_Annot* pAnnot, uint32_t nFlag) { |
252 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; | 252 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; |
253 UnderlyingPageType* pPage = pWidget->GetUnderlyingPage(); | 253 UnderlyingPageType* pPage = pWidget->GetUnderlyingPage(); |
254 CPDFSDK_Document* pDoc = m_pApp->GetSDKDocument(); | 254 CPDFSDK_Document* pDoc = m_pApp->GetSDKDocument(); |
255 CPDFSDK_PageView* pPageView = pDoc->GetPageView(pPage, true); | 255 CPDFSDK_PageView* pPageView = pDoc->GetPageView(pPage, true); |
256 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, TRUE)) | 256 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, TRUE)) |
257 pWnd->SetFocus(); | 257 pWnd->SetFocus(); |
258 | 258 |
259 m_bValid = TRUE; | 259 m_bValid = TRUE; |
260 FX_RECT rcRect = GetViewBBox(pPageView, pAnnot); | 260 FX_RECT rcRect = GetViewBBox(pPageView, pAnnot); |
261 InvalidateRect(rcRect.left, rcRect.top, rcRect.right, rcRect.bottom); | 261 InvalidateRect(rcRect.left, rcRect.top, rcRect.right, rcRect.bottom); |
262 } | 262 } |
263 | 263 |
264 void CFFL_FormFiller::KillFocusForAnnot(CPDFSDK_Annot* pAnnot, FX_UINT nFlag) { | 264 void CFFL_FormFiller::KillFocusForAnnot(CPDFSDK_Annot* pAnnot, uint32_t nFlag) { |
265 if (!IsValid()) | 265 if (!IsValid()) |
266 return; | 266 return; |
267 | 267 |
268 CPDFSDK_PageView* pPageView = GetCurPageView(false); | 268 CPDFSDK_PageView* pPageView = GetCurPageView(false); |
269 if (!pPageView) | 269 if (!pPageView) |
270 return; | 270 return; |
271 | 271 |
272 CommitData(pPageView, nFlag); | 272 CommitData(pPageView, nFlag); |
273 | 273 |
274 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE)) | 274 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE)) |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
514 const CFX_FloatPoint& pt) { | 514 const CFX_FloatPoint& pt) { |
515 return FFLtoPWL(pt); | 515 return FFLtoPWL(pt); |
516 } | 516 } |
517 | 517 |
518 CFX_FloatRect CFFL_FormFiller::FFLtoWnd(CPDFSDK_PageView* pPageView, | 518 CFX_FloatRect CFFL_FormFiller::FFLtoWnd(CPDFSDK_PageView* pPageView, |
519 const CFX_FloatRect& rect) { | 519 const CFX_FloatRect& rect) { |
520 return rect; | 520 return rect; |
521 } | 521 } |
522 | 522 |
523 FX_BOOL CFFL_FormFiller::CommitData(CPDFSDK_PageView* pPageView, | 523 FX_BOOL CFFL_FormFiller::CommitData(CPDFSDK_PageView* pPageView, |
524 FX_UINT nFlag) { | 524 uint32_t nFlag) { |
525 if (IsDataChanged(pPageView)) { | 525 if (IsDataChanged(pPageView)) { |
526 FX_BOOL bRC = TRUE; | 526 FX_BOOL bRC = TRUE; |
527 FX_BOOL bExit = FALSE; | 527 FX_BOOL bExit = FALSE; |
528 CFFL_IFormFiller* pIFormFiller = m_pApp->GetIFormFiller(); | 528 CFFL_IFormFiller* pIFormFiller = m_pApp->GetIFormFiller(); |
529 pIFormFiller->OnKeyStrokeCommit(m_pWidget, pPageView, bRC, bExit, nFlag); | 529 pIFormFiller->OnKeyStrokeCommit(m_pWidget, pPageView, bRC, bExit, nFlag); |
530 if (bExit) | 530 if (bExit) |
531 return TRUE; | 531 return TRUE; |
532 if (!bRC) { | 532 if (!bRC) { |
533 ResetPDFWindow(pPageView, FALSE); | 533 ResetPDFWindow(pPageView, FALSE); |
534 return TRUE; | 534 return TRUE; |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
635 m_bMouseIn = FALSE; | 635 m_bMouseIn = FALSE; |
636 | 636 |
637 FX_RECT rect = GetViewBBox(pPageView, pAnnot); | 637 FX_RECT rect = GetViewBBox(pPageView, pAnnot); |
638 InvalidateRect(rect.left, rect.top, rect.right, rect.bottom); | 638 InvalidateRect(rect.left, rect.top, rect.right, rect.bottom); |
639 EndTimer(); | 639 EndTimer(); |
640 ASSERT(m_pWidget); | 640 ASSERT(m_pWidget); |
641 } | 641 } |
642 | 642 |
643 FX_BOOL CFFL_Button::OnLButtonDown(CPDFSDK_PageView* pPageView, | 643 FX_BOOL CFFL_Button::OnLButtonDown(CPDFSDK_PageView* pPageView, |
644 CPDFSDK_Annot* pAnnot, | 644 CPDFSDK_Annot* pAnnot, |
645 FX_UINT nFlags, | 645 uint32_t nFlags, |
646 const CFX_FloatPoint& point) { | 646 const CFX_FloatPoint& point) { |
647 CFX_FloatRect rcAnnot = pAnnot->GetRect(); | 647 CFX_FloatRect rcAnnot = pAnnot->GetRect(); |
648 if (!rcAnnot.Contains(point.x, point.y)) | 648 if (!rcAnnot.Contains(point.x, point.y)) |
649 return FALSE; | 649 return FALSE; |
650 | 650 |
651 m_bMouseDown = TRUE; | 651 m_bMouseDown = TRUE; |
652 m_bValid = TRUE; | 652 m_bValid = TRUE; |
653 FX_RECT rect = GetViewBBox(pPageView, pAnnot); | 653 FX_RECT rect = GetViewBBox(pPageView, pAnnot); |
654 InvalidateRect(rect.left, rect.top, rect.right, rect.bottom); | 654 InvalidateRect(rect.left, rect.top, rect.right, rect.bottom); |
655 return TRUE; | 655 return TRUE; |
656 } | 656 } |
657 | 657 |
658 FX_BOOL CFFL_Button::OnLButtonUp(CPDFSDK_PageView* pPageView, | 658 FX_BOOL CFFL_Button::OnLButtonUp(CPDFSDK_PageView* pPageView, |
659 CPDFSDK_Annot* pAnnot, | 659 CPDFSDK_Annot* pAnnot, |
660 FX_UINT nFlags, | 660 uint32_t nFlags, |
661 const CFX_FloatPoint& point) { | 661 const CFX_FloatPoint& point) { |
662 CFX_FloatRect rcAnnot = pAnnot->GetRect(); | 662 CFX_FloatRect rcAnnot = pAnnot->GetRect(); |
663 if (!rcAnnot.Contains(point.x, point.y)) | 663 if (!rcAnnot.Contains(point.x, point.y)) |
664 return FALSE; | 664 return FALSE; |
665 | 665 |
666 m_bMouseDown = FALSE; | 666 m_bMouseDown = FALSE; |
667 m_pWidget->GetPDFPage(); | 667 m_pWidget->GetPDFPage(); |
668 | 668 |
669 FX_RECT rect = GetViewBBox(pPageView, pAnnot); | 669 FX_RECT rect = GetViewBBox(pPageView, pAnnot); |
670 InvalidateRect(rect.left, rect.top, rect.right, rect.bottom); | 670 InvalidateRect(rect.left, rect.top, rect.right, rect.bottom); |
671 return TRUE; | 671 return TRUE; |
672 } | 672 } |
673 | 673 |
674 FX_BOOL CFFL_Button::OnMouseMove(CPDFSDK_PageView* pPageView, | 674 FX_BOOL CFFL_Button::OnMouseMove(CPDFSDK_PageView* pPageView, |
675 CPDFSDK_Annot* pAnnot, | 675 CPDFSDK_Annot* pAnnot, |
676 FX_UINT nFlags, | 676 uint32_t nFlags, |
677 const CFX_FloatPoint& point) { | 677 const CFX_FloatPoint& point) { |
678 ASSERT(m_pApp); | 678 ASSERT(m_pApp); |
679 | 679 |
680 return TRUE; | 680 return TRUE; |
681 } | 681 } |
682 | 682 |
683 void CFFL_Button::OnDraw(CPDFSDK_PageView* pPageView, | 683 void CFFL_Button::OnDraw(CPDFSDK_PageView* pPageView, |
684 CPDFSDK_Annot* pAnnot, | 684 CPDFSDK_Annot* pAnnot, |
685 CFX_RenderDevice* pDevice, | 685 CFX_RenderDevice* pDevice, |
686 CFX_Matrix* pUser2Device) { | 686 CFX_Matrix* pUser2Device) { |
(...skipping 24 matching lines...) Expand all Loading... |
711 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, nullptr); | 711 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, nullptr); |
712 } | 712 } |
713 } | 713 } |
714 | 714 |
715 void CFFL_Button::OnDrawDeactive(CPDFSDK_PageView* pPageView, | 715 void CFFL_Button::OnDrawDeactive(CPDFSDK_PageView* pPageView, |
716 CPDFSDK_Annot* pAnnot, | 716 CPDFSDK_Annot* pAnnot, |
717 CFX_RenderDevice* pDevice, | 717 CFX_RenderDevice* pDevice, |
718 CFX_Matrix* pUser2Device) { | 718 CFX_Matrix* pUser2Device) { |
719 OnDraw(pPageView, pAnnot, pDevice, pUser2Device); | 719 OnDraw(pPageView, pAnnot, pDevice, pUser2Device); |
720 } | 720 } |
OLD | NEW |