| 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 "../../include/formfiller/FormFiller.h" | 7 #include "../../include/formfiller/FormFiller.h" |
| 8 #include "../../include/formfiller/FFL_FormFiller.h" | 8 #include "../../include/formfiller/FFL_FormFiller.h" |
| 9 #include "../../include/formfiller/FFL_CheckBox.h" | 9 #include "../../include/formfiller/FFL_CheckBox.h" |
| 10 | 10 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 { | 24 { |
| 25 CPWL_CheckBox* pWnd = new CPWL_CheckBox(); | 25 CPWL_CheckBox* pWnd = new CPWL_CheckBox(); |
| 26 pWnd->Create(cp); | 26 pWnd->Create(cp); |
| 27 | 27 |
| 28 ASSERT(m_pWidget != NULL); | 28 ASSERT(m_pWidget != NULL); |
| 29 pWnd->SetCheck(m_pWidget->IsChecked()); | 29 pWnd->SetCheck(m_pWidget->IsChecked()); |
| 30 | 30 |
| 31 return pWnd; | 31 return pWnd; |
| 32 } | 32 } |
| 33 | 33 |
| 34 FX_BOOL»CFFL_CheckBox::OnKeyDown(CPDFSDK_Annot* pAnnot, FX_UINT nKeyCode, FX_UIN
T nFlags) | 34 bool» CFFL_CheckBox::OnKeyDown(CPDFSDK_Annot* pAnnot, FX_UINT nKeyCode, FX_UIN
T nFlags) |
| 35 { | 35 { |
| 36 switch (nKeyCode) | 36 switch (nKeyCode) |
| 37 { | 37 { |
| 38 case FWL_VKEY_Return: | 38 case FWL_VKEY_Return: |
| 39 case FWL_VKEY_Space: | 39 case FWL_VKEY_Space: |
| 40 » » return TRUE; | 40 » » return true; |
| 41 default: | 41 default: |
| 42 return CFFL_FormFiller::OnKeyDown(pAnnot, nKeyCode, nFlags); | 42 return CFFL_FormFiller::OnKeyDown(pAnnot, nKeyCode, nFlags); |
| 43 } | 43 } |
| 44 } | 44 } |
| 45 FX_BOOL»CFFL_CheckBox::OnChar(CPDFSDK_Annot* pAnnot, FX_UINT nChar, FX_UINT nFla
gs) | 45 bool» CFFL_CheckBox::OnChar(CPDFSDK_Annot* pAnnot, FX_UINT nChar, FX_UINT nFla
gs) |
| 46 { | 46 { |
| 47 switch (nChar) | 47 switch (nChar) |
| 48 { | 48 { |
| 49 case FWL_VKEY_Return: | 49 case FWL_VKEY_Return: |
| 50 case FWL_VKEY_Space: | 50 case FWL_VKEY_Space: |
| 51 { | 51 { |
| 52 CFFL_IFormFiller* pIFormFiller = m_pApp->GetIFormFiller(
); | 52 CFFL_IFormFiller* pIFormFiller = m_pApp->GetIFormFiller(
); |
| 53 ASSERT(pIFormFiller != NULL); | 53 ASSERT(pIFormFiller != NULL); |
| 54 | 54 |
| 55 CPDFSDK_PageView* pPageView = pAnnot->GetPageView(); | 55 CPDFSDK_PageView* pPageView = pAnnot->GetPageView(); |
| 56 ASSERT(pPageView != NULL); | 56 ASSERT(pPageView != NULL); |
| 57 | 57 |
| 58 » » » FX_BOOL bReset = FALSE; | 58 » » » bool bReset = false; |
| 59 » » » FX_BOOL bExit = FALSE; | 59 » » » bool bExit = false; |
| 60 | 60 |
| 61 pIFormFiller->OnButtonUp(m_pWidget, pPageView, bReset, b
Exit,nFlags); | 61 pIFormFiller->OnButtonUp(m_pWidget, pPageView, bReset, b
Exit,nFlags); |
| 62 | 62 |
| 63 » » » if (bReset) return TRUE; | 63 » » » if (bReset) return true; |
| 64 » » » if (bExit) return TRUE; | 64 » » » if (bExit) return true; |
| 65 | 65 |
| 66 CFFL_FormFiller::OnChar(pAnnot, nChar, nFlags); | 66 CFFL_FormFiller::OnChar(pAnnot, nChar, nFlags); |
| 67 | 67 |
| 68 » » » if (CPWL_CheckBox * pWnd = (CPWL_CheckBox*)GetPDFWindow(
pPageView, TRUE)) | 68 » » » if (CPWL_CheckBox * pWnd = (CPWL_CheckBox*)GetPDFWindow(
pPageView, true)) |
| 69 pWnd->SetCheck(!pWnd->IsChecked()); | 69 pWnd->SetCheck(!pWnd->IsChecked()); |
| 70 | 70 |
| 71 CommitData(pPageView,nFlags); | 71 CommitData(pPageView,nFlags); |
| 72 » » » return TRUE; | 72 » » » return true; |
| 73 } | 73 } |
| 74 default: | 74 default: |
| 75 return CFFL_FormFiller::OnChar(pAnnot, nChar, nFlags); | 75 return CFFL_FormFiller::OnChar(pAnnot, nChar, nFlags); |
| 76 } | 76 } |
| 77 } | 77 } |
| 78 | 78 |
| 79 FX_BOOL CFFL_CheckBox::OnLButtonUp(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* p
Annot, FX_UINT nFlags, const CPDF_Point& point) | 79 bool CFFL_CheckBox::OnLButtonUp(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnn
ot, FX_UINT nFlags, const CPDF_Point& point) |
| 80 { | 80 { |
| 81 CFFL_Button::OnLButtonUp(pPageView, pAnnot, nFlags, point); | 81 CFFL_Button::OnLButtonUp(pPageView, pAnnot, nFlags, point); |
| 82 | 82 |
| 83 if (IsValid()) | 83 if (IsValid()) |
| 84 { | 84 { |
| 85 » » if (CPWL_CheckBox * pWnd = (CPWL_CheckBox*)GetPDFWindow(pPageVie
w, TRUE)) | 85 » » if (CPWL_CheckBox * pWnd = (CPWL_CheckBox*)GetPDFWindow(pPageVie
w, true)) |
| 86 { | 86 { |
| 87 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; | 87 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; |
| 88 pWnd->SetCheck(!pWidget->IsChecked()); | 88 pWnd->SetCheck(!pWidget->IsChecked()); |
| 89 // pWnd->SetCheck(!pWnd->IsChecked()); | 89 // pWnd->SetCheck(!pWnd->IsChecked()); |
| 90 } | 90 } |
| 91 | 91 |
| 92 » » if (!CommitData(pPageView, nFlags)) return FALSE; | 92 » » if (!CommitData(pPageView, nFlags)) return false; |
| 93 } | 93 } |
| 94 | 94 |
| 95 » return TRUE; | 95 » return true; |
| 96 } | 96 } |
| 97 | 97 |
| 98 FX_BOOL»CFFL_CheckBox::IsDataChanged(CPDFSDK_PageView* pPageView) | 98 bool» CFFL_CheckBox::IsDataChanged(CPDFSDK_PageView* pPageView) |
| 99 { | 99 { |
| 100 | 100 |
| 101 ASSERT(m_pWidget != NULL); | 101 ASSERT(m_pWidget != NULL); |
| 102 | 102 |
| 103 » if (CPWL_CheckBox* pWnd = (CPWL_CheckBox*)GetPDFWindow(pPageView, FALSE)
) | 103 » if (CPWL_CheckBox* pWnd = (CPWL_CheckBox*)GetPDFWindow(pPageView, false)
) |
| 104 { | 104 { |
| 105 return pWnd->IsChecked() != m_pWidget->IsChecked(); | 105 return pWnd->IsChecked() != m_pWidget->IsChecked(); |
| 106 } | 106 } |
| 107 | 107 |
| 108 » return FALSE; | 108 » return false; |
| 109 } | 109 } |
| 110 | 110 |
| 111 void CFFL_CheckBox::SaveData(CPDFSDK_PageView* pPageView) | 111 void CFFL_CheckBox::SaveData(CPDFSDK_PageView* pPageView) |
| 112 { | 112 { |
| 113 | 113 |
| 114 ASSERT(m_pWidget != NULL); | 114 ASSERT(m_pWidget != NULL); |
| 115 | 115 |
| 116 » if (CPWL_CheckBox* pWnd = (CPWL_CheckBox*)GetPDFWindow(pPageView, FALSE)
) | 116 » if (CPWL_CheckBox* pWnd = (CPWL_CheckBox*)GetPDFWindow(pPageView, false)
) |
| 117 { | 117 { |
| 118 | 118 |
| 119 » » FX_BOOL bNewChecked = pWnd->IsChecked(); | 119 » » bool bNewChecked = pWnd->IsChecked(); |
| 120 | 120 |
| 121 | 121 |
| 122 if (bNewChecked) | 122 if (bNewChecked) |
| 123 { | 123 { |
| 124 CPDF_FormField* pField = m_pWidget->GetFormField(); | 124 CPDF_FormField* pField = m_pWidget->GetFormField(); |
| 125 ASSERT(pField != NULL); | 125 ASSERT(pField != NULL); |
| 126 | 126 |
| 127 for (int32_t i=0,sz=pField->CountControls(); i<sz; i++) | 127 for (int32_t i=0,sz=pField->CountControls(); i<sz; i++) |
| 128 { | 128 { |
| 129 if (CPDF_FormControl* pCtrl = pField->GetControl
(i)) | 129 if (CPDF_FormControl* pCtrl = pField->GetControl
(i)) |
| 130 { | 130 { |
| 131 if (pCtrl->IsChecked()) | 131 if (pCtrl->IsChecked()) |
| 132 { | 132 { |
| 133 break; | 133 break; |
| 134 } | 134 } |
| 135 } | 135 } |
| 136 } | 136 } |
| 137 } | 137 } |
| 138 | 138 |
| 139 » » m_pWidget->SetCheck(bNewChecked, FALSE); | 139 » » m_pWidget->SetCheck(bNewChecked, false); |
| 140 m_pWidget->UpdateField(); | 140 m_pWidget->UpdateField(); |
| 141 SetChangeMark(); | 141 SetChangeMark(); |
| 142 } | 142 } |
| 143 | 143 |
| 144 } | 144 } |
| OLD | NEW |