• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_COMBOBOX_H_
8 #define FPDFSDK_FORMFILLER_CFFL_COMBOBOX_H_
9 
10 #include <memory>
11 
12 #include "core/fxcrt/fx_string.h"
13 #include "fpdfsdk/formfiller/cffl_textobject.h"
14 
15 class CPWL_ComboBox;
16 
17 struct FFL_ComboBoxState {
18   int nIndex = 0;
19   int nStart = 0;
20   int nEnd = 0;
21   WideString sValue;
22 };
23 
24 class CFFL_ComboBox final : public CFFL_TextObject,
25                             public CPWL_Wnd::FocusHandlerIface {
26  public:
27   CFFL_ComboBox(CPDFSDK_FormFillEnvironment* pApp, CPDFSDK_Widget* pWidget);
28   ~CFFL_ComboBox() override;
29 
30   // CFFL_TextObject:
31   CPWL_Wnd::CreateParams GetCreateParam() override;
32   std::unique_ptr<CPWL_Wnd> NewPWLWindow(
33       const CPWL_Wnd::CreateParams& cp,
34       std::unique_ptr<IPWL_SystemHandler::PerWindowData> pAttachedData)
35       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                      CPDFSDK_FieldAction& fa) override;
42   void SetActionData(CPDFSDK_PageView* pPageView,
43                      CPDF_AAction::AActionType type,
44                      const CPDFSDK_FieldAction& fa) override;
45   void SaveState(CPDFSDK_PageView* pPageView) override;
46   void RestoreState(CPDFSDK_PageView* pPageView) override;
47   bool SetIndexSelected(int index, bool selected) override;
48   bool IsIndexSelected(int index) override;
49 #ifdef PDF_ENABLE_XFA
50   bool IsFieldFull(CPDFSDK_PageView* pPageView) override;
51 #endif
52 
53   // CPWL_Wnd::FocusHandlerIface:
54   void OnSetFocus(CPWL_Edit* pEdit) override;
55 
56  private:
57   WideString GetSelectExportText();
58   CPWL_ComboBox* GetComboBox(CPDFSDK_PageView* pPageView, bool bNew);
59 
60   FFL_ComboBoxState m_State;
61 };
62 
63 #endif  // FPDFSDK_FORMFILLER_CFFL_COMBOBOX_H_
64