Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(355)

Side by Side Diff: fpdfsdk/src/formfiller/FFL_RadioButton.cpp

Issue 1265503005: clang-format all pdfium code. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: sigh Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_RadioButton.h" 9 #include "../../include/formfiller/FFL_RadioButton.h"
10 //#include "../include/FFL_Undo.h" 10 //#include "../include/FFL_Undo.h"
11 11
12 /* ------------------------------- CFFL_RadioButton ---------------------------- --- */ 12 /* ------------------------------- CFFL_RadioButton
13 * ------------------------------- */
13 14
14 CFFL_RadioButton::CFFL_RadioButton(CPDFDoc_Environment* pApp, CPDFSDK_Annot* pWi dget) : 15 CFFL_RadioButton::CFFL_RadioButton(CPDFDoc_Environment* pApp,
15 » CFFL_Button(pApp, pWidget) 16 CPDFSDK_Annot* pWidget)
16 { 17 : CFFL_Button(pApp, pWidget) {}
18
19 CFFL_RadioButton::~CFFL_RadioButton() {}
20
21 CPWL_Wnd* CFFL_RadioButton::NewPDFWindow(const PWL_CREATEPARAM& cp,
22 CPDFSDK_PageView* pPageView) {
23 CPWL_RadioButton* pWnd = new CPWL_RadioButton();
24 pWnd->Create(cp);
25
26 ASSERT(m_pWidget != NULL);
27 pWnd->SetCheck(m_pWidget->IsChecked());
28
29 return pWnd;
17 } 30 }
18 31
19 CFFL_RadioButton::~CFFL_RadioButton() 32 FX_BOOL CFFL_RadioButton::OnKeyDown(CPDFSDK_Annot* pAnnot,
20 { 33 FX_UINT nKeyCode,
34 FX_UINT nFlags) {
35 switch (nKeyCode) {
36 case FWL_VKEY_Return:
37 case FWL_VKEY_Space:
38 return TRUE;
39 default:
40 return CFFL_FormFiller::OnKeyDown(pAnnot, nKeyCode, nFlags);
41 }
21 } 42 }
22 43
23 CPWL_Wnd* CFFL_RadioButton::NewPDFWindow(const PWL_CREATEPARAM& cp, CPDFSDK_Page View* pPageView) 44 FX_BOOL CFFL_RadioButton::OnChar(CPDFSDK_Annot* pAnnot,
24 { 45 FX_UINT nChar,
25 » CPWL_RadioButton* pWnd = new CPWL_RadioButton(); 46 FX_UINT nFlags) {
26 » pWnd->Create(cp); 47 switch (nChar) {
48 case FWL_VKEY_Return:
49 case FWL_VKEY_Space: {
50 CFFL_IFormFiller* pIFormFiller = m_pApp->GetIFormFiller();
51 ASSERT(pIFormFiller != NULL);
27 52
28 » ASSERT(m_pWidget != NULL); 53 CPDFSDK_PageView* pPageView = pAnnot->GetPageView();
29 » pWnd->SetCheck(m_pWidget->IsChecked()); 54 ASSERT(pPageView != NULL);
30 55
31 » return pWnd; 56 FX_BOOL bReset = FALSE;
57 FX_BOOL bExit = FALSE;
58
59 pIFormFiller->OnButtonUp(m_pWidget, pPageView, bReset, bExit, nFlags);
60
61 if (bReset)
62 return TRUE;
63 if (bExit)
64 return TRUE;
65
66 CFFL_FormFiller::OnChar(pAnnot, nChar, nFlags);
67
68 if (CPWL_RadioButton* pWnd =
69 (CPWL_RadioButton*)GetPDFWindow(pPageView, TRUE))
70 pWnd->SetCheck(TRUE);
71 CommitData(pPageView, nFlags);
72 return TRUE;
73 }
74 default:
75 return CFFL_FormFiller::OnChar(pAnnot, nChar, nFlags);
76 }
32 } 77 }
33 78
34 FX_BOOL»CFFL_RadioButton::OnKeyDown(CPDFSDK_Annot* pAnnot, FX_UINT nKeyCode, FX_ UINT nFlags) 79 FX_BOOL CFFL_RadioButton::OnLButtonUp(CPDFSDK_PageView* pPageView,
35 { 80 CPDFSDK_Annot* pAnnot,
36 » switch (nKeyCode) 81 FX_UINT nFlags,
37 » { 82 const CPDF_Point& point) {
38 » case FWL_VKEY_Return: 83 CFFL_Button::OnLButtonUp(pPageView, pAnnot, nFlags, point);
39 » case FWL_VKEY_Space: 84
40 » » return TRUE; 85 if (IsValid()) {
41 » default: 86 if (CPWL_RadioButton* pWnd =
42 » » return CFFL_FormFiller::OnKeyDown(pAnnot, nKeyCode, nFlags); 87 (CPWL_RadioButton*)GetPDFWindow(pPageView, TRUE))
43 » } 88 pWnd->SetCheck(TRUE);
89
90 if (!CommitData(pPageView, nFlags))
91 return FALSE;
92 }
93
94 return TRUE;
44 } 95 }
45 96
46 FX_BOOL»CFFL_RadioButton::OnChar(CPDFSDK_Annot* pAnnot, FX_UINT nChar, FX_UINT n Flags) 97 FX_BOOL CFFL_RadioButton::IsDataChanged(CPDFSDK_PageView* pPageView) {
47 { 98 ASSERT(m_pWidget != NULL);
48 » switch (nChar)
49 » {
50 » case FWL_VKEY_Return:
51 » case FWL_VKEY_Space:
52 » » {
53 » » » CFFL_IFormFiller* pIFormFiller = m_pApp->GetIFormFiller( );
54 » » » ASSERT(pIFormFiller != NULL);
55 99
56 » » » CPDFSDK_PageView* pPageView = pAnnot->GetPageView(); 100 if (CPWL_RadioButton* pWnd =
57 » » » ASSERT(pPageView != NULL); 101 (CPWL_RadioButton*)GetPDFWindow(pPageView, FALSE)) {
102 return pWnd->IsChecked() != m_pWidget->IsChecked();
103 }
58 104
59 » » » FX_BOOL bReset = FALSE; 105 return FALSE;
60 » » » FX_BOOL bExit = FALSE;
61
62 » » » pIFormFiller->OnButtonUp(m_pWidget, pPageView, bReset, b Exit,nFlags);
63
64 » » » if (bReset) return TRUE;
65 » » » if (bExit) return TRUE;
66
67 » » » CFFL_FormFiller::OnChar(pAnnot, nChar, nFlags);
68
69 » » » if (CPWL_RadioButton * pWnd = (CPWL_RadioButton*)GetPDFW indow(pPageView, TRUE))
70 » » » » pWnd->SetCheck(TRUE);
71 » » » CommitData(pPageView,nFlags);
72 » » » return TRUE;
73 » » }
74 » default:
75 » » return CFFL_FormFiller::OnChar(pAnnot, nChar, nFlags);
76 » }
77 } 106 }
78 107
79 FX_BOOL»CFFL_RadioButton::OnLButtonUp(CPDFSDK_PageView *pPageView, CPDFSDK_Annot * pAnnot, FX_UINT nFlags, const CPDF_Point& point) 108 void CFFL_RadioButton::SaveData(CPDFSDK_PageView* pPageView) {
80 { 109 ASSERT(m_pWidget != NULL);
81 » CFFL_Button::OnLButtonUp(pPageView, pAnnot, nFlags, point);
82 110
83 » if (IsValid()) 111 if (CPWL_RadioButton* pWnd =
84 » { 112 (CPWL_RadioButton*)GetPDFWindow(pPageView, FALSE)) {
85 » » if (CPWL_RadioButton * pWnd = (CPWL_RadioButton*)GetPDFWindow(pP ageView, TRUE)) 113 FX_BOOL bNewChecked = pWnd->IsChecked();
86 » » » pWnd->SetCheck(TRUE);
87 114
88 » » if (!CommitData(pPageView,nFlags)) return FALSE; 115 if (bNewChecked) {
89 » } 116 CPDF_FormField* pField = m_pWidget->GetFormField();
117 ASSERT(pField != NULL);
90 118
91 » return TRUE; 119 for (int32_t i = 0, sz = pField->CountControls(); i < sz; i++) {
120 if (CPDF_FormControl* pCtrl = pField->GetControl(i)) {
121 if (pCtrl->IsChecked()) {
122 break;
123 }
124 }
125 }
126 }
127
128 m_pWidget->SetCheck(bNewChecked, FALSE);
129 m_pWidget->UpdateField();
130 SetChangeMark();
131 }
92 } 132 }
93
94 FX_BOOL CFFL_RadioButton::IsDataChanged(CPDFSDK_PageView* pPageView)
95 {
96 ASSERT(m_pWidget != NULL);
97
98 if (CPWL_RadioButton* pWnd = (CPWL_RadioButton*)GetPDFWindow(pPageView, FALSE))
99 {
100 return pWnd->IsChecked() != m_pWidget->IsChecked();
101 }
102
103 return FALSE;
104 }
105
106 void CFFL_RadioButton::SaveData(CPDFSDK_PageView* pPageView)
107 {
108 ASSERT(m_pWidget != NULL);
109
110 if (CPWL_RadioButton* pWnd = (CPWL_RadioButton*)GetPDFWindow(pPageView, FALSE))
111 {
112
113 FX_BOOL bNewChecked = pWnd->IsChecked();
114
115 if (bNewChecked)
116 {
117 CPDF_FormField* pField = m_pWidget->GetFormField();
118 ASSERT(pField != NULL);
119
120 for (int32_t i=0,sz=pField->CountControls(); i<sz; i++)
121 {
122 if (CPDF_FormControl* pCtrl = pField->GetControl (i))
123 {
124 if (pCtrl->IsChecked())
125 {
126 break;
127 }
128 }
129 }
130 }
131
132 m_pWidget->SetCheck(bNewChecked, FALSE);
133 m_pWidget->UpdateField();
134 SetChangeMark();
135 }
136 }
137
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698