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 _FWL_COMBOBOX_LIGHT_H 8 #define _FWL_COMBOBOX_LIGHT_H 9 class CFWL_Widget; 10 class CFWL_WidgetProperties; 11 class IFWL_ComboBoxDP; 12 class CFWL_ComboBox; 13 class CFWL_ComboBoxDP; 14 class CFWL_ComboBoxItem; 15 class CFWL_ComboBox : public CFWL_Widget { 16 public: 17 static CFWL_ComboBox* Create(); 18 FWL_ERR Initialize(const CFWL_WidgetProperties* pProperties = NULL); 19 int32_t AddString(const CFX_WideStringC& wsText); 20 int32_t AddString(const CFX_WideStringC& wsText, CFX_DIBitmap* pIcon); 21 int32_t RemoveAt(int32_t iIndex); 22 int32_t RemoveAll(); 23 int32_t CountItems(); 24 FWL_ERR GetTextByIndex(int32_t iIndex, CFX_WideString& wsText); 25 int32_t GetCurSel(); 26 FWL_ERR SetCurSel(int32_t iSel); 27 FWL_ERR SetEditText(const CFX_WideStringC& wsText); 28 int32_t GetEditTextLength() const; 29 FWL_ERR GetEditText(CFX_WideString& wsText, 30 int32_t nStart = 0, 31 int32_t nCount = -1) const; 32 FWL_ERR SetEditSelRange(int32_t nStart, int32_t nCount = -1); 33 int32_t GetEditSelRange(int32_t nIndex, int32_t& nStart); 34 int32_t GetEditLimit(); 35 FWL_ERR SetEditLimit(int32_t nLimit); 36 FWL_ERR EditDoClipboard(int32_t iCmd); 37 FX_BOOL EditRedo(const CFX_ByteStringC& bsRecord); 38 FX_BOOL EditUndo(const CFX_ByteStringC& bsRecord); 39 FWL_ERR SetMaxListHeight(FX_FLOAT fMaxHeight); 40 FWL_ERR SetItemData(int32_t iIndex, void* pData); 41 void* GetItemData(int32_t iIndex); 42 FWL_ERR SetListTheme(IFWL_ThemeProvider* pTheme); 43 FX_BOOL AfterFocusShowDropList(); 44 FWL_ERR OpenDropDownList(FX_BOOL bActivate); 45 46 public: 47 FX_BOOL EditCanUndo(); 48 FX_BOOL EditCanRedo(); 49 FX_BOOL EditUndo(); 50 FX_BOOL EditRedo(); 51 FX_BOOL EditCanCopy(); 52 FX_BOOL EditCanCut(); 53 FX_BOOL EditCanSelectAll(); 54 FX_BOOL EditCopy(CFX_WideString& wsCopy); 55 FX_BOOL EditCut(CFX_WideString& wsCut); 56 FX_BOOL EditPaste(const CFX_WideString& wsPaste); 57 FX_BOOL EditSelectAll(); 58 FX_BOOL EditDelete(); 59 FX_BOOL EditDeSelect(); 60 FWL_ERR GetBBox(CFX_RectF& rect); 61 FWL_ERR EditModifyStylesEx(FX_DWORD dwStylesExAdded, 62 FX_DWORD dwStylesExRemoved); 63 CFWL_ComboBox(); 64 virtual ~CFWL_ComboBox(); 65 66 protected: 67 class CFWL_ComboBoxDP : public IFWL_ComboBoxDP { 68 public: 69 CFWL_ComboBoxDP(); 70 ~CFWL_ComboBoxDP(); GetCaption(IFWL_Widget * pWidget,CFX_WideString & wsCaption)71 virtual FWL_ERR GetCaption(IFWL_Widget* pWidget, 72 CFX_WideString& wsCaption) { 73 return FWL_ERR_Succeeded; 74 } 75 76 virtual int32_t CountItems(IFWL_Widget* pWidget); 77 virtual FWL_HLISTITEM GetItem(IFWL_Widget* pWidget, int32_t nIndex); 78 virtual int32_t GetItemIndex(IFWL_Widget* pWidget, FWL_HLISTITEM hItem); 79 virtual FX_BOOL SetItemIndex(IFWL_Widget* pWidget, 80 FWL_HLISTITEM hItem, 81 int32_t nIndex); 82 83 virtual FX_DWORD GetItemStyles(IFWL_Widget* pWidget, FWL_HLISTITEM hItem); 84 virtual FWL_ERR GetItemText(IFWL_Widget* pWidget, 85 FWL_HLISTITEM hItem, 86 CFX_WideString& wsText); 87 virtual FWL_ERR GetItemRect(IFWL_Widget* pWidget, 88 FWL_HLISTITEM hItem, 89 CFX_RectF& rtItem); 90 virtual void* GetItemData(IFWL_Widget* pWidget, FWL_HLISTITEM hItem); 91 virtual FWL_ERR SetItemStyles(IFWL_Widget* pWidget, 92 FWL_HLISTITEM hItem, 93 FX_DWORD dwStyle); 94 virtual FWL_ERR SetItemText(IFWL_Widget* pWidget, 95 FWL_HLISTITEM hItem, 96 const FX_WCHAR* pszText); 97 virtual FWL_ERR SetItemRect(IFWL_Widget* pWidget, 98 FWL_HLISTITEM hItem, 99 const CFX_RectF& rtItem); 100 virtual FX_FLOAT GetItemHeight(IFWL_Widget* pWidget); 101 virtual CFX_DIBitmap* GetItemIcon(IFWL_Widget* pWidget, 102 FWL_HLISTITEM hItem); 103 virtual FWL_ERR GetItemCheckRect(IFWL_Widget* pWidget, 104 FWL_HLISTITEM hItem, 105 CFX_RectF& rtCheck); 106 virtual FWL_ERR SetItemCheckRect(IFWL_Widget* pWidget, 107 FWL_HLISTITEM hItem, 108 const CFX_RectF& rtCheck); 109 virtual FX_DWORD GetItemCheckState(IFWL_Widget* pWidget, 110 FWL_HLISTITEM hItem); 111 virtual FWL_ERR SetItemCheckState(IFWL_Widget* pWidget, 112 FWL_HLISTITEM hItem, 113 FX_DWORD dwCheckState); 114 virtual FX_FLOAT GetListHeight(IFWL_Widget* pWidget); 115 116 CFX_PtrArray m_arrItem; 117 FX_FLOAT m_fMaxListHeight; 118 FX_FLOAT m_fItemHeight; 119 }; 120 CFWL_ComboBoxDP m_comboBoxData; 121 }; 122 class CFWL_ComboBoxItem { 123 public: CFWL_ComboBoxItem()124 CFWL_ComboBoxItem() { 125 m_pDIB = NULL; 126 m_pData = NULL; 127 } 128 CFX_RectF m_rtItem; 129 FX_DWORD m_dwStyles; 130 CFX_WideString m_wsText; 131 CFX_DIBitmap* m_pDIB; 132 FX_DWORD m_dwCheckState; 133 CFX_RectF m_rtCheckBox; 134 void* m_pData; 135 }; 136 #endif 137