Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
cpdfsdk_widget.h
Go to the documentation of this file.
1// Copyright 2016 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#ifndef FPDFSDK_CPDFSDK_WIDGET_H_
8#define FPDFSDK_CPDFSDK_WIDGET_H_
9
10#include <optional>
11
12#include "core/fpdfdoc/cpdf_aaction.h"
13#include "core/fpdfdoc/cpdf_action.h"
14#include "core/fpdfdoc/cpdf_annot.h"
15#include "core/fpdfdoc/cpdf_formfield.h"
16#include "core/fxcrt/fx_coordinates.h"
17#include "core/fxcrt/unowned_ptr.h"
18#include "core/fxcrt/widestring.h"
19#include "core/fxge/cfx_color.h"
20#include "fpdfsdk/cpdfsdk_baannot.h"
21
22class CFFL_InteractiveFormFiller;
24class CPDF_Annot;
26class CPDF_FormField;
27class CPDFSDK_FormFillEnvironment;
28class CPDFSDK_InteractiveForm;
29class CPDFSDK_PageView;
30struct CFFL_FieldAction;
31
32#ifdef PDF_ENABLE_XFA
33class CXFA_FFWidget;
34class CXFA_FFWidgetHandler;
35
36enum PDFSDK_XFAAActionType {
37 PDFSDK_XFA_Click = 0,
38 PDFSDK_XFA_Full,
39 PDFSDK_XFA_PreOpen,
40 PDFSDK_XFA_PostOpen
41};
42#endif // PDF_ENABLE_XFA
43
44class CPDFSDK_Widget final : public CPDFSDK_BAAnnot {
45 public:
46 enum ValueChanged : bool { kValueUnchanged = false, kValueChanged = true };
47
49 CPDFSDK_PageView* pPageView,
50 CPDFSDK_InteractiveForm* pInteractiveForm);
51 ~CPDFSDK_Widget() override;
52
53 // CPDFSDK_BAAnnot:
54 void OnLoad() override;
56 bool IsAppearanceValid() override;
57 int GetLayoutOrder() const override;
58 void OnDraw(CFX_RenderDevice* pDevice,
59 const CFX_Matrix& mtUser2Device,
60 bool bDrawAnnots) override;
61 bool DoHitTest(const CFX_PointF& point) override;
62 CFX_FloatRect GetViewBBox() override;
63 bool CanUndo() override;
64 bool CanRedo() override;
65 bool Undo() override;
66 bool Redo() override;
67 WideString GetText() override;
68 WideString GetSelectedText() override;
69 void ReplaceAndKeepSelection(const WideString& text) override;
70 void ReplaceSelection(const WideString& text) override;
71 bool SelectAllText() override;
72 bool SetIndexSelected(int index, bool selected) override;
73 bool IsIndexSelected(int index) override;
74 void DrawAppearance(CFX_RenderDevice* pDevice,
75 const CFX_Matrix& mtUser2Device,
76 CPDF_Annot::AppearanceMode mode) override;
77
78 bool IsSignatureWidget() const;
79 void SetRect(const CFX_FloatRect& rect);
81 int GetFieldFlags() const;
82 int GetRotate() const;
83
84 std::optional<FX_COLORREF> GetFillColor() const;
85 std::optional<FX_COLORREF> GetBorderColor() const;
86 std::optional<FX_COLORREF> GetTextColor() const;
87 float GetFontSize() const;
88
89 int GetSelectedIndex(int nIndex) const;
90 WideString GetValue() const;
92 WideString GetOptionLabel(int nIndex) const;
93 WideString GetSelectExportText(int nIndex) const;
94
95 int CountOptions() const;
96 bool IsOptionSelected(int nIndex) const;
97 int GetTopVisibleIndex() const;
98 bool IsChecked() const;
99 int GetAlignment() const;
100 int GetMaxLen() const;
101
102 void SetCheck(bool bChecked);
103 void SetValue(const WideString& sValue);
104 void SetOptionSelection(int index);
105 void ClearSelection();
106 void SetTopVisibleIndex(int index);
107
108#ifdef PDF_ENABLE_XFA
109 CXFA_FFWidget* GetMixXFAWidget() const;
110 bool HasXFAAAction(PDFSDK_XFAAActionType eXFAAAT) const;
111 bool OnXFAAAction(PDFSDK_XFAAActionType eXFAAAT,
112 CFFL_FieldAction* data,
113 const CPDFSDK_PageView* pPageView);
114 void Synchronize(bool bSynchronizeElse);
115 // TODO(thestig): Figure out if the parameter should be used or removed.
116 void ResetXFAAppearance(ValueChanged bValueChanged);
117#endif // PDF_ENABLE_XFA
118
119 void ResetAppearance(std::optional<WideString> sValue,
120 ValueChanged bValueChanged);
122 void UpdateField();
123 std::optional<WideString> OnFormat();
124
126 CFFL_FieldAction* data,
127 const CPDFSDK_PageView* pPageView);
128
131
132 void DrawShadow(CFX_RenderDevice* pDevice, CPDFSDK_PageView* pPageView);
133
134 void SetAppModified();
135 void ClearAppModified();
136 bool IsAppModified() const;
137
138 uint32_t GetAppearanceAge() const { return m_nAppearanceAge; }
139 uint32_t GetValueAge() const { return m_nValueAge; }
140
142 bool IsPushHighlighted() const;
143 CFX_Matrix GetMatrix() const;
149
150 private:
151 // CPDFSDK_Annot::UnsafeInputHandlers:
152 void OnMouseEnter(Mask<FWL_EVENTFLAG> nFlags) override;
153 void OnMouseExit(Mask<FWL_EVENTFLAG> nFlags) override;
154 bool OnLButtonDown(Mask<FWL_EVENTFLAG> nFlags,
155 const CFX_PointF& point) override;
156 bool OnLButtonUp(Mask<FWL_EVENTFLAG> nFlags,
157 const CFX_PointF& point) override;
158 bool OnLButtonDblClk(Mask<FWL_EVENTFLAG> nFlags,
159 const CFX_PointF& point) override;
160 bool OnMouseMove(Mask<FWL_EVENTFLAG> nFlags,
161 const CFX_PointF& point) override;
162 bool OnMouseWheel(Mask<FWL_EVENTFLAG> nFlags,
163 const CFX_PointF& point,
164 const CFX_Vector& delta) override;
165 bool OnRButtonDown(Mask<FWL_EVENTFLAG> nFlags,
166 const CFX_PointF& point) override;
167 bool OnRButtonUp(Mask<FWL_EVENTFLAG> nFlags,
168 const CFX_PointF& point) override;
169 bool OnChar(uint32_t nChar, Mask<FWL_EVENTFLAG> nFlags) override;
170 bool OnKeyDown(FWL_VKEYCODE nKeyCode, Mask<FWL_EVENTFLAG> nFlags) override;
171 bool OnSetFocus(Mask<FWL_EVENTFLAG> nFlags) override;
172 bool OnKillFocus(Mask<FWL_EVENTFLAG> nFlags) override;
173
174 CFFL_InteractiveFormFiller* GetInteractiveFormFiller();
175
176#ifdef PDF_ENABLE_XFA
177 CXFA_FFWidgetHandler* GetXFAWidgetHandler() const;
178 CXFA_FFWidget* GetGroupMixXFAWidget() const;
179 WideString GetName() const;
180 bool HandleXFAAAction(CPDF_AAction::AActionType type,
181 CFFL_FieldAction* data,
182 CPDFSDK_FormFillEnvironment* pFormFillEnv);
183#endif // PDF_ENABLE_XFA
184
185 UnownedPtr<CPDFSDK_InteractiveForm> const m_pInteractiveForm;
186 bool m_bAppModified = false;
187 uint32_t m_nAppearanceAge = 0;
188 uint32_t m_nValueAge = 0;
189};
190
191inline CPDFSDK_Widget* ToCPDFSDKWidget(CPDFSDK_Annot* pAnnot) {
192 return pAnnot && pAnnot->GetAnnotSubtype() == CPDF_Annot::Subtype::WIDGET
193 ? static_cast<CPDFSDK_Widget*>(pAnnot)
194 : nullptr;
195}
196
197#endif // FPDFSDK_CPDFSDK_WIDGET_H_
fxcrt::ByteString ByteString
Definition bytestring.h:180
CPDFSDK_AnnotIterator(CPDFSDK_PageView *pPageView, const std::vector< CPDF_Annot::Subtype > &subtypes_to_iterate)
CPDFSDK_Annot * GetNextAnnot(CPDFSDK_Annot *pAnnot)
CPDFSDK_Annot * GetPrevAnnot(CPDFSDK_Annot *pAnnot)
virtual CPDF_Annot::Subtype GetAnnotSubtype() const =0
virtual CPDF_Annot * GetPDFAnnot() const
CPDF_Page * GetPDFPage() const
void SetOptionSelection(int index)
WideString GetValue() const
std::optional< FX_COLORREF > GetBorderColor() const
bool CanUndo() override
int GetMaxLen() const
WideString GetSelectExportText(int nIndex) const
CPDF_FormField * GetFormField() const
bool IsWidgetAppearanceValid(CPDF_Annot::AppearanceMode mode) const
void SetRect(const CFX_FloatRect &rect)
bool OnMouseMove(Mask< FWL_EVENTFLAG > nFlags, const CFX_PointF &point) override
WideString GetSelectedText() override
int GetSelectedIndex(int nIndex) const
int GetAlignment() const
bool OnAAction(CPDF_AAction::AActionType type, CFFL_FieldAction *data, const CPDFSDK_PageView *pPageView)
int GetTopVisibleIndex() const
bool Undo() override
bool IsIndexSelected(int index) override
bool OnRButtonUp(Mask< FWL_EVENTFLAG > nFlags, const CFX_PointF &point) override
CFX_Matrix GetMatrix() const
bool OnLButtonUp(Mask< FWL_EVENTFLAG > nFlags, const CFX_PointF &point) override
bool OnLButtonDown(Mask< FWL_EVENTFLAG > nFlags, const CFX_PointF &point) override
bool IsSignatureWidget() const
bool CanRedo() override
uint32_t GetValueAge() const
bool IsChecked() const
bool IsOptionSelected(int nIndex) const
void SetCheck(bool bChecked)
std::optional< FX_COLORREF > GetTextColor() const
int GetRotate() const
void OnMouseExit(Mask< FWL_EVENTFLAG > nFlags) override
int GetFieldFlags() const
int CountOptions() const
void ReplaceSelection(const WideString &text) override
std::optional< WideString > OnFormat()
std::optional< FX_COLORREF > GetFillColor() const
void DrawShadow(CFX_RenderDevice *pDevice, CPDFSDK_PageView *pPageView)
void ResetAppearance(std::optional< WideString > sValue, ValueChanged bValueChanged)
CFX_FloatRect GetViewBBox() override
bool SetIndexSelected(int index, bool selected) override
bool OnSetFocus(Mask< FWL_EVENTFLAG > nFlags) override
void ReplaceAndKeepSelection(const WideString &text) override
bool IsAppearanceValid() override
WideString GetOptionLabel(int nIndex) const
CPDF_FormControl * GetFormControl() const
void SetTopVisibleIndex(int index)
void DrawAppearance(CFX_RenderDevice *pDevice, const CFX_Matrix &mtUser2Device, CPDF_Annot::AppearanceMode mode) override
bool OnMouseWheel(Mask< FWL_EVENTFLAG > nFlags, const CFX_PointF &point, const CFX_Vector &delta) override
bool OnKeyDown(FWL_VKEYCODE nKeyCode, Mask< FWL_EVENTFLAG > nFlags) override
CPDF_Action GetAAction(CPDF_AAction::AActionType eAAT) override
bool OnLButtonDblClk(Mask< FWL_EVENTFLAG > nFlags, const CFX_PointF &point) override
CFX_FloatRect GetRotatedRect() const
bool IsAppModified() const
int GetLayoutOrder() const override
void OnMouseEnter(Mask< FWL_EVENTFLAG > nFlags) override
float GetFontSize() const
~CPDFSDK_Widget() override
bool OnKillFocus(Mask< FWL_EVENTFLAG > nFlags) override
uint32_t GetAppearanceAge() const
void SetValue(const WideString &sValue)
CFX_Color GetFillPWLColor() const
void OnDraw(CFX_RenderDevice *pDevice, const CFX_Matrix &mtUser2Device, bool bDrawAnnots) override
bool SelectAllText() override
CFX_FloatRect GetClientRect() const
WideString GetText() override
CFX_Color GetTextPWLColor() const
bool IsPushHighlighted() const
CPDFSDK_Widget(CPDF_Annot *pAnnot, CPDFSDK_PageView *pPageView, CPDFSDK_InteractiveForm *pInteractiveForm)
bool OnRButtonDown(Mask< FWL_EVENTFLAG > nFlags, const CFX_PointF &point) override
WideString GetExportValue() const
CFX_Color GetBorderPWLColor() const
bool DoHitTest(const CFX_PointF &point) override
bool OnChar(uint32_t nChar, Mask< FWL_EVENTFLAG > nFlags) override
FormFieldType GetFieldType() const
void OnLoad() override
bool Redo() override
CFX_FloatRect GetRect() const
bool operator==(const char *ptr) const
FormFieldType
CPDFSDK_Widget * ToCPDFSDKWidget(CPDFSDK_Annot *pAnnot)
CFX_VTemplate< int32_t > CFX_Vector
CFX_PTemplate< float > CFX_PointF
uint32_t FX_COLORREF
Definition fx_dib.h:42
fxcrt::WideString WideString
Definition widestring.h:207