Home | History | Annotate | Download | only in formfiller
      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 <memory>
     11 
     12 #include "fpdfsdk/formfiller/cffl_formfiller.h"
     13 
     14 #define BF_ALIGN_LEFT 0
     15 #define BF_ALIGN_MIDDLE 1
     16 #define BF_ALIGN_RIGHT 2
     17 
     18 class CBA_FontMap;
     19 
     20 struct FFL_TextFieldState {
     21   FFL_TextFieldState() : nStart(0), nEnd(0) {}
     22 
     23   int nStart;
     24   int nEnd;
     25   CFX_WideString sValue;
     26 };
     27 
     28 class CFFL_TextField : public CFFL_FormFiller, public IPWL_FocusHandler {
     29  public:
     30   CFFL_TextField(CPDFSDK_FormFillEnvironment* pApp, CPDFSDK_Annot* pAnnot);
     31   ~CFFL_TextField() override;
     32 
     33   // CFFL_FormFiller:
     34   PWL_CREATEPARAM GetCreateParam() override;
     35   CPWL_Wnd* NewPDFWindow(const PWL_CREATEPARAM& cp,
     36                          CPDFSDK_PageView* pPageView) override;
     37   bool OnChar(CPDFSDK_Annot* pAnnot, uint32_t nChar, uint32_t nFlags) override;
     38   bool IsDataChanged(CPDFSDK_PageView* pPageView) override;
     39   void SaveData(CPDFSDK_PageView* pPageView) override;
     40   void GetActionData(CPDFSDK_PageView* pPageView,
     41                      CPDF_AAction::AActionType type,
     42                      PDFSDK_FieldAction& fa) override;
     43   void SetActionData(CPDFSDK_PageView* pPageView,
     44                      CPDF_AAction::AActionType type,
     45                      const PDFSDK_FieldAction& fa) override;
     46   bool IsActionDataChanged(CPDF_AAction::AActionType type,
     47                            const PDFSDK_FieldAction& faOld,
     48                            const PDFSDK_FieldAction& faNew) override;
     49   void SaveState(CPDFSDK_PageView* pPageView) override;
     50   void RestoreState(CPDFSDK_PageView* pPageView) override;
     51   CPWL_Wnd* ResetPDFWindow(CPDFSDK_PageView* pPageView,
     52                            bool bRestoreValue) override;
     53 
     54   // IPWL_FocusHandler:
     55   void OnSetFocus(CPWL_Wnd* pWnd) override;
     56 
     57 #ifdef PDF_ENABLE_XFA
     58   // CFFL_FormFiller:
     59   bool IsFieldFull(CPDFSDK_PageView* pPageView) override;
     60 #endif  // PDF_ENABLE_XFA
     61 
     62  private:
     63   std::unique_ptr<CBA_FontMap> m_pFontMap;
     64   FFL_TextFieldState m_State;
     65 };
     66 
     67 #endif  // FPDFSDK_FORMFILLER_CFFL_TEXTFIELD_H_
     68