OLD | NEW |
| (Empty) |
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 XFA_FWL_BASEWIDGET_IFWL_LISTBOX_H_ | |
8 #define XFA_FWL_BASEWIDGET_IFWL_LISTBOX_H_ | |
9 | |
10 #include "xfa/fwl/core/cfwl_event.h" | |
11 #include "xfa/fwl/core/cfwl_widgetimpproperties.h" | |
12 #include "xfa/fwl/core/ifwl_dataprovider.h" | |
13 #include "xfa/fwl/core/ifwl_widget.h" | |
14 | |
15 #define FWL_CLASS_ListBox L"FWL_LISTBOX" | |
16 #define FWL_STYLEEXT_LTB_MultiSelection (1L << 0) | |
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 | |
32 class CFX_DIBitmap; | |
33 | |
34 FWL_EVENT_DEF(CFWL_EvtLtbSelChanged, | |
35 CFWL_EventType::SelectChanged, | |
36 CFX_Int32Array iarraySels;) | |
37 | |
38 FWL_EVENT_DEF(CFWL_EvtLtbDrawItem, | |
39 CFWL_EventType::DrawItem, | |
40 CFX_Graphics* m_pGraphics; | |
41 CFX_Matrix m_matrix; | |
42 int32_t m_index; | |
43 CFX_RectF m_rect;) | |
44 | |
45 class IFWL_ListItem {}; | |
46 | |
47 class IFWL_ListBoxDP : public IFWL_DataProvider { | |
48 public: | |
49 virtual int32_t CountItems(IFWL_Widget* pWidget) = 0; | |
50 virtual IFWL_ListItem* GetItem(IFWL_Widget* pWidget, int32_t nIndex) = 0; | |
51 virtual int32_t GetItemIndex(IFWL_Widget* pWidget, IFWL_ListItem* pItem) = 0; | |
52 virtual FX_BOOL SetItemIndex(IFWL_Widget* pWidget, | |
53 IFWL_ListItem* pItem, | |
54 int32_t nIndex) = 0; | |
55 virtual uint32_t GetItemStyles(IFWL_Widget* pWidget, | |
56 IFWL_ListItem* pItem) = 0; | |
57 virtual FWL_Error GetItemText(IFWL_Widget* pWidget, | |
58 IFWL_ListItem* pItem, | |
59 CFX_WideString& wsText) = 0; | |
60 virtual FWL_Error GetItemRect(IFWL_Widget* pWidget, | |
61 IFWL_ListItem* pItem, | |
62 CFX_RectF& rtItem) = 0; | |
63 virtual void* GetItemData(IFWL_Widget* pWidget, IFWL_ListItem* pItem) = 0; | |
64 virtual FWL_Error SetItemStyles(IFWL_Widget* pWidget, | |
65 IFWL_ListItem* pItem, | |
66 uint32_t dwStyle) = 0; | |
67 virtual FWL_Error SetItemText(IFWL_Widget* pWidget, | |
68 IFWL_ListItem* pItem, | |
69 const FX_WCHAR* pszText) = 0; | |
70 virtual FWL_Error SetItemRect(IFWL_Widget* pWidget, | |
71 IFWL_ListItem* pItem, | |
72 const CFX_RectF& rtItem) = 0; | |
73 virtual FX_FLOAT GetItemHeight(IFWL_Widget* pWidget) = 0; | |
74 virtual CFX_DIBitmap* GetItemIcon(IFWL_Widget* pWidget, | |
75 IFWL_ListItem* pItem) = 0; | |
76 virtual FWL_Error GetItemCheckRect(IFWL_Widget* pWidget, | |
77 IFWL_ListItem* pItem, | |
78 CFX_RectF& rtCheck) = 0; | |
79 virtual FWL_Error SetItemCheckRect(IFWL_Widget* pWidget, | |
80 IFWL_ListItem* pItem, | |
81 const CFX_RectF& rtCheck) = 0; | |
82 virtual uint32_t GetItemCheckState(IFWL_Widget* pWidget, | |
83 IFWL_ListItem* pItem) = 0; | |
84 virtual FWL_Error SetItemCheckState(IFWL_Widget* pWidget, | |
85 IFWL_ListItem* pItem, | |
86 uint32_t dwCheckState) = 0; | |
87 }; | |
88 | |
89 class IFWL_ListBoxCompare { | |
90 public: | |
91 virtual ~IFWL_ListBoxCompare() {} | |
92 virtual int32_t Compare(IFWL_ListItem* hLeft, IFWL_ListItem* hRight) = 0; | |
93 }; | |
94 | |
95 class IFWL_ListBox : public IFWL_Widget { | |
96 public: | |
97 static IFWL_ListBox* Create(const CFWL_WidgetImpProperties& properties, | |
98 IFWL_Widget* pOuter); | |
99 static IFWL_ListBox* CreateComboList( | |
100 const CFWL_WidgetImpProperties& properties, | |
101 IFWL_Widget* pOuter); | |
102 | |
103 int32_t CountSelItems(); | |
104 IFWL_ListItem* GetSelItem(int32_t nIndexSel); | |
105 int32_t GetSelIndex(int32_t nIndex); | |
106 FWL_Error SetSelItem(IFWL_ListItem* pItem, FX_BOOL bSelect = TRUE); | |
107 FWL_Error GetItemText(IFWL_ListItem* pItem, CFX_WideString& wsText); | |
108 FWL_Error GetScrollPos(FX_FLOAT& fPos, FX_BOOL bVert = TRUE); | |
109 | |
110 protected: | |
111 IFWL_ListBox(); | |
112 }; | |
113 | |
114 #endif // XFA_FWL_BASEWIDGET_IFWL_LISTBOX_H_ | |
OLD | NEW |