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_checkbox.h" | 7 #include "fpdfsdk/formfiller/cffl_checkbox.h" |
8 | 8 |
9 #include "fpdfsdk/formfiller/cffl_formfiller.h" | 9 #include "fpdfsdk/formfiller/cffl_formfiller.h" |
10 #include "fpdfsdk/include/cpdfsdk_environment.h" | 10 #include "fpdfsdk/include/cpdfsdk_environment.h" |
11 #include "fpdfsdk/include/cpdfsdk_widget.h" | 11 #include "fpdfsdk/include/cpdfsdk_widget.h" |
12 #include "fpdfsdk/pdfwindow/PWL_SpecialButton.h" | 12 #include "fpdfsdk/pdfwindow/PWL_SpecialButton.h" |
13 #include "public/fpdf_fwlevent.h" | 13 #include "public/fpdf_fwlevent.h" |
14 | 14 |
15 CFFL_CheckBox::CFFL_CheckBox(CPDFSDK_Environment* pApp, CPDFSDK_Widget* pWidget) | 15 CFFL_CheckBox::CFFL_CheckBox(CPDFSDK_Environment* pApp, CPDFSDK_Widget* pWidget) |
16 : CFFL_Button(pApp, pWidget) {} | 16 : CFFL_Button(pApp, pWidget) {} |
17 | 17 |
18 CFFL_CheckBox::~CFFL_CheckBox() {} | 18 CFFL_CheckBox::~CFFL_CheckBox() {} |
19 | 19 |
20 CPWL_Wnd* CFFL_CheckBox::NewPDFWindow(const PWL_CREATEPARAM& cp, | 20 CPWL_Wnd* CFFL_CheckBox::NewPDFWindow(const PWL_CREATEPARAM& cp, |
21 CPDFSDK_PageView* pPageView) { | 21 CPDFSDK_PageView* pPageView) { |
22 CPWL_CheckBox* pWnd = new CPWL_CheckBox(); | 22 CPWL_CheckBox* pWnd = new CPWL_CheckBox(); |
23 pWnd->Create(cp); | 23 pWnd->Create(cp); |
24 pWnd->SetCheck(m_pWidget->IsChecked()); | 24 pWnd->SetCheck(m_pWidget->IsChecked()); |
25 return pWnd; | 25 return pWnd; |
26 } | 26 } |
27 | 27 |
28 FX_BOOL CFFL_CheckBox::OnKeyDown(CPDFSDK_Annot* pAnnot, | 28 FX_BOOL CFFL_CheckBox::OnKeyDown(CPDFSDK_Annot* pAnnot, |
29 FX_UINT nKeyCode, | 29 uint32_t nKeyCode, |
30 FX_UINT nFlags) { | 30 uint32_t nFlags) { |
31 switch (nKeyCode) { | 31 switch (nKeyCode) { |
32 case FWL_VKEY_Return: | 32 case FWL_VKEY_Return: |
33 case FWL_VKEY_Space: | 33 case FWL_VKEY_Space: |
34 return TRUE; | 34 return TRUE; |
35 default: | 35 default: |
36 return CFFL_FormFiller::OnKeyDown(pAnnot, nKeyCode, nFlags); | 36 return CFFL_FormFiller::OnKeyDown(pAnnot, nKeyCode, nFlags); |
37 } | 37 } |
38 } | 38 } |
39 FX_BOOL CFFL_CheckBox::OnChar(CPDFSDK_Annot* pAnnot, | 39 FX_BOOL CFFL_CheckBox::OnChar(CPDFSDK_Annot* pAnnot, |
40 FX_UINT nChar, | 40 uint32_t nChar, |
41 FX_UINT nFlags) { | 41 uint32_t nFlags) { |
42 switch (nChar) { | 42 switch (nChar) { |
43 case FWL_VKEY_Return: | 43 case FWL_VKEY_Return: |
44 case FWL_VKEY_Space: { | 44 case FWL_VKEY_Space: { |
45 CFFL_IFormFiller* pIFormFiller = m_pApp->GetIFormFiller(); | 45 CFFL_IFormFiller* pIFormFiller = m_pApp->GetIFormFiller(); |
46 ASSERT(pIFormFiller); | 46 ASSERT(pIFormFiller); |
47 | 47 |
48 CPDFSDK_PageView* pPageView = pAnnot->GetPageView(); | 48 CPDFSDK_PageView* pPageView = pAnnot->GetPageView(); |
49 ASSERT(pPageView); | 49 ASSERT(pPageView); |
50 | 50 |
51 FX_BOOL bReset = FALSE; | 51 FX_BOOL bReset = FALSE; |
(...skipping 14 matching lines...) Expand all Loading... |
66 CommitData(pPageView, nFlags); | 66 CommitData(pPageView, nFlags); |
67 return TRUE; | 67 return TRUE; |
68 } | 68 } |
69 default: | 69 default: |
70 return CFFL_FormFiller::OnChar(pAnnot, nChar, nFlags); | 70 return CFFL_FormFiller::OnChar(pAnnot, nChar, nFlags); |
71 } | 71 } |
72 } | 72 } |
73 | 73 |
74 FX_BOOL CFFL_CheckBox::OnLButtonUp(CPDFSDK_PageView* pPageView, | 74 FX_BOOL CFFL_CheckBox::OnLButtonUp(CPDFSDK_PageView* pPageView, |
75 CPDFSDK_Annot* pAnnot, | 75 CPDFSDK_Annot* pAnnot, |
76 FX_UINT nFlags, | 76 uint32_t nFlags, |
77 const CFX_FloatPoint& point) { | 77 const CFX_FloatPoint& point) { |
78 CFFL_Button::OnLButtonUp(pPageView, pAnnot, nFlags, point); | 78 CFFL_Button::OnLButtonUp(pPageView, pAnnot, nFlags, point); |
79 | 79 |
80 if (IsValid()) { | 80 if (IsValid()) { |
81 if (CPWL_CheckBox* pWnd = (CPWL_CheckBox*)GetPDFWindow(pPageView, TRUE)) { | 81 if (CPWL_CheckBox* pWnd = (CPWL_CheckBox*)GetPDFWindow(pPageView, TRUE)) { |
82 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; | 82 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; |
83 pWnd->SetCheck(!pWidget->IsChecked()); | 83 pWnd->SetCheck(!pWidget->IsChecked()); |
84 } | 84 } |
85 | 85 |
86 if (!CommitData(pPageView, nFlags)) | 86 if (!CommitData(pPageView, nFlags)) |
(...skipping 21 matching lines...) Expand all Loading... |
108 } | 108 } |
109 } | 109 } |
110 } | 110 } |
111 } | 111 } |
112 | 112 |
113 m_pWidget->SetCheck(bNewChecked, false); | 113 m_pWidget->SetCheck(bNewChecked, false); |
114 m_pWidget->UpdateField(); | 114 m_pWidget->UpdateField(); |
115 SetChangeMark(); | 115 SetChangeMark(); |
116 } | 116 } |
117 } | 117 } |
OLD | NEW |