Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
cffl_radiobutton.cpp
Go to the documentation of this file.
1
// Copyright 2014 The PDFium Authors
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/formfiller/cffl_radiobutton.h"
8
9
#
include
<
utility
>
10
11
#
include
"constants/ascii.h"
12
#
include
"core/fpdfdoc/cpdf_formcontrol.h"
13
#
include
"core/fxcrt/check.h"
14
#
include
"fpdfsdk/cpdfsdk_widget.h"
15
#
include
"fpdfsdk/formfiller/cffl_formfield.h"
16
#
include
"fpdfsdk/pwl/cpwl_special_button.h"
17
#
include
"public/fpdf_fwlevent.h"
18
19
CFFL_RadioButton::
CFFL_RadioButton
(CFFL_InteractiveFormFiller* pFormFiller,
20
CPDFSDK_Widget* pWidget)
21
:
CFFL_Button
(
pFormFiller
,
pWidget
)
{}
22
23
CFFL_RadioButton::~
CFFL_RadioButton
() =
default
;
24
25
std
::
unique_ptr
<
CPWL_Wnd
> CFFL_RadioButton::
NewPWLWindow
(
26
const
CPWL_Wnd
::
CreateParams
& cp,
27
std::unique_ptr<IPWL_FillerNotify::PerWindowData> pAttachedData) {
28
auto
pWnd =
std
::make_unique<CPWL_RadioButton>(cp,
std
::move(pAttachedData));
29
pWnd->Realize();
30
pWnd->SetCheck(m_pWidget->IsChecked());
31
return
pWnd;
32
}
33
34
bool
CFFL_RadioButton::
OnKeyDown
(FWL_VKEYCODE nKeyCode,
35
Mask
<FWL_EVENTFLAG> nFlags) {
36
switch
(nKeyCode) {
37
case
FWL_VKEY_Return
:
38
case
FWL_VKEY_Space
:
39
return
true
;
40
default
:
41
return
CFFL_FormField
::
OnKeyDown
(
nKeyCode
,
nFlags
)
;
42
}
43
}
44
45
bool
CFFL_RadioButton::
OnChar
(CPDFSDK_Widget* pWidget,
46
uint32_t nChar,
47
Mask
<FWL_EVENTFLAG> nFlags) {
48
switch
(nChar) {
49
case
pdfium
::
ascii
::
kReturn
:
50
case
pdfium
::
ascii
::
kSpace
: {
51
CPDFSDK_PageView* pPageView = pWidget
->
GetPageView
();
52
DCHECK
(pPageView);
53
54
ObservedPtr<CPDFSDK_Widget> pObserved(m_pWidget);
55
if
(m_pFormFiller->OnButtonUp(pObserved, pPageView, nFlags) ||
56
!pObserved) {
57
return
true
;
58
}
59
60
CFFL_FormField
::
OnChar
(
pWidget
,
nChar
,
nFlags
)
;
61
CPWL_RadioButton* pWnd = CreateOrUpdatePWLRadioButton(pPageView);
62
if
(pWnd && !pWnd
->
IsReadOnly
())
63
pWnd
->
SetCheck
(
true
)
;
64
return
CommitData
(
pPageView
,
nFlags
)
;
65
}
66
default
:
67
return
CFFL_FormField
::
OnChar
(
pWidget
,
nChar
,
nFlags
)
;
68
}
69
}
70
71
bool
CFFL_RadioButton::
OnLButtonUp
(CPDFSDK_PageView* pPageView,
72
CPDFSDK_Widget* pWidget,
73
Mask
<FWL_EVENTFLAG> nFlags,
74
const
CFX_PointF
& point) {
75
CFFL_Button
::
OnLButtonUp
(
pPageView
,
pWidget
,
nFlags
,
point
)
;
76
77
if
(!
IsValid
())
78
return
true
;
79
80
CPWL_RadioButton* pWnd = CreateOrUpdatePWLRadioButton(pPageView);
81
if
(pWnd)
82
pWnd
->
SetCheck
(
true
)
;
83
84
return
CommitData
(
pPageView
,
nFlags
)
;
85
}
86
87
bool
CFFL_RadioButton::
IsDataChanged
(
const
CPDFSDK_PageView* pPageView) {
88
CPWL_RadioButton* pWnd = GetPWLRadioButton(pPageView);
89
return
pWnd && pWnd
->
IsChecked
(
)
!= m_pWidget->IsChecked();
90
}
91
92
void
CFFL_RadioButton::
SaveData
(
const
CPDFSDK_PageView* pPageView) {
93
ObservedPtr<CFFL_RadioButton> observed_this(
this
);
94
CPWL_RadioButton* pWnd = observed_this->GetPWLRadioButton(pPageView);
95
if
(!pWnd) {
96
return
;
97
}
98
bool
bNewChecked = pWnd
->
IsChecked
(
)
;
99
ObservedPtr<CPDFSDK_Widget> observed_widget(observed_this->m_pWidget);
100
observed_widget->SetCheck(bNewChecked);
101
if
(!observed_widget) {
102
return
;
103
}
104
observed_widget->UpdateField();
105
if
(!observed_widget || !observed_this) {
106
return
;
107
}
108
observed_this->SetChangeMark();
109
}
110
111
CPWL_RadioButton* CFFL_RadioButton::GetPWLRadioButton(
112
const
CPDFSDK_PageView* pPageView)
const
{
113
return
static_cast
<CPWL_RadioButton*>(
GetPWLWindow
(pPageView));
114
}
115
116
CPWL_RadioButton* CFFL_RadioButton::CreateOrUpdatePWLRadioButton(
117
const
CPDFSDK_PageView* pPageView) {
118
return
static_cast
<CPWL_RadioButton*>(
CreateOrUpdatePWLWindow
(pPageView));
119
}
DCHECK
#define DCHECK
Definition
check.h:33
CFFL_Button
Definition
cffl_button.h:18
CFFL_Button::CFFL_Button
CFFL_Button(CFFL_InteractiveFormFiller *pFormFiller, CPDFSDK_Widget *pWidget)
Definition
cffl_button.cpp:12
CFFL_Button::OnLButtonUp
bool OnLButtonUp(CPDFSDK_PageView *pPageView, CPDFSDK_Widget *pWidget, Mask< FWL_EVENTFLAG > nFlags, const CFX_PointF &point) override
Definition
cffl_button.cpp:43
CFFL_FormField
Definition
cffl_formfield.h:27
CFFL_FormField::OnChar
virtual bool OnChar(CPDFSDK_Widget *pAnnot, uint32_t nChar, Mask< FWL_EVENTFLAG > nFlags)
Definition
cffl_formfield.cpp:172
CFFL_FormField::GetPWLWindow
CPWL_Wnd * GetPWLWindow(const CPDFSDK_PageView *pPageView) const
Definition
cffl_formfield.cpp:356
CFFL_FormField::CreateOrUpdatePWLWindow
CPWL_Wnd * CreateOrUpdatePWLWindow(const CPDFSDK_PageView *pPageView)
Definition
cffl_formfield.cpp:363
CFFL_FormField::CommitData
bool CommitData(const CPDFSDK_PageView *pPageView, Mask< FWL_EVENTFLAG > nFlag)
Definition
cffl_formfield.cpp:474
CFFL_FormField::OnKeyDown
virtual bool OnKeyDown(FWL_VKEYCODE nKeyCode, Mask< FWL_EVENTFLAG > nFlags)
Definition
cffl_formfield.cpp:163
CFFL_FormField::IsValid
bool IsValid() const
Definition
cffl_formfield.cpp:305
CFFL_RadioButton::~CFFL_RadioButton
~CFFL_RadioButton() override
CFFL_RadioButton::SaveData
void SaveData(const CPDFSDK_PageView *pPageView) override
Definition
cffl_radiobutton.cpp:92
CFFL_RadioButton::CFFL_RadioButton
CFFL_RadioButton(CFFL_InteractiveFormFiller *pFormFiller, CPDFSDK_Widget *pWidget)
Definition
cffl_radiobutton.cpp:19
CFFL_RadioButton::IsDataChanged
bool IsDataChanged(const CPDFSDK_PageView *pPageView) override
Definition
cffl_radiobutton.cpp:87
CFFL_RadioButton::NewPWLWindow
std::unique_ptr< CPWL_Wnd > NewPWLWindow(const CPWL_Wnd::CreateParams &cp, std::unique_ptr< IPWL_FillerNotify::PerWindowData > pAttachedData) override
Definition
cffl_radiobutton.cpp:25
CFFL_RadioButton::OnLButtonUp
bool OnLButtonUp(CPDFSDK_PageView *pPageView, CPDFSDK_Widget *pWidget, Mask< FWL_EVENTFLAG > nFlags, const CFX_PointF &point) override
Definition
cffl_radiobutton.cpp:71
CFFL_RadioButton::OnKeyDown
bool OnKeyDown(FWL_VKEYCODE nKeyCode, Mask< FWL_EVENTFLAG > nFlags) override
Definition
cffl_radiobutton.cpp:34
CFFL_RadioButton::OnChar
bool OnChar(CPDFSDK_Widget *pWidget, uint32_t nChar, Mask< FWL_EVENTFLAG > nFlags) override
Definition
cffl_radiobutton.cpp:45
CPDFSDK_Annot::GetPageView
CPDFSDK_PageView * GetPageView() const
Definition
cpdfsdk_annot.h:129
CPWL_RadioButton::SetCheck
void SetCheck(bool bCheck)
Definition
cpwl_special_button.h:55
CPWL_RadioButton::IsChecked
bool IsChecked() const
Definition
cpwl_special_button.h:54
CPWL_Wnd::CreateParams
Definition
cpwl_wnd.h:96
CPWL_Wnd
Definition
cpwl_wnd.h:77
CPWL_Wnd::IsReadOnly
bool IsReadOnly() const
Definition
cpwl_wnd.cpp:610
fxcrt::Mask
Definition
mask.h:15
pdfium::CFDETextOutLargeBitmapTest
Definition
cfde_textout_unittest.cpp:117
FWL_VKEY_Space
@ FWL_VKEY_Space
Definition
fpdf_fwlevent.h:53
FWL_VKEY_Return
@ FWL_VKEY_Return
Definition
fpdf_fwlevent.h:36
CFX_PointF
CFX_PTemplate< float > CFX_PointF
Definition
fx_coordinates.h:51
pdfium::ascii
Definition
ascii.h:11
pdfium::ascii::kReturn
constexpr uint8_t kReturn
Definition
ascii.h:20
pdfium::ascii::kSpace
constexpr uint8_t kSpace
Definition
ascii.h:25
std
[33]
Definition
src_corelib_tools_qhash.cpp:421
qtwebengine
src
3rdparty
chromium
third_party
pdfium
fpdfsdk
formfiller
cffl_radiobutton.cpp
Generated on
for Qt by
1.18.0