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

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

Issue 1799773002: Move fpdfsdk/src up to fpdfsdk/. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Rebase to master Created 4 years, 9 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
« no previous file with comments | « fpdfsdk/src/formfiller/FFL_PushButton.cpp ('k') | fpdfsdk/src/formfiller/FFL_TextField.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7 #include "fpdfsdk/include/formfiller/FFL_RadioButton.h"
8
9 #include "fpdfsdk/include/formfiller/FFL_FormFiller.h"
10 #include "fpdfsdk/include/fsdk_mgr.h"
11 #include "fpdfsdk/include/pdfwindow/PWL_SpecialButton.h"
12
13 CFFL_RadioButton::CFFL_RadioButton(CPDFDoc_Environment* pApp,
14 CPDFSDK_Annot* pWidget)
15 : CFFL_Button(pApp, pWidget) {}
16
17 CFFL_RadioButton::~CFFL_RadioButton() {}
18
19 CPWL_Wnd* CFFL_RadioButton::NewPDFWindow(const PWL_CREATEPARAM& cp,
20 CPDFSDK_PageView* pPageView) {
21 CPWL_RadioButton* pWnd = new CPWL_RadioButton();
22 pWnd->Create(cp);
23
24 pWnd->SetCheck(m_pWidget->IsChecked());
25
26 return pWnd;
27 }
28
29 FX_BOOL CFFL_RadioButton::OnKeyDown(CPDFSDK_Annot* pAnnot,
30 FX_UINT nKeyCode,
31 FX_UINT nFlags) {
32 switch (nKeyCode) {
33 case FWL_VKEY_Return:
34 case FWL_VKEY_Space:
35 return TRUE;
36 default:
37 return CFFL_FormFiller::OnKeyDown(pAnnot, nKeyCode, nFlags);
38 }
39 }
40
41 FX_BOOL CFFL_RadioButton::OnChar(CPDFSDK_Annot* pAnnot,
42 FX_UINT nChar,
43 FX_UINT nFlags) {
44 switch (nChar) {
45 case FWL_VKEY_Return:
46 case FWL_VKEY_Space: {
47 CFFL_IFormFiller* pIFormFiller = m_pApp->GetIFormFiller();
48 CPDFSDK_PageView* pPageView = pAnnot->GetPageView();
49 ASSERT(pPageView);
50
51 FX_BOOL bReset = FALSE;
52 FX_BOOL bExit = FALSE;
53
54 pIFormFiller->OnButtonUp(m_pWidget, pPageView, bReset, bExit, nFlags);
55
56 if (bReset)
57 return TRUE;
58 if (bExit)
59 return TRUE;
60
61 CFFL_FormFiller::OnChar(pAnnot, nChar, nFlags);
62
63 if (CPWL_RadioButton* pWnd =
64 (CPWL_RadioButton*)GetPDFWindow(pPageView, TRUE))
65 pWnd->SetCheck(TRUE);
66 CommitData(pPageView, nFlags);
67 return TRUE;
68 }
69 default:
70 return CFFL_FormFiller::OnChar(pAnnot, nChar, nFlags);
71 }
72 }
73
74 FX_BOOL CFFL_RadioButton::OnLButtonUp(CPDFSDK_PageView* pPageView,
75 CPDFSDK_Annot* pAnnot,
76 FX_UINT nFlags,
77 const CFX_FloatPoint& point) {
78 CFFL_Button::OnLButtonUp(pPageView, pAnnot, nFlags, point);
79
80 if (IsValid()) {
81 if (CPWL_RadioButton* pWnd =
82 (CPWL_RadioButton*)GetPDFWindow(pPageView, TRUE))
83 pWnd->SetCheck(TRUE);
84
85 if (!CommitData(pPageView, nFlags))
86 return FALSE;
87 }
88
89 return TRUE;
90 }
91
92 FX_BOOL CFFL_RadioButton::IsDataChanged(CPDFSDK_PageView* pPageView) {
93 if (CPWL_RadioButton* pWnd =
94 (CPWL_RadioButton*)GetPDFWindow(pPageView, FALSE)) {
95 return pWnd->IsChecked() != m_pWidget->IsChecked();
96 }
97
98 return FALSE;
99 }
100
101 void CFFL_RadioButton::SaveData(CPDFSDK_PageView* pPageView) {
102 if (CPWL_RadioButton* pWnd =
103 (CPWL_RadioButton*)GetPDFWindow(pPageView, FALSE)) {
104 bool bNewChecked = pWnd->IsChecked();
105
106 if (bNewChecked) {
107 CPDF_FormField* pField = m_pWidget->GetFormField();
108 for (int32_t i = 0, sz = pField->CountControls(); i < sz; i++) {
109 if (CPDF_FormControl* pCtrl = pField->GetControl(i)) {
110 if (pCtrl->IsChecked()) {
111 break;
112 }
113 }
114 }
115 }
116
117 m_pWidget->SetCheck(bNewChecked, false);
118 m_pWidget->UpdateField();
119 SetChangeMark();
120 }
121 }
OLDNEW
« no previous file with comments | « fpdfsdk/src/formfiller/FFL_PushButton.cpp ('k') | fpdfsdk/src/formfiller/FFL_TextField.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698