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