| OLD | NEW |
| (Empty) |
| 1 // Copyright 2016 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 #ifndef FPDFSDK_INCLUDE_CPDFSDK_WIDGET_H_ | |
| 8 #define FPDFSDK_INCLUDE_CPDFSDK_WIDGET_H_ | |
| 9 | |
| 10 #include <set> | |
| 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/fxcrt/fx_coordinates.h" | |
| 16 #include "core/fxcrt/fx_string.h" | |
| 17 #include "fpdfsdk/include/cpdfsdk_baannot.h" | |
| 18 #include "fpdfsdk/include/pdfsdk_fieldaction.h" | |
| 19 #include "fpdfsdk/pdfwindow/PWL_Wnd.h" | |
| 20 | |
| 21 class CFX_RenderDevice; | |
| 22 class CPDF_Annot; | |
| 23 class CPDF_Dictionary; | |
| 24 class CPDF_FormControl; | |
| 25 class CPDF_FormField; | |
| 26 class CPDF_RenderOptions; | |
| 27 class CPDF_Stream; | |
| 28 class CPDFSDK_InterForm; | |
| 29 class CPDFSDK_PageView; | |
| 30 | |
| 31 #ifdef PDF_ENABLE_XFA | |
| 32 class CXFA_FFWidget; | |
| 33 class CXFA_FFWidgetHandler; | |
| 34 #endif // PDF_ENABLE_XFA | |
| 35 | |
| 36 class CPDFSDK_Widget : public CPDFSDK_BAAnnot { | |
| 37 public: | |
| 38 #ifdef PDF_ENABLE_XFA | |
| 39 CXFA_FFWidget* GetMixXFAWidget() const; | |
| 40 CXFA_FFWidget* GetGroupMixXFAWidget(); | |
| 41 CXFA_FFWidgetHandler* GetXFAWidgetHandler() const; | |
| 42 | |
| 43 FX_BOOL HasXFAAAction(PDFSDK_XFAAActionType eXFAAAT); | |
| 44 FX_BOOL OnXFAAAction(PDFSDK_XFAAActionType eXFAAAT, | |
| 45 PDFSDK_FieldAction& data, | |
| 46 CPDFSDK_PageView* pPageView); | |
| 47 | |
| 48 void Synchronize(FX_BOOL bSynchronizeElse); | |
| 49 void SynchronizeXFAValue(); | |
| 50 void SynchronizeXFAItems(); | |
| 51 | |
| 52 static void SynchronizeXFAValue(CXFA_FFDocView* pXFADocView, | |
| 53 CXFA_FFWidget* hWidget, | |
| 54 CPDF_FormField* pFormField, | |
| 55 CPDF_FormControl* pFormControl); | |
| 56 static void SynchronizeXFAItems(CXFA_FFDocView* pXFADocView, | |
| 57 CXFA_FFWidget* hWidget, | |
| 58 CPDF_FormField* pFormField, | |
| 59 CPDF_FormControl* pFormControl); | |
| 60 #endif // PDF_ENABLE_XFA | |
| 61 | |
| 62 CPDFSDK_Widget(CPDF_Annot* pAnnot, | |
| 63 CPDFSDK_PageView* pPageView, | |
| 64 CPDFSDK_InterForm* pInterForm); | |
| 65 ~CPDFSDK_Widget() override; | |
| 66 | |
| 67 bool IsSignatureWidget() const override; | |
| 68 CPDF_Action GetAAction(CPDF_AAction::AActionType eAAT) override; | |
| 69 FX_BOOL IsAppearanceValid() override; | |
| 70 | |
| 71 int GetLayoutOrder() const override; | |
| 72 | |
| 73 int GetFieldType() const; | |
| 74 int GetFieldFlags() const; | |
| 75 int GetRotate() const; | |
| 76 | |
| 77 FX_BOOL GetFillColor(FX_COLORREF& color) const; | |
| 78 FX_BOOL GetBorderColor(FX_COLORREF& color) const; | |
| 79 FX_BOOL GetTextColor(FX_COLORREF& color) const; | |
| 80 FX_FLOAT GetFontSize() const; | |
| 81 | |
| 82 int GetSelectedIndex(int nIndex) const; | |
| 83 #ifndef PDF_ENABLE_XFA | |
| 84 CFX_WideString GetValue() const; | |
| 85 #else | |
| 86 CFX_WideString GetValue(FX_BOOL bDisplay = TRUE) const; | |
| 87 #endif // PDF_ENABLE_XFA | |
| 88 CFX_WideString GetDefaultValue() const; | |
| 89 CFX_WideString GetOptionLabel(int nIndex) const; | |
| 90 int CountOptions() const; | |
| 91 FX_BOOL IsOptionSelected(int nIndex) const; | |
| 92 int GetTopVisibleIndex() const; | |
| 93 bool IsChecked() const; | |
| 94 int GetAlignment() const; | |
| 95 int GetMaxLen() const; | |
| 96 #ifdef PDF_ENABLE_XFA | |
| 97 CFX_WideString GetName() const; | |
| 98 #endif // PDF_ENABLE_XFA | |
| 99 CFX_WideString GetAlternateName() const; | |
| 100 | |
| 101 void SetCheck(bool bChecked, bool bNotify); | |
| 102 void SetValue(const CFX_WideString& sValue, FX_BOOL bNotify); | |
| 103 void SetDefaultValue(const CFX_WideString& sValue); | |
| 104 void SetOptionSelection(int index, FX_BOOL bSelected, FX_BOOL bNotify); | |
| 105 void ClearSelection(FX_BOOL bNotify); | |
| 106 void SetTopVisibleIndex(int index); | |
| 107 | |
| 108 #ifdef PDF_ENABLE_XFA | |
| 109 void ResetAppearance(FX_BOOL bValueChanged); | |
| 110 #endif // PDF_ENABLE_XFA | |
| 111 void ResetAppearance(const CFX_WideString* sValue, FX_BOOL bValueChanged); | |
| 112 void ResetFieldAppearance(FX_BOOL bValueChanged); | |
| 113 void UpdateField(); | |
| 114 CFX_WideString OnFormat(FX_BOOL& bFormatted); | |
| 115 | |
| 116 FX_BOOL OnAAction(CPDF_AAction::AActionType type, | |
| 117 PDFSDK_FieldAction& data, | |
| 118 CPDFSDK_PageView* pPageView); | |
| 119 | |
| 120 CPDFSDK_InterForm* GetInterForm() const { return m_pInterForm; } | |
| 121 CPDF_FormField* GetFormField() const; | |
| 122 CPDF_FormControl* GetFormControl() const; | |
| 123 static CPDF_FormControl* GetFormControl(CPDF_InterForm* pInterForm, | |
| 124 const CPDF_Dictionary* pAnnotDict); | |
| 125 | |
| 126 void DrawShadow(CFX_RenderDevice* pDevice, CPDFSDK_PageView* pPageView); | |
| 127 | |
| 128 void SetAppModified(); | |
| 129 void ClearAppModified(); | |
| 130 FX_BOOL IsAppModified() const; | |
| 131 | |
| 132 int32_t GetAppearanceAge() const; | |
| 133 int32_t GetValueAge() const; | |
| 134 | |
| 135 FX_BOOL IsWidgetAppearanceValid(CPDF_Annot::AppearanceMode mode); | |
| 136 void DrawAppearance(CFX_RenderDevice* pDevice, | |
| 137 const CFX_Matrix* pUser2Device, | |
| 138 CPDF_Annot::AppearanceMode mode, | |
| 139 const CPDF_RenderOptions* pOptions) override; | |
| 140 | |
| 141 FX_BOOL HitTest(FX_FLOAT pageX, FX_FLOAT pageY); | |
| 142 | |
| 143 private: | |
| 144 void ResetAppearance_PushButton(); | |
| 145 void ResetAppearance_CheckBox(); | |
| 146 void ResetAppearance_RadioButton(); | |
| 147 void ResetAppearance_ComboBox(const CFX_WideString* sValue); | |
| 148 void ResetAppearance_ListBox(); | |
| 149 void ResetAppearance_TextField(const CFX_WideString* sValue); | |
| 150 | |
| 151 CFX_FloatRect GetClientRect() const; | |
| 152 CFX_FloatRect GetRotatedRect() const; | |
| 153 | |
| 154 CFX_ByteString GetBackgroundAppStream() const; | |
| 155 CFX_ByteString GetBorderAppStream() const; | |
| 156 CFX_Matrix GetMatrix() const; | |
| 157 | |
| 158 CPWL_Color GetTextPWLColor() const; | |
| 159 CPWL_Color GetBorderPWLColor() const; | |
| 160 CPWL_Color GetFillPWLColor() const; | |
| 161 | |
| 162 void AddImageToAppearance(const CFX_ByteString& sAPType, CPDF_Stream* pImage); | |
| 163 void RemoveAppearance(const CFX_ByteString& sAPType); | |
| 164 | |
| 165 CPDFSDK_InterForm* const m_pInterForm; | |
| 166 FX_BOOL m_bAppModified; | |
| 167 int32_t m_nAppAge; | |
| 168 int32_t m_nValueAge; | |
| 169 | |
| 170 #ifdef PDF_ENABLE_XFA | |
| 171 mutable CXFA_FFWidget* m_hMixXFAWidget; | |
| 172 mutable CXFA_FFWidgetHandler* m_pWidgetHandler; | |
| 173 #endif // PDF_ENABLE_XFA | |
| 174 }; | |
| 175 | |
| 176 #endif // FPDFSDK_INCLUDE_CPDFSDK_WIDGET_H_ | |
| OLD | NEW |