1 // Copyright 2017 The PDFium Authors 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 "v8/include/cppgc/member.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 CONSTRUCT_VIA_MAKE_GARBAGE_COLLECTED; 18 ~CXFA_FFComboBox() override; 19 20 void Trace(cppgc::Visitor* visitor) const override; 21 22 // CXFA_FFDropDown: 23 CXFA_FFComboBox* AsComboBox() override; 24 25 // CXFA_FFField 26 CFX_RectF GetBBox(FocusOption focus) override; 27 bool LoadWidget() override; 28 void UpdateWidgetProperty() override; 29 bool OnRButtonUp(Mask<XFA_FWL_KeyFlag> dwFlags, 30 const CFX_PointF& point) override; 31 [[nodiscard]] bool OnKillFocus(CXFA_FFWidget* pNewWidget) override; 32 bool CanUndo() override; 33 bool CanRedo() override; 34 bool CanCopy() override; 35 bool CanCut() override; 36 bool CanPaste() override; 37 bool CanSelectAll() override; 38 bool Undo() override; 39 bool Redo() override; 40 absl::optional<WideString> Copy() override; 41 absl::optional<WideString> Cut() override; 42 bool Paste(const WideString& wsPaste) override; 43 void SelectAll() override; 44 void Delete() override; 45 void DeSelect() override; 46 WideString GetText() override; 47 FormFieldType GetFormFieldType() override; 48 49 // IFWL_WidgetDelegate 50 void OnProcessMessage(CFWL_Message* pMessage) override; 51 void OnProcessEvent(CFWL_Event* pEvent) override; 52 void OnDrawWidget(CFGAS_GEGraphics* pGraphics, 53 const CFX_Matrix& matrix) override; 54 55 // CXFA_FFDropDown 56 void InsertItem(const WideString& wsLabel, int32_t nIndex) override; 57 void DeleteItem(int32_t nIndex) override; 58 59 void OpenDropDownList(); 60 61 void OnTextChanged(CFWL_Widget* pWidget, const WideString& wsChanged); 62 void OnSelectChanged(CFWL_Widget* pWidget, bool bLButtonUp); 63 void OnPreOpen(CFWL_Widget* pWidget); 64 void OnPostOpen(CFWL_Widget* pWidget); 65 void SetItemState(int32_t nIndex, bool bSelected); 66 67 private: 68 explicit CXFA_FFComboBox(CXFA_Node* pNode); 69 70 // CXFA_FFField: 71 bool PtInActiveRect(const CFX_PointF& point) override; 72 bool CommitData() override; 73 bool UpdateFWLData() override; 74 bool IsDataChanged() override; 75 76 uint32_t GetAlignment(); 77 void FWLEventSelChange(CXFA_EventParam* pParam); 78 WideString GetCurrentText() const; 79 80 WideString m_wsNewValue; 81 cppgc::Member<IFWL_WidgetDelegate> m_pOldDelegate; 82 }; 83 84 #endif // XFA_FXFA_CXFA_FFCOMBOBOX_H_ 85