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_checkbox.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_checkbox.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_CheckBox::
CFFL_CheckBox
(CFFL_InteractiveFormFiller* pFormFiller,
20
CPDFSDK_Widget* pWidget)
21
:
CFFL_Button
(
pFormFiller
,
pWidget
)
{}
22
23
CFFL_CheckBox::~
CFFL_CheckBox
() =
default
;
24
25
std
::
unique_ptr
<
CPWL_Wnd
> CFFL_CheckBox::
NewPWLWindow
(
26
const
CPWL_Wnd
::
CreateParams
& cp,
27
std::unique_ptr<IPWL_FillerNotify::PerWindowData> pAttachedData) {
28
auto
pWnd =
std
::make_unique<CPWL_CheckBox>(cp,
std
::move(pAttachedData));
29
pWnd->Realize();
30
pWnd->SetCheck(m_pWidget->IsChecked());
31
return
pWnd;
32
}
33
34
bool
CFFL_CheckBox::
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_CheckBox::
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
if
(!pObserved)
57
m_pWidget =
nullptr
;
58
return
true
;
59
}
60
if
(!pObserved) {
61
m_pWidget =
nullptr
;
62
return
true
;
63
}
64
65
CFFL_FormField
::
OnChar
(
pWidget
,
nChar
,
nFlags
)
;
66
67
CPWL_CheckBox* pWnd = CreateOrUpdatePWLCheckBox(pPageView);
68
if
(pWnd && !pWnd
->
IsReadOnly
()) {
69
ObservedPtr<CPWL_CheckBox> pObservedBox(pWnd);
70
const
bool
is_checked = pWidget
->
IsChecked
(
)
;
71
if
(pObservedBox) {
72
pObservedBox->SetCheck(!is_checked);
73
}
74
}
75
return
CommitData
(
pPageView
,
nFlags
)
;
76
}
77
default
:
78
return
CFFL_FormField
::
OnChar
(
pWidget
,
nChar
,
nFlags
)
;
79
}
80
}
81
82
bool
CFFL_CheckBox::
OnLButtonUp
(CPDFSDK_PageView* pPageView,
83
CPDFSDK_Widget* pWidget,
84
Mask
<FWL_EVENTFLAG> nFlags,
85
const
CFX_PointF
& point) {
86
CFFL_Button
::
OnLButtonUp
(
pPageView
,
pWidget
,
nFlags
,
point
)
;
87
if
(!
IsValid
()) {
88
return
true
;
89
}
90
ObservedPtr<CPWL_CheckBox> pWnd(CreateOrUpdatePWLCheckBox(pPageView));
91
if
(pWnd) {
92
// IsChecked() may invalidate check box.
93
const
bool
is_checked = pWidget
->
IsChecked
(
)
;
94
if
(pWnd) {
95
pWnd->SetCheck(!is_checked);
96
}
97
}
98
return
CommitData
(
pPageView
,
nFlags
)
;
99
}
100
101
bool
CFFL_CheckBox::
IsDataChanged
(
const
CPDFSDK_PageView* pPageView) {
102
CPWL_CheckBox* pWnd = GetPWLCheckBox(pPageView);
103
return
pWnd && pWnd
->
IsChecked
(
)
!= m_pWidget->IsChecked();
104
}
105
106
void
CFFL_CheckBox::
SaveData
(
const
CPDFSDK_PageView* pPageView) {
107
ObservedPtr<CFFL_CheckBox> observed_this(
this
);
108
CPWL_CheckBox* pWnd = observed_this->GetPWLCheckBox(pPageView);
109
if
(!pWnd) {
110
return
;
111
}
112
bool
bNewChecked = pWnd
->
IsChecked
(
)
;
113
ObservedPtr<CPDFSDK_Widget> observed_widget(m_pWidget);
114
observed_widget->SetCheck(bNewChecked);
115
if
(!observed_widget) {
116
return
;
117
}
118
observed_widget->UpdateField();
119
if
(!observed_widget || !observed_this) {
120
return
;
121
}
122
observed_this->SetChangeMark();
123
}
124
125
CPWL_CheckBox* CFFL_CheckBox::GetPWLCheckBox(
126
const
CPDFSDK_PageView* pPageView)
const
{
127
return
static_cast
<CPWL_CheckBox*>(
GetPWLWindow
(pPageView));
128
}
129
130
CPWL_CheckBox* CFFL_CheckBox::CreateOrUpdatePWLCheckBox(
131
const
CPDFSDK_PageView* pPageView) {
132
return
static_cast
<CPWL_CheckBox*>(
CreateOrUpdatePWLWindow
(pPageView));
133
}
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_CheckBox::~CFFL_CheckBox
~CFFL_CheckBox() override
CFFL_CheckBox::IsDataChanged
bool IsDataChanged(const CPDFSDK_PageView *pPageView) override
Definition
cffl_checkbox.cpp:101
CFFL_CheckBox::OnKeyDown
bool OnKeyDown(FWL_VKEYCODE nKeyCode, Mask< FWL_EVENTFLAG > nFlags) override
Definition
cffl_checkbox.cpp:34
CFFL_CheckBox::NewPWLWindow
std::unique_ptr< CPWL_Wnd > NewPWLWindow(const CPWL_Wnd::CreateParams &cp, std::unique_ptr< IPWL_FillerNotify::PerWindowData > pAttachedData) override
Definition
cffl_checkbox.cpp:25
CFFL_CheckBox::OnChar
bool OnChar(CPDFSDK_Widget *pWidget, uint32_t nChar, Mask< FWL_EVENTFLAG > nFlags) override
Definition
cffl_checkbox.cpp:45
CFFL_CheckBox::OnLButtonUp
bool OnLButtonUp(CPDFSDK_PageView *pPageView, CPDFSDK_Widget *pWidget, Mask< FWL_EVENTFLAG > nFlags, const CFX_PointF &point) override
Definition
cffl_checkbox.cpp:82
CFFL_CheckBox::SaveData
void SaveData(const CPDFSDK_PageView *pPageView) override
Definition
cffl_checkbox.cpp:106
CFFL_CheckBox::CFFL_CheckBox
CFFL_CheckBox(CFFL_InteractiveFormFiller *pFormFiller, CPDFSDK_Widget *pWidget)
Definition
cffl_checkbox.cpp:19
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
CPDFSDK_Annot::GetPageView
CPDFSDK_PageView * GetPageView() const
Definition
cpdfsdk_annot.h:129
CPDFSDK_Widget::IsChecked
bool IsChecked() const
Definition
cpdfsdk_widget.cpp:559
CPWL_CheckBox::IsChecked
bool IsChecked() const
Definition
cpwl_special_button.h:36
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_checkbox.cpp
Generated on
for Qt by
1.18.0