Merge to XFA: Use stdint.h types throughout PDFium.
[pdfium.git] / xfa / include / fwl / basewidget / fwl_listbox.h
1 // Copyright 2014 PDFium Authors. All rights reserved.\r
2 // Use of this source code is governed by a BSD-style license that can be\r
3 // found in the LICENSE file.\r
4 \r
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com\r
6 \r
7 #ifndef _FWL_LISTBOX_H\r
8 #define _FWL_LISTBOX_H\r
9 class CFWL_WidgetImpProperties;\r
10 class IFWL_Widget;\r
11 class IFWL_ListBoxDP;\r
12 class IFWL_ListBox;\r
13 #define FWL_CLASS_ListBox                       L"FWL_LISTBOX"\r
14 #define FWL_CLASSHASH_ListBox           1777358317\r
15 #define FWL_STYLEEXT_LTB_MultiSelection                 (1L << 0)\r
16 #define FWL_STYLEEXT_LTB_Sort                                   (1L << 1)\r
17 #define FWL_STYLEEXT_LTB_ShowScrollBarAlaways   (1L << 2)\r
18 #define FWL_STYLEEXT_LTB_MultiColumn                    (1L << 3)\r
19 #define FWL_STYLEEXT_LTB_LeftAlign                              (0L << 4)\r
20 #define FWL_STYLEEXT_LTB_CenterAlign                    (1L << 4)\r
21 #define FWL_STYLEEXT_LTB_RightAlign                             (2L << 4)\r
22 #define FWL_STYLEEXT_LTB_MultiLine                              (1L << 6)\r
23 #define FWL_STYLEEXT_LTB_OwnerDraw                              (1L << 7)\r
24 #define FWL_STYLEEXT_LTB_Icon                   (1L << 8)\r
25 #define FWL_STYLEEXT_LTB_Check                  (1L << 9)\r
26 #define FWL_STYLEEXT_LTB_AlignMask                              (3L << 4)\r
27 #define FWL_STYLEEXT_LTB_ShowScrollBarFocus             (1L << 10)\r
28 #define FWL_ITEMSTATE_LTB_Selected                      (1L << 0)\r
29 #define FWL_ITEMSTATE_LTB_Focused                       (1L << 1)\r
30 #define FWL_ITEMSTATE_LTB_Checked                       (1L << 2)\r
31 #define FWL_PART_LTB_Border                                     1\r
32 #define FWL_PART_LTB_Edge                                       2\r
33 #define FWL_PART_LTB_Background                         3\r
34 #define FWL_PART_LTB_ListItem                           4\r
35 #define FWL_PART_LTB_Check                              5\r
36 #define FWL_PART_LTB_Icon                               6\r
37 #define FWL_PARTSTATE_LTB_Normal                        (0L << 0)\r
38 #define FWL_PARTSTATE_LTB_Selected                      (1L << 0)\r
39 #define FWL_PARTSTATE_LTB_Disabled                      (2L << 0)\r
40 #define FWL_PARTSTATE_LTB_Focused                       (1L << 2)\r
41 #define FWL_PARTSTATE_LTB_UnChecked                     (0L << 3)\r
42 #define FWL_PARTSTATE_LTB_Checked                       (1L << 3)\r
43 #define FWL_PARTSTATE_LTB_Mask                          (3L << 0)\r
44 #define FWL_WGTHITTEST_LTB_Item                         FWL_WGTHITTEST_MAX + 1\r
45 #define FWL_WGTHITTEST_LTB_HScrollBar           FWL_WGTHITTEST_MAX + 2\r
46 #define FWL_WGTHITTEST_LTB_VScrollBar           FWL_WGTHITTEST_MAX + 3\r
47 #define FWL_EVT_LTB_SelChanged                          L"FWL_EVENT_LTB_SelChanged"\r
48 #define FWL_EVT_LTB_DrawItem                            L"FWL_EVENT_LTB_DrawItem"\r
49 #define FWL_EVTHASH_LTB_SelChanged                      1701781688\r
50 #define FWL_EVTHASH_LTB_DrawItem                        1050853991\r
51 BEGIN_FWL_EVENT_DEF(CFWL_EvtLtbSelChanged, FWL_EVTHASH_LTB_SelChanged)\r
52 CFX_Int32Array iarraySels;\r
53 END_FWL_EVENT_DEF\r
54 BEGIN_FWL_EVENT_DEF(CFWL_EvtLtbDrawItem, FWL_EVTHASH_LTB_DrawItem)\r
55 CFX_Graphics *m_pGraphics;\r
56 CFX_Matrix m_matrix;\r
57 int32_t m_index;\r
58 CFX_RectF m_rect;\r
59 END_FWL_EVENT_DEF\r
60 typedef struct _FWL_HLISTITEM {\r
61     FX_LPVOID pData;\r
62 }* FWL_HLISTITEM;\r
63 typedef struct _FWL_ListBoxItemData {\r
64     IFWL_ListBoxDP *pDataProvider;\r
65     int32_t iIndex;\r
66 } FWL_ListBoxItemData;\r
67 class IFWL_ListBoxDP : public IFWL_DataProvider\r
68 {\r
69 public:\r
70     virtual     int32_t                 CountItems(IFWL_Widget *pWidget) = 0;\r
71     virtual     FWL_HLISTITEM           GetItem(IFWL_Widget *pWidget, int32_t nIndex) = 0;\r
72     virtual     int32_t                 GetItemIndex(IFWL_Widget *pWidget, FWL_HLISTITEM hItem) = 0;\r
73     virtual FX_BOOL                             SetItemIndex(IFWL_Widget *pWidget, FWL_HLISTITEM hItem, int32_t nIndex) = 0;\r
74     virtual     FX_DWORD                        GetItemStyles(IFWL_Widget *pWidget, FWL_HLISTITEM hItem) = 0;\r
75     virtual     FWL_ERR                         GetItemText(IFWL_Widget *pWidget, FWL_HLISTITEM hItem, CFX_WideString &wsText) = 0;\r
76     virtual FWL_ERR                             GetItemRect(IFWL_Widget *pWidget, FWL_HLISTITEM hItem, CFX_RectF &rtItem) = 0;\r
77     virtual FX_LPVOID                   GetItemData(IFWL_Widget *pWidget, FWL_HLISTITEM hItem) = 0;\r
78     virtual     FWL_ERR                         SetItemStyles(IFWL_Widget *pWidget, FWL_HLISTITEM hItem, FX_DWORD dwStyle) = 0;\r
79     virtual FWL_ERR                             SetItemText(IFWL_Widget *pWidget, FWL_HLISTITEM hItem, FX_LPCWSTR pszText) = 0;\r
80     virtual FWL_ERR                             SetItemRect(IFWL_Widget *pWidget, FWL_HLISTITEM hItem, const CFX_RectF &rtItem) = 0;\r
81     virtual FX_FLOAT                    GetItemHeight(IFWL_Widget *pWidget) = 0;\r
82     virtual CFX_DIBitmap*               GetItemIcon(IFWL_Widget *pWidget, FWL_HLISTITEM hItem) = 0;\r
83     virtual FWL_ERR                             GetItemCheckRect(IFWL_Widget *pWidget, FWL_HLISTITEM hItem, CFX_RectF& rtCheck) = 0;\r
84     virtual FWL_ERR                             SetItemCheckRect(IFWL_Widget *pWidget, FWL_HLISTITEM hItem, const CFX_RectF& rtCheck) = 0;\r
85     virtual     FX_DWORD                        GetItemCheckState(IFWL_Widget *pWidget, FWL_HLISTITEM hItem) = 0;\r
86     virtual     FWL_ERR                         SetItemCheckState(IFWL_Widget *pWidget, FWL_HLISTITEM hItem, FX_DWORD dwCheckState) = 0;\r
87 };\r
88 class IFWL_ListBoxCompare\r
89 {\r
90 public:\r
91     virtual int32_t Compare(FWL_HLISTITEM hLeft, FWL_HLISTITEM hRight) = 0;\r
92 };\r
93 class IFWL_ListBox : public IFWL_Widget\r
94 {\r
95 public:\r
96     static IFWL_ListBox* Create();\r
97     FWL_ERR                     Initialize(IFWL_Widget *pOuter = NULL);\r
98     FWL_ERR                     Initialize(const CFWL_WidgetImpProperties &properties, IFWL_Widget *pOuter = NULL);\r
99     int32_t             CountSelItems();\r
100     FWL_HLISTITEM       GetSelItem(int32_t nIndexSel);\r
101     int32_t             GetSelIndex(int32_t nIndex);\r
102     FWL_ERR                     SetSelItem(FWL_HLISTITEM hItem, FX_BOOL bSelect = TRUE);\r
103     FWL_ERR                     GetItemText(FWL_HLISTITEM hItem, CFX_WideString &wsText);\r
104     FWL_ERR                     GetScrollPos(FX_FLOAT &fPos, FX_BOOL bVert = TRUE);\r
105     FWL_ERR*            Sort(IFWL_ListBoxCompare *pCom);\r
106 protected:\r
107     IFWL_ListBox();\r
108     virtual ~IFWL_ListBox();\r
109 };\r
110 #endif\r