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 CanCopy() override;
32   bool CanCut() override;
33   bool CanPaste() override;
34   bool CanSelectAll() override;
35   bool Undo() override;
36   bool Redo() override;
37   Optional<WideString> Copy() override;
38   Optional<WideString> Cut() override;
39   bool Paste(const WideString& wsPaste) override;
40   void SelectAll() override;
41   void Delete() override;
42   void DeSelect() override;
43   WideString GetText() override;
44   FormFieldType GetFormFieldType() override;
45 
46   // IFWL_WidgetDelegate
47   void OnProcessMessage(CFWL_Message* pMessage) override;
48   void OnProcessEvent(CFWL_Event* pEvent) override;
49   void OnDrawWidget(CXFA_Graphics* pGraphics,
50                     const CFX_Matrix& matrix) override;
51 
52   // CXFA_FFDropDown
53   void InsertItem(const WideString& wsLabel, int32_t nIndex) override;
54   void DeleteItem(int32_t nIndex) override;
55 
56   void OpenDropDownList();
57 
58   void OnTextChanged(CFWL_Widget* pWidget, const WideString& wsChanged);
59   void OnSelectChanged(CFWL_Widget* pWidget, bool bLButtonUp);
60   void OnPreOpen(CFWL_Widget* pWidget);
61   void OnPostOpen(CFWL_Widget* pWidget);
62   void SetItemState(int32_t nIndex, bool bSelected);
63 
64  private:
65   // CXFA_FFField:
66   bool PtInActiveRect(const CFX_PointF& point) override;
67   bool CommitData() override;
68   bool UpdateFWLData() override;
69   bool IsDataChanged() override;
70 
71   uint32_t GetAlignment();
72   void FWLEventSelChange(CXFA_EventParam* pParam);
73   WideString GetCurrentText() const;
74 
75   WideString m_wsNewValue;
76   UnownedPtr<IFWL_WidgetDelegate> m_pOldDelegate;
77 };
78 
79 #endif  // XFA_FXFA_CXFA_FFCOMBOBOX_H_
80