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_H 8 #define _FWL_LISTBOX_H 9 class CFWL_WidgetImpProperties; 10 class IFWL_Widget; 11 class IFWL_ListBoxDP; 12 class IFWL_ListBox; 13 #define FWL_CLASS_ListBox L"FWL_LISTBOX" 14 #define FWL_CLASSHASH_ListBox 1777358317 15 #define FWL_STYLEEXT_LTB_MultiSelection (1L << 0) 16 #define FWL_STYLEEXT_LTB_Sort (1L << 1) 17 #define FWL_STYLEEXT_LTB_ShowScrollBarAlaways (1L << 2) 18 #define FWL_STYLEEXT_LTB_MultiColumn (1L << 3) 19 #define FWL_STYLEEXT_LTB_LeftAlign (0L << 4) 20 #define FWL_STYLEEXT_LTB_CenterAlign (1L << 4) 21 #define FWL_STYLEEXT_LTB_RightAlign (2L << 4) 22 #define FWL_STYLEEXT_LTB_MultiLine (1L << 6) 23 #define FWL_STYLEEXT_LTB_OwnerDraw (1L << 7) 24 #define FWL_STYLEEXT_LTB_Icon (1L << 8) 25 #define FWL_STYLEEXT_LTB_Check (1L << 9) 26 #define FWL_STYLEEXT_LTB_AlignMask (3L << 4) 27 #define FWL_STYLEEXT_LTB_ShowScrollBarFocus (1L << 10) 28 #define FWL_ITEMSTATE_LTB_Selected (1L << 0) 29 #define FWL_ITEMSTATE_LTB_Focused (1L << 1) 30 #define FWL_ITEMSTATE_LTB_Checked (1L << 2) 31 #define FWL_PART_LTB_Border 1 32 #define FWL_PART_LTB_Edge 2 33 #define FWL_PART_LTB_Background 3 34 #define FWL_PART_LTB_ListItem 4 35 #define FWL_PART_LTB_Check 5 36 #define FWL_PART_LTB_Icon 6 37 #define FWL_PARTSTATE_LTB_Normal (0L << 0) 38 #define FWL_PARTSTATE_LTB_Selected (1L << 0) 39 #define FWL_PARTSTATE_LTB_Disabled (2L << 0) 40 #define FWL_PARTSTATE_LTB_Focused (1L << 2) 41 #define FWL_PARTSTATE_LTB_UnChecked (0L << 3) 42 #define FWL_PARTSTATE_LTB_Checked (1L << 3) 43 #define FWL_PARTSTATE_LTB_Mask (3L << 0) 44 #define FWL_WGTHITTEST_LTB_Item FWL_WGTHITTEST_MAX + 1 45 #define FWL_WGTHITTEST_LTB_HScrollBar FWL_WGTHITTEST_MAX + 2 46 #define FWL_WGTHITTEST_LTB_VScrollBar FWL_WGTHITTEST_MAX + 3 47 #define FWL_EVT_LTB_SelChanged L"FWL_EVENT_LTB_SelChanged" 48 #define FWL_EVT_LTB_DrawItem L"FWL_EVENT_LTB_DrawItem" 49 #define FWL_EVTHASH_LTB_SelChanged 1701781688 50 #define FWL_EVTHASH_LTB_DrawItem 1050853991 51 BEGIN_FWL_EVENT_DEF(CFWL_EvtLtbSelChanged, FWL_EVTHASH_LTB_SelChanged) 52 CFX_Int32Array iarraySels; 53 END_FWL_EVENT_DEF 54 BEGIN_FWL_EVENT_DEF(CFWL_EvtLtbDrawItem, FWL_EVTHASH_LTB_DrawItem) 55 CFX_Graphics* m_pGraphics; 56 CFX_Matrix m_matrix; 57 int32_t m_index; 58 CFX_RectF m_rect; 59 END_FWL_EVENT_DEF 60 typedef struct _FWL_HLISTITEM { void* pData; } * FWL_HLISTITEM; 61 typedef struct _FWL_ListBoxItemData { 62 IFWL_ListBoxDP* pDataProvider; 63 int32_t iIndex; 64 } FWL_ListBoxItemData; 65 class IFWL_ListBoxDP : public IFWL_DataProvider { 66 public: 67 virtual int32_t CountItems(IFWL_Widget* pWidget) = 0; 68 virtual FWL_HLISTITEM GetItem(IFWL_Widget* pWidget, int32_t nIndex) = 0; 69 virtual int32_t GetItemIndex(IFWL_Widget* pWidget, FWL_HLISTITEM hItem) = 0; 70 virtual FX_BOOL SetItemIndex(IFWL_Widget* pWidget, 71 FWL_HLISTITEM hItem, 72 int32_t nIndex) = 0; 73 virtual FX_DWORD GetItemStyles(IFWL_Widget* pWidget, FWL_HLISTITEM hItem) = 0; 74 virtual FWL_ERR GetItemText(IFWL_Widget* pWidget, 75 FWL_HLISTITEM hItem, 76 CFX_WideString& wsText) = 0; 77 virtual FWL_ERR GetItemRect(IFWL_Widget* pWidget, 78 FWL_HLISTITEM hItem, 79 CFX_RectF& rtItem) = 0; 80 virtual void* GetItemData(IFWL_Widget* pWidget, FWL_HLISTITEM hItem) = 0; 81 virtual FWL_ERR SetItemStyles(IFWL_Widget* pWidget, 82 FWL_HLISTITEM hItem, 83 FX_DWORD dwStyle) = 0; 84 virtual FWL_ERR SetItemText(IFWL_Widget* pWidget, 85 FWL_HLISTITEM hItem, 86 const FX_WCHAR* pszText) = 0; 87 virtual FWL_ERR SetItemRect(IFWL_Widget* pWidget, 88 FWL_HLISTITEM hItem, 89 const CFX_RectF& rtItem) = 0; 90 virtual FX_FLOAT GetItemHeight(IFWL_Widget* pWidget) = 0; 91 virtual CFX_DIBitmap* GetItemIcon(IFWL_Widget* pWidget, 92 FWL_HLISTITEM hItem) = 0; 93 virtual FWL_ERR GetItemCheckRect(IFWL_Widget* pWidget, 94 FWL_HLISTITEM hItem, 95 CFX_RectF& rtCheck) = 0; 96 virtual FWL_ERR SetItemCheckRect(IFWL_Widget* pWidget, 97 FWL_HLISTITEM hItem, 98 const CFX_RectF& rtCheck) = 0; 99 virtual FX_DWORD GetItemCheckState(IFWL_Widget* pWidget, 100 FWL_HLISTITEM hItem) = 0; 101 virtual FWL_ERR SetItemCheckState(IFWL_Widget* pWidget, 102 FWL_HLISTITEM hItem, 103 FX_DWORD dwCheckState) = 0; 104 }; 105 class IFWL_ListBoxCompare { 106 public: ~IFWL_ListBoxCompare()107 virtual ~IFWL_ListBoxCompare() {} 108 virtual int32_t Compare(FWL_HLISTITEM hLeft, FWL_HLISTITEM hRight) = 0; 109 }; 110 class IFWL_ListBox : public IFWL_Widget { 111 public: 112 static IFWL_ListBox* Create(const CFWL_WidgetImpProperties& properties, 113 IFWL_Widget* pOuter); 114 static IFWL_ListBox* CreateComboList( 115 const CFWL_WidgetImpProperties& properties, 116 IFWL_Widget* pOuter); 117 118 int32_t CountSelItems(); 119 FWL_HLISTITEM GetSelItem(int32_t nIndexSel); 120 int32_t GetSelIndex(int32_t nIndex); 121 FWL_ERR SetSelItem(FWL_HLISTITEM hItem, FX_BOOL bSelect = TRUE); 122 FWL_ERR GetItemText(FWL_HLISTITEM hItem, CFX_WideString& wsText); 123 FWL_ERR GetScrollPos(FX_FLOAT& fPos, FX_BOOL bVert = TRUE); 124 FWL_ERR* Sort(IFWL_ListBoxCompare* pCom); 125 126 protected: 127 IFWL_ListBox(); 128 }; 129 #endif 130