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_PDFWINDOW_PWL_COMBOBOX_H_ 8 #define FPDFSDK_PDFWINDOW_PWL_COMBOBOX_H_ 9 10 #include "fpdfsdk/pdfwindow/PWL_Edit.h" 11 #include "fpdfsdk/pdfwindow/PWL_ListBox.h" 12 #include "fpdfsdk/pdfwindow/PWL_Wnd.h" 13 14 class CPWL_CBEdit : public CPWL_Edit { 15 public: CPWL_CBEdit()16 CPWL_CBEdit() {} ~CPWL_CBEdit()17 ~CPWL_CBEdit() override {} 18 }; 19 20 class CPWL_CBListBox : public CPWL_ListBox { 21 public: CPWL_CBListBox()22 CPWL_CBListBox() {} ~CPWL_CBListBox()23 ~CPWL_CBListBox() override {} 24 25 // CPWL_ListBox 26 bool OnLButtonUp(const CFX_PointF& point, uint32_t nFlag) override; 27 28 bool OnKeyDownWithExit(uint16_t nChar, bool& bExit, uint32_t nFlag); 29 bool OnCharWithExit(uint16_t nChar, bool& bExit, uint32_t nFlag); 30 }; 31 32 #define PWL_COMBOBOX_BUTTON_WIDTH 13 33 34 class CPWL_CBButton : public CPWL_Wnd { 35 public: CPWL_CBButton()36 CPWL_CBButton() {} ~CPWL_CBButton()37 ~CPWL_CBButton() override {} 38 39 // CPWL_Wnd 40 void GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) override; 41 void DrawThisAppearance(CFX_RenderDevice* pDevice, 42 CFX_Matrix* pUser2Device) override; 43 bool OnLButtonDown(const CFX_PointF& point, uint32_t nFlag) override; 44 bool OnLButtonUp(const CFX_PointF& point, uint32_t nFlag) override; 45 }; 46 47 class CPWL_ComboBox : public CPWL_Wnd { 48 public: 49 CPWL_ComboBox(); ~CPWL_ComboBox()50 ~CPWL_ComboBox() override {} 51 GetEdit()52 CPWL_Edit* GetEdit() const { return m_pEdit; } 53 54 // CPWL_Wnd: 55 CFX_ByteString GetClassName() const override; 56 void OnCreate(PWL_CREATEPARAM& cp) override; 57 bool OnKeyDown(uint16_t nChar, uint32_t nFlag) override; 58 bool OnChar(uint16_t nChar, uint32_t nFlag) override; 59 void OnNotify(CPWL_Wnd* pWnd, 60 uint32_t msg, 61 intptr_t wParam = 0, 62 intptr_t lParam = 0) override; 63 void CreateChildWnd(const PWL_CREATEPARAM& cp) override; 64 void RePosChildWnd() override; 65 CFX_FloatRect GetFocusRect() const override; 66 void SetFocus() override; 67 void KillFocus() override; 68 69 void SetFillerNotify(IPWL_Filler_Notify* pNotify); 70 71 CFX_WideString GetText() const; 72 void SetText(const CFX_WideString& text); 73 void AddString(const CFX_WideString& str); 74 int32_t GetSelect() const; 75 void SetSelect(int32_t nItemIndex); 76 77 void SetEditSel(int32_t nStartChar, int32_t nEndChar); 78 void GetEditSel(int32_t& nStartChar, int32_t& nEndChar) const; 79 void Clear(); 80 void SelectAll(); 81 bool IsPopup() const; 82 83 void SetSelectText(); 84 AttachFFLData(CFFL_FormFiller * pData)85 void AttachFFLData(CFFL_FormFiller* pData) { m_pFormFiller = pData; } 86 87 private: 88 void CreateEdit(const PWL_CREATEPARAM& cp); 89 void CreateButton(const PWL_CREATEPARAM& cp); 90 void CreateListBox(const PWL_CREATEPARAM& cp); 91 void SetPopup(bool bPopup); 92 93 CPWL_CBEdit* m_pEdit; 94 CPWL_CBButton* m_pButton; 95 CPWL_CBListBox* m_pList; 96 bool m_bPopup; 97 CFX_FloatRect m_rcOldWindow; 98 int32_t m_nPopupWhere; 99 int32_t m_nSelectItem; 100 IPWL_Filler_Notify* m_pFillerNotify; 101 CFFL_FormFiller* m_pFormFiller; // Not owned. 102 }; 103 104 #endif // FPDFSDK_PDFWINDOW_PWL_COMBOBOX_H_ 105