Fix a leak with g_DefaultGlobalObjectTemplate.
[pdfium.git] / fpdfsdk / include / formfiller / FFL_ComboBox.h
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 "../../../core/include/fxcrt/fx_string.h"
11 #include "FFL_FormFiller.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   void OnKeyStroke(FX_BOOL bKeyDown, FX_DWORD nFlag) override;
51
52   // IPWL_FocusHandler:
53   void OnSetFocus(CPWL_Wnd* pWnd) override;
54   void OnKillFocus(CPWL_Wnd* pWnd) override;
55
56   // IPWL_Edit_Notify:
57   void OnAddUndo(CPWL_Edit* pEdit) override;
58
59  private:
60   CFX_WideString GetSelectExportText();
61
62   CBA_FontMap* m_pFontMap;
63   FFL_ComboBoxState m_State;
64 };
65
66 #endif  // FPDFSDK_INCLUDE_FORMFILLER_FFL_COMBOBOX_H_