summaryrefslogtreecommitdiff
path: root/fpdfsdk/formfiller/FFL_RadioButton.cpp
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2016-03-14 13:51:24 -0400
committerDan Sinclair <dsinclair@chromium.org>2016-03-14 13:51:24 -0400
commitf766ad219f66543654520f6a1955836f519e26d1 (patch)
tree2edf8bc93b89503a3669f7add5b6c2a407b8a78c /fpdfsdk/formfiller/FFL_RadioButton.cpp
parent54b0abed08048008498471e39b7c72b034474090 (diff)
downloadpdfium-f766ad219f66543654520f6a1955836f519e26d1.tar.xz
Move fpdfsdk/src up to fpdfsdk/.
This CL moves the files in fpdfsdk/src/ up one level to fpdfsdk/ and fixes up the include paths, include guards and build files. R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1799773002 .
Diffstat (limited to 'fpdfsdk/formfiller/FFL_RadioButton.cpp')
-rw-r--r--fpdfsdk/formfiller/FFL_RadioButton.cpp121
1 files changed, 121 insertions, 0 deletions
diff --git a/fpdfsdk/formfiller/FFL_RadioButton.cpp b/fpdfsdk/formfiller/FFL_RadioButton.cpp
new file mode 100644
index 0000000000..029bcf1a17
--- /dev/null
+++ b/fpdfsdk/formfiller/FFL_RadioButton.cpp
@@ -0,0 +1,121 @@
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "fpdfsdk/include/formfiller/FFL_RadioButton.h"
+
+#include "fpdfsdk/include/formfiller/FFL_FormFiller.h"
+#include "fpdfsdk/include/fsdk_mgr.h"
+#include "fpdfsdk/include/pdfwindow/PWL_SpecialButton.h"
+
+CFFL_RadioButton::CFFL_RadioButton(CPDFDoc_Environment* pApp,
+ CPDFSDK_Annot* pWidget)
+ : CFFL_Button(pApp, pWidget) {}
+
+CFFL_RadioButton::~CFFL_RadioButton() {}
+
+CPWL_Wnd* CFFL_RadioButton::NewPDFWindow(const PWL_CREATEPARAM& cp,
+ CPDFSDK_PageView* pPageView) {
+ CPWL_RadioButton* pWnd = new CPWL_RadioButton();
+ pWnd->Create(cp);
+
+ pWnd->SetCheck(m_pWidget->IsChecked());
+
+ return pWnd;
+}
+
+FX_BOOL CFFL_RadioButton::OnKeyDown(CPDFSDK_Annot* pAnnot,
+ FX_UINT nKeyCode,
+ FX_UINT nFlags) {
+ switch (nKeyCode) {
+ case FWL_VKEY_Return:
+ case FWL_VKEY_Space:
+ return TRUE;
+ default:
+ return CFFL_FormFiller::OnKeyDown(pAnnot, nKeyCode, nFlags);
+ }
+}
+
+FX_BOOL CFFL_RadioButton::OnChar(CPDFSDK_Annot* pAnnot,
+ FX_UINT nChar,
+ FX_UINT nFlags) {
+ switch (nChar) {
+ case FWL_VKEY_Return:
+ case FWL_VKEY_Space: {
+ CFFL_IFormFiller* pIFormFiller = m_pApp->GetIFormFiller();
+ CPDFSDK_PageView* pPageView = pAnnot->GetPageView();
+ ASSERT(pPageView);
+
+ FX_BOOL bReset = FALSE;
+ FX_BOOL bExit = FALSE;
+
+ pIFormFiller->OnButtonUp(m_pWidget, pPageView, bReset, bExit, nFlags);
+
+ if (bReset)
+ return TRUE;
+ if (bExit)
+ return TRUE;
+
+ CFFL_FormFiller::OnChar(pAnnot, nChar, nFlags);
+
+ if (CPWL_RadioButton* pWnd =
+ (CPWL_RadioButton*)GetPDFWindow(pPageView, TRUE))
+ pWnd->SetCheck(TRUE);
+ CommitData(pPageView, nFlags);
+ return TRUE;
+ }
+ default:
+ return CFFL_FormFiller::OnChar(pAnnot, nChar, nFlags);
+ }
+}
+
+FX_BOOL CFFL_RadioButton::OnLButtonUp(CPDFSDK_PageView* pPageView,
+ CPDFSDK_Annot* pAnnot,
+ FX_UINT nFlags,
+ const CFX_FloatPoint& point) {
+ CFFL_Button::OnLButtonUp(pPageView, pAnnot, nFlags, point);
+
+ if (IsValid()) {
+ if (CPWL_RadioButton* pWnd =
+ (CPWL_RadioButton*)GetPDFWindow(pPageView, TRUE))
+ pWnd->SetCheck(TRUE);
+
+ if (!CommitData(pPageView, nFlags))
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+FX_BOOL CFFL_RadioButton::IsDataChanged(CPDFSDK_PageView* pPageView) {
+ if (CPWL_RadioButton* pWnd =
+ (CPWL_RadioButton*)GetPDFWindow(pPageView, FALSE)) {
+ return pWnd->IsChecked() != m_pWidget->IsChecked();
+ }
+
+ return FALSE;
+}
+
+void CFFL_RadioButton::SaveData(CPDFSDK_PageView* pPageView) {
+ if (CPWL_RadioButton* pWnd =
+ (CPWL_RadioButton*)GetPDFWindow(pPageView, FALSE)) {
+ bool bNewChecked = pWnd->IsChecked();
+
+ if (bNewChecked) {
+ CPDF_FormField* pField = m_pWidget->GetFormField();
+ for (int32_t i = 0, sz = pField->CountControls(); i < sz; i++) {
+ if (CPDF_FormControl* pCtrl = pField->GetControl(i)) {
+ if (pCtrl->IsChecked()) {
+ break;
+ }
+ }
+ }
+ }
+
+ m_pWidget->SetCheck(bNewChecked, false);
+ m_pWidget->UpdateField();
+ SetChangeMark();
+ }
+}