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_INCLUDE_FORMFILLER_FFL_COMBOBOX_H_
8 #define FPDFSDK_INCLUDE_FORMFILLER_FFL_COMBOBOX_H_
9 
10 #include "FFL_FormFiller.h"
11 #include "core/include/fxcrt/fx_string.h"
12 
13 class CBA_FontMap;
14 class CPDFSDK_Document;
15 
16 struct FFL_ComboBoxState {
17   int nIndex;
18   int nStart;
19   int nEnd;
20   CFX_WideString sValue;
21 };
22 
23 class CFFL_ComboBox : public CFFL_FormFiller,
24                       public IPWL_FocusHandler,
25                       public IPWL_Edit_Notify {
26  public:
27   CFFL_ComboBox(CPDFDoc_Environment* pApp, CPDFSDK_Annot* pWidget);
28   ~CFFL_ComboBox() override;
29 
30   // CFFL_FormFiller:
31   PWL_CREATEPARAM GetCreateParam() override;
32   CPWL_Wnd* NewPDFWindow(const PWL_CREATEPARAM& cp,
33                          CPDFSDK_PageView* pPageView) override;
34   FX_BOOL OnChar(CPDFSDK_Annot* pAnnot, FX_UINT nChar, FX_UINT nFlags) override;
35   FX_BOOL IsDataChanged(CPDFSDK_PageView* pPageView) override;
36   void SaveData(CPDFSDK_PageView* pPageView) override;
37   void GetActionData(CPDFSDK_PageView* pPageView,
38                      CPDF_AAction::AActionType type,
39                      PDFSDK_FieldAction& fa) override;
40   void SetActionData(CPDFSDK_PageView* pPageView,
41                      CPDF_AAction::AActionType type,
42                      const PDFSDK_FieldAction& fa) override;
43   FX_BOOL IsActionDataChanged(CPDF_AAction::AActionType type,
44                               const PDFSDK_FieldAction& faOld,
45                               const PDFSDK_FieldAction& faNew) override;
46   void SaveState(CPDFSDK_PageView* pPageView) override;
47   void RestoreState(CPDFSDK_PageView* pPageView) override;
48   CPWL_Wnd* ResetPDFWindow(CPDFSDK_PageView* pPageView,
49                            FX_BOOL bRestoreValue) override;
50 
51   // IPWL_FocusHandler:
52   void OnSetFocus(CPWL_Wnd* pWnd) override;
53   void OnKillFocus(CPWL_Wnd* pWnd) override;
54 
55   // IPWL_Edit_Notify:
56   void OnAddUndo(CPWL_Edit* pEdit) override;
57 
58 #ifdef PDF_ENABLE_XFA
59   // CFFL_FormFiller:
60   FX_BOOL IsFieldFull(CPDFSDK_PageView* pPageView) override;
61 #endif  // PDF_ENABLE_XFA
62 
63  private:
64   CFX_WideString GetSelectExportText();
65 
66   CBA_FontMap* m_pFontMap;
67   FFL_ComboBoxState m_State;
68 };
69 
70 #endif  // FPDFSDK_INCLUDE_FORMFILLER_FFL_COMBOBOX_H_
71