1 // Copyright 2014 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_FORMFILLER_CFFL_TEXTFIELD_H_ 8 #define FPDFSDK_FORMFILLER_CFFL_TEXTFIELD_H_ 9 10 #include "fpdfsdk/formfiller/cffl_textobject.h" 11 12 #define BF_ALIGN_LEFT 0 13 #define BF_ALIGN_MIDDLE 1 14 #define BF_ALIGN_RIGHT 2 15 16 class CBA_FontMap; 17 class CPWL_Edit; 18 19 struct FFL_TextFieldState { FFL_TextFieldStateFFL_TextFieldState20 FFL_TextFieldState() : nStart(0), nEnd(0) {} 21 22 int nStart; 23 int nEnd; 24 WideString sValue; 25 }; 26 27 class CFFL_TextField : public CFFL_TextObject, 28 public CPWL_Wnd::FocusHandlerIface { 29 public: 30 CFFL_TextField(CPDFSDK_FormFillEnvironment* pApp, CPDFSDK_Widget* pWidget); 31 ~CFFL_TextField() override; 32 33 // CFFL_TextObject: 34 CPWL_Wnd::CreateParams GetCreateParam() override; 35 CPWL_Wnd* NewPDFWindow(const CPWL_Wnd::CreateParams& cp) override; 36 bool OnChar(CPDFSDK_Annot* pAnnot, uint32_t nChar, uint32_t nFlags) override; 37 bool IsDataChanged(CPDFSDK_PageView* pPageView) override; 38 void SaveData(CPDFSDK_PageView* pPageView) override; 39 void GetActionData(CPDFSDK_PageView* pPageView, 40 CPDF_AAction::AActionType type, 41 PDFSDK_FieldAction& fa) override; 42 void SetActionData(CPDFSDK_PageView* pPageView, 43 CPDF_AAction::AActionType type, 44 const PDFSDK_FieldAction& fa) override; 45 bool IsActionDataChanged(CPDF_AAction::AActionType type, 46 const PDFSDK_FieldAction& faOld, 47 const PDFSDK_FieldAction& faNew) override; 48 void SaveState(CPDFSDK_PageView* pPageView) override; 49 void RestoreState(CPDFSDK_PageView* pPageView) override; 50 #ifdef PDF_ENABLE_XFA 51 bool IsFieldFull(CPDFSDK_PageView* pPageView) override; 52 #endif 53 54 // CPWL_Wnd::FocusHandlerIface: 55 void OnSetFocus(CPWL_Edit* pEdit) override; 56 57 private: 58 CPWL_Edit* GetEdit(CPDFSDK_PageView* pPageView, bool bNew); 59 60 FFL_TextFieldState m_State; 61 }; 62 63 #endif // FPDFSDK_FORMFILLER_CFFL_TEXTFIELD_H_ 64