Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(51)

Side by Side Diff: xfa/fwl/core/ifwl_listbox.h

Issue 2432423002: Merge the CFWL_*Imp classes into the IFWL_* classes. (Closed)
Patch Set: Review feedback Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « xfa/fwl/core/ifwl_formproxy.cpp ('k') | xfa/fwl/core/ifwl_listbox.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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_CORE_IFWL_LISTBOX_H_
8 #define XFA_FWL_CORE_IFWL_LISTBOX_H_
9
10 #include <memory>
11
12 #include "xfa/fwl/core/cfwl_event.h"
13 #include "xfa/fwl/core/cfwl_widgetimpproperties.h"
14 #include "xfa/fwl/core/ifwl_dataprovider.h"
15 #include "xfa/fwl/core/ifwl_edit.h"
16 #include "xfa/fwl/core/ifwl_listbox.h"
17 #include "xfa/fwl/core/ifwl_widget.h"
18
19 #define FWL_CLASS_ListBox L"FWL_LISTBOX"
20 #define FWL_STYLEEXT_LTB_MultiSelection (1L << 0)
21 #define FWL_STYLEEXT_LTB_ShowScrollBarAlaways (1L << 2)
22 #define FWL_STYLEEXT_LTB_MultiColumn (1L << 3)
23 #define FWL_STYLEEXT_LTB_LeftAlign (0L << 4)
24 #define FWL_STYLEEXT_LTB_CenterAlign (1L << 4)
25 #define FWL_STYLEEXT_LTB_RightAlign (2L << 4)
26 #define FWL_STYLEEXT_LTB_MultiLine (1L << 6)
27 #define FWL_STYLEEXT_LTB_OwnerDraw (1L << 7)
28 #define FWL_STYLEEXT_LTB_Icon (1L << 8)
29 #define FWL_STYLEEXT_LTB_Check (1L << 9)
30 #define FWL_STYLEEXT_LTB_AlignMask (3L << 4)
31 #define FWL_STYLEEXT_LTB_ShowScrollBarFocus (1L << 10)
32 #define FWL_ITEMSTATE_LTB_Selected (1L << 0)
33 #define FWL_ITEMSTATE_LTB_Focused (1L << 1)
34 #define FWL_ITEMSTATE_LTB_Checked (1L << 2)
35
36 class CFWL_ListBoxImpDelegate;
37 class CFWL_MsgKillFocus;
38 class CFWL_MsgMouse;
39 class CFWL_MsgMouseWheel;
40 class CFX_DIBitmap;
41
42 FWL_EVENT_DEF(CFWL_EvtLtbSelChanged,
43 CFWL_EventType::SelectChanged,
44 CFX_Int32Array iarraySels;)
45
46 FWL_EVENT_DEF(CFWL_EvtLtbDrawItem,
47 CFWL_EventType::DrawItem,
48 CFX_Graphics* m_pGraphics;
49 CFX_Matrix m_matrix;
50 int32_t m_index;
51 CFX_RectF m_rect;)
52
53 class IFWL_ListItem {};
54
55 class IFWL_ListBoxDP : public IFWL_DataProvider {
56 public:
57 virtual int32_t CountItems(const IFWL_Widget* pWidget) = 0;
58 virtual IFWL_ListItem* GetItem(const IFWL_Widget* pWidget,
59 int32_t nIndex) = 0;
60 virtual int32_t GetItemIndex(IFWL_Widget* pWidget, IFWL_ListItem* pItem) = 0;
61 virtual FX_BOOL SetItemIndex(IFWL_Widget* pWidget,
62 IFWL_ListItem* pItem,
63 int32_t nIndex) = 0;
64 virtual uint32_t GetItemStyles(IFWL_Widget* pWidget,
65 IFWL_ListItem* pItem) = 0;
66 virtual FWL_Error GetItemText(IFWL_Widget* pWidget,
67 IFWL_ListItem* pItem,
68 CFX_WideString& wsText) = 0;
69 virtual FWL_Error GetItemRect(IFWL_Widget* pWidget,
70 IFWL_ListItem* pItem,
71 CFX_RectF& rtItem) = 0;
72 virtual void* GetItemData(IFWL_Widget* pWidget, IFWL_ListItem* pItem) = 0;
73 virtual FWL_Error SetItemStyles(IFWL_Widget* pWidget,
74 IFWL_ListItem* pItem,
75 uint32_t dwStyle) = 0;
76 virtual FWL_Error SetItemText(IFWL_Widget* pWidget,
77 IFWL_ListItem* pItem,
78 const FX_WCHAR* pszText) = 0;
79 virtual FWL_Error SetItemRect(IFWL_Widget* pWidget,
80 IFWL_ListItem* pItem,
81 const CFX_RectF& rtItem) = 0;
82 virtual FX_FLOAT GetItemHeight(IFWL_Widget* pWidget) = 0;
83 virtual CFX_DIBitmap* GetItemIcon(IFWL_Widget* pWidget,
84 IFWL_ListItem* pItem) = 0;
85 virtual FWL_Error GetItemCheckRect(IFWL_Widget* pWidget,
86 IFWL_ListItem* pItem,
87 CFX_RectF& rtCheck) = 0;
88 virtual FWL_Error SetItemCheckRect(IFWL_Widget* pWidget,
89 IFWL_ListItem* pItem,
90 const CFX_RectF& rtCheck) = 0;
91 virtual uint32_t GetItemCheckState(IFWL_Widget* pWidget,
92 IFWL_ListItem* pItem) = 0;
93 virtual FWL_Error SetItemCheckState(IFWL_Widget* pWidget,
94 IFWL_ListItem* pItem,
95 uint32_t dwCheckState) = 0;
96 };
97
98 class IFWL_ListBoxCompare {
99 public:
100 virtual ~IFWL_ListBoxCompare() {}
101 virtual int32_t Compare(IFWL_ListItem* hLeft, IFWL_ListItem* hRight) = 0;
102 };
103
104 class IFWL_ListBox : public IFWL_Widget {
105 public:
106 static IFWL_ListBox* Create(const CFWL_WidgetImpProperties& properties,
107 IFWL_Widget* pOuter);
108
109 IFWL_ListBox(const CFWL_WidgetImpProperties& properties, IFWL_Widget* pOuter);
110 ~IFWL_ListBox() override;
111
112 // IFWL_Widget
113 FWL_Error GetClassName(CFX_WideString& wsClass) const override;
114 FWL_Type GetClassID() const override;
115 FWL_Error Initialize() override;
116 FWL_Error Finalize() override;
117 FWL_Error GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE) override;
118 FWL_Error Update() override;
119 FWL_WidgetHit HitTest(FX_FLOAT fx, FX_FLOAT fy) override;
120 FWL_Error DrawWidget(CFX_Graphics* pGraphics,
121 const CFX_Matrix* pMatrix = nullptr) override;
122 FWL_Error SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) override;
123
124 int32_t CountSelItems();
125 IFWL_ListItem* GetSelItem(int32_t nIndexSel);
126 int32_t GetSelIndex(int32_t nIndex);
127 FWL_Error SetSelItem(IFWL_ListItem* hItem, FX_BOOL bSelect = TRUE);
128 FWL_Error GetItemText(IFWL_ListItem* hItem, CFX_WideString& wsText);
129 FWL_Error GetScrollPos(FX_FLOAT& fPos, FX_BOOL bVert = TRUE);
130 FWL_Error* Sort(IFWL_ListBoxCompare* pCom);
131
132 protected:
133 friend class CFWL_ListBoxImpDelegate;
134
135 IFWL_ListItem* GetItem(IFWL_ListItem* hItem, uint32_t dwKeyCode);
136 void SetSelection(IFWL_ListItem* hStart,
137 IFWL_ListItem* hEnd,
138 FX_BOOL bSelected);
139 void SetSelectionDirect(IFWL_ListItem* hItem, FX_BOOL bSelect);
140 FX_BOOL IsItemSelected(IFWL_ListItem* hItem);
141 void ClearSelection();
142 void SelectAll();
143 IFWL_ListItem* GetFocusedItem();
144 void SetFocusItem(IFWL_ListItem* hItem);
145 IFWL_ListItem* GetItemAtPoint(FX_FLOAT fx, FX_FLOAT fy);
146 FX_BOOL GetItemCheckRect(IFWL_ListItem* hItem, CFX_RectF& rtCheck);
147 FX_BOOL SetItemChecked(IFWL_ListItem* hItem, FX_BOOL bChecked);
148 FX_BOOL GetItemChecked(IFWL_ListItem* hItem);
149 FX_BOOL ScrollToVisible(IFWL_ListItem* hItem);
150 void DrawBkground(CFX_Graphics* pGraphics,
151 IFWL_ThemeProvider* pTheme,
152 const CFX_Matrix* pMatrix = nullptr);
153 void DrawItems(CFX_Graphics* pGraphics,
154 IFWL_ThemeProvider* pTheme,
155 const CFX_Matrix* pMatrix = nullptr);
156 void DrawItem(CFX_Graphics* pGraphics,
157 IFWL_ThemeProvider* pTheme,
158 IFWL_ListItem* hItem,
159 int32_t Index,
160 const CFX_RectF& rtItem,
161 const CFX_Matrix* pMatrix = nullptr);
162 void DrawStatic(CFX_Graphics* pGraphics, IFWL_ThemeProvider* pTheme);
163 CFX_SizeF CalcSize(FX_BOOL bAutoSize = FALSE);
164 void GetItemSize(CFX_SizeF& size,
165 IFWL_ListItem* hItem,
166 FX_FLOAT fWidth,
167 FX_FLOAT fHeight,
168 FX_BOOL bAutoSize = FALSE);
169 FX_FLOAT GetMaxTextWidth();
170 FX_FLOAT GetScrollWidth();
171 FX_FLOAT GetItemHeigt();
172 void InitScrollBar(FX_BOOL bVert = TRUE);
173 FX_BOOL IsShowScrollBar(FX_BOOL bVert);
174 void ProcessSelChanged();
175
176 CFX_RectF m_rtClient;
177 CFX_RectF m_rtStatic;
178 CFX_RectF m_rtConent;
179 std::unique_ptr<IFWL_ScrollBar> m_pHorzScrollBar;
180 std::unique_ptr<IFWL_ScrollBar> m_pVertScrollBar;
181 uint32_t m_dwTTOStyles;
182 int32_t m_iTTOAligns;
183 IFWL_ListItem* m_hAnchor;
184 FX_FLOAT m_fItemHeight;
185 FX_FLOAT m_fScorllBarWidth;
186 FX_BOOL m_bLButtonDown;
187 IFWL_ThemeProvider* m_pScrollBarTP;
188 };
189
190 class CFWL_ListBoxImpDelegate : public CFWL_WidgetImpDelegate {
191 public:
192 CFWL_ListBoxImpDelegate(IFWL_ListBox* pOwner);
193 void OnProcessMessage(CFWL_Message* pMessage) override;
194 void OnProcessEvent(CFWL_Event* pEvent) override;
195 void OnDrawWidget(CFX_Graphics* pGraphics,
196 const CFX_Matrix* pMatrix = nullptr) override;
197
198 protected:
199 void OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet = TRUE);
200 void OnLButtonDown(CFWL_MsgMouse* pMsg);
201 void OnLButtonUp(CFWL_MsgMouse* pMsg);
202 void OnMouseWheel(CFWL_MsgMouseWheel* pMsg);
203 void OnKeyDown(CFWL_MsgKey* pMsg);
204 void OnVK(IFWL_ListItem* hItem, FX_BOOL bShift, FX_BOOL bCtrl);
205 FX_BOOL OnScroll(IFWL_ScrollBar* pScrollBar, uint32_t dwCode, FX_FLOAT fPos);
206 void DispatchSelChangedEv();
207 IFWL_ListBox* m_pOwner;
208 };
209
210 #endif // XFA_FWL_CORE_IFWL_LISTBOX_H_
OLDNEW
« no previous file with comments | « xfa/fwl/core/ifwl_formproxy.cpp ('k') | xfa/fwl/core/ifwl_listbox.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698