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_LISTBOX_LIGHT_H 8 #define _FWL_LISTBOX_LIGHT_H 9 class CFWL_Widget; 10 class CFWL_WidgetProperties; 11 class IFWL_ListBoxDP; 12 class CFWL_ListBox; 13 class CFWL_ListItem; 14 class CFWL_ListBox : public CFWL_Widget { 15 public: 16 static CFWL_ListBox* Create(); 17 FWL_ERR Initialize(const CFWL_WidgetProperties* pProperties = NULL); 18 FWL_ERR AddDIBitmap(CFX_DIBitmap* pDIB, FWL_HLISTITEM hItem); 19 FWL_HLISTITEM AddString(const CFX_WideStringC& wsAdd, 20 FX_BOOL bSelect = FALSE); 21 FX_BOOL DeleteString(FWL_HLISTITEM hItem); 22 FX_BOOL DeleteAll(); 23 int32_t CountSelItems(); 24 FWL_HLISTITEM GetSelItem(int32_t nIndexSel); 25 int32_t GetSelIndex(int32_t nIndex); 26 FWL_ERR SetSelItem(FWL_HLISTITEM hItem, FX_BOOL bSelect = TRUE); 27 FWL_ERR GetItemText(FWL_HLISTITEM hItem, CFX_WideString& wsText); 28 FWL_ERR GetScrollPos(FX_FLOAT& fPos, FX_BOOL bVert = TRUE); 29 FWL_ERR SetItemHeight(FX_FLOAT fItemHeight); 30 FWL_HLISTITEM GetFocusItem(); 31 FWL_ERR SetFocusItem(FWL_HLISTITEM hItem); 32 FWL_ERR* Sort(IFWL_ListBoxCompare* pCom); 33 int32_t CountItems(); 34 FWL_HLISTITEM GetItem(int32_t nIndex); 35 FWL_ERR SetItemString(FWL_HLISTITEM hItem, const CFX_WideStringC& wsText); 36 FWL_ERR GetItemString(FWL_HLISTITEM hItem, CFX_WideString& wsText); 37 FWL_ERR SetItemData(FWL_HLISTITEM hItem, void* pData); 38 void* GetItemData(FWL_HLISTITEM hItem); 39 FWL_HLISTITEM GetItemAtPoint(FX_FLOAT fx, FX_FLOAT fy); 40 FX_DWORD GetItemStates(FWL_HLISTITEM hItem); 41 CFWL_ListBox(); 42 virtual ~CFWL_ListBox(); 43 44 protected: 45 class CFWL_ListBoxDP : public IFWL_ListBoxDP { 46 public: 47 CFWL_ListBoxDP(); 48 ~CFWL_ListBoxDP(); 49 virtual FWL_ERR GetCaption(IFWL_Widget* pWidget, CFX_WideString& wsCaption); 50 51 virtual int32_t CountItems(IFWL_Widget* pWidget); 52 virtual FWL_HLISTITEM GetItem(IFWL_Widget* pWidget, int32_t nIndex); 53 virtual int32_t GetItemIndex(IFWL_Widget* pWidget, FWL_HLISTITEM hItem); 54 virtual FX_BOOL SetItemIndex(IFWL_Widget* pWidget, 55 FWL_HLISTITEM hItem, 56 int32_t nIndex); 57 58 virtual FX_DWORD GetItemStyles(IFWL_Widget* pWidget, FWL_HLISTITEM hItem); 59 virtual FWL_ERR GetItemText(IFWL_Widget* pWidget, 60 FWL_HLISTITEM hItem, 61 CFX_WideString& wsText); 62 virtual FWL_ERR GetItemRect(IFWL_Widget* pWidget, 63 FWL_HLISTITEM hItem, 64 CFX_RectF& rtItem); 65 virtual void* GetItemData(IFWL_Widget* pWidget, FWL_HLISTITEM hItem); 66 67 virtual FWL_ERR SetItemStyles(IFWL_Widget* pWidget, 68 FWL_HLISTITEM hItem, 69 FX_DWORD dwStyle); 70 virtual FWL_ERR SetItemText(IFWL_Widget* pWidget, 71 FWL_HLISTITEM hItem, 72 const FX_WCHAR* pszText); 73 virtual FWL_ERR SetItemRect(IFWL_Widget* pWidget, 74 FWL_HLISTITEM hItem, 75 const CFX_RectF& rtItem); 76 virtual FX_FLOAT GetItemHeight(IFWL_Widget* pWidget); 77 virtual CFX_DIBitmap* GetItemIcon(IFWL_Widget* pWidget, 78 FWL_HLISTITEM hItem); 79 virtual FWL_ERR GetItemCheckRect(IFWL_Widget* pWidget, 80 FWL_HLISTITEM hItem, 81 CFX_RectF& rtCheck); 82 virtual FWL_ERR SetItemCheckRect(IFWL_Widget* pWidget, 83 FWL_HLISTITEM hItem, 84 const CFX_RectF& rtCheck); 85 virtual FX_DWORD GetItemCheckState(IFWL_Widget* pWidget, 86 FWL_HLISTITEM hItem); 87 virtual FWL_ERR SetItemCheckState(IFWL_Widget* pWidget, 88 FWL_HLISTITEM hItem, 89 FX_DWORD dwCheckState); 90 91 CFX_PtrArray m_arrItem; 92 CFX_WideString m_wsData; 93 FX_FLOAT m_fItemHeight; 94 }; 95 CFWL_ListBoxDP m_ListBoxDP; 96 }; 97 class CFWL_ListItem { 98 public: 99 CFWL_ListItem() { 100 m_rtItem.Reset(); 101 m_dwStates = 0; 102 m_wsText = L""; 103 m_pDIB = NULL; 104 m_pData = NULL; 105 m_dwCheckState = 0; 106 m_rtCheckBox.Reset(); 107 } 108 CFX_RectF m_rtItem; 109 FX_DWORD m_dwStates; 110 CFX_WideString m_wsText; 111 CFX_DIBitmap* m_pDIB; 112 void* m_pData; 113 FX_DWORD m_dwCheckState; 114 CFX_RectF m_rtCheckBox; 115 }; 116 #endif 117