• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2017 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 XFA_FXFA_CXFA_FFCOMBOBOX_H_
8 #define XFA_FXFA_CXFA_FFCOMBOBOX_H_
9 
10 #include "core/fxcrt/unowned_ptr.h"
11 #include "xfa/fxfa/cxfa_ffdropdown.h"
12 
13 class CXFA_EventParam;
14 
15 class CXFA_FFComboBox final : public CXFA_FFDropDown {
16  public:
17   explicit CXFA_FFComboBox(CXFA_Node* pNode);
18   ~CXFA_FFComboBox() override;
19 
20   // CXFA_FFDropDown:
21   CXFA_FFComboBox* AsComboBox() override;
22 
23   // CXFA_FFField
24   CFX_RectF GetBBox(FocusOption focus) override;
25   bool LoadWidget() override;
26   void UpdateWidgetProperty() override;
27   bool OnRButtonUp(uint32_t dwFlags, const CFX_PointF& point) override;
28   bool OnKillFocus(CXFA_FFWidget* pNewWidget) override WARN_UNUSED_RESULT;
29   bool CanUndo() override;
30   bool CanRedo() override;
31   bool Undo() override;
32   bool Redo() override;
33 
34   bool CanCopy() override;
35   bool CanCut() override;
36   bool CanPaste() override;
37   bool CanSelectAll() override;
38   Optional<WideString> Copy() override;
39   Optional<WideString> Cut() override;
40   bool Paste(const WideString& wsPaste) override;
41   void SelectAll() override;
42   void Delete() override;
43   void DeSelect() override;
44   WideString GetText() override;
45   FormFieldType GetFormFieldType() override;
46 
47   // IFWL_WidgetDelegate
48   void OnProcessMessage(CFWL_Message* pMessage) override;
49   void OnProcessEvent(CFWL_Event* pEvent) override;
50   void OnDrawWidget(CXFA_Graphics* pGraphics,
51                     const CFX_Matrix& matrix) override;
52 
53   // CXFA_FFDropDown
54   void InsertItem(const WideString& wsLabel, int32_t nIndex) override;
55   void DeleteItem(int32_t nIndex) override;
56 
57   void OpenDropDownList();
58 
59   void OnTextChanged(CFWL_Widget* pWidget, const WideString& wsChanged);
60   void OnSelectChanged(CFWL_Widget* pWidget, bool bLButtonUp);
61   void OnPreOpen(CFWL_Widget* pWidget);
62   void OnPostOpen(CFWL_Widget* pWidget);
63   void SetItemState(int32_t nIndex, bool bSelected);
64 
65  private:
66   // CXFA_FFField:
67   bool PtInActiveRect(const CFX_PointF& point) override;
68   bool CommitData() override;
69   bool UpdateFWLData() override;
70   bool IsDataChanged() override;
71 
72   uint32_t GetAlignment();
73   void FWLEventSelChange(CXFA_EventParam* pParam);
74   WideString GetCurrentText() const;
75 
76   WideString m_wsNewValue;
77   UnownedPtr<IFWL_WidgetDelegate> m_pOldDelegate;
78 };
79 
80 #endif  // XFA_FXFA_CXFA_FFCOMBOBOX_H_
81