soui 5.0.0.1
Soui5 Doc
 
Loading...
Searching...
No Matches
SListView.h
1#ifndef __SLISTVIEW__H__
2#define __SLISTVIEW__H__
3
4#include <core/SPanel.h>
5#include <core/SItemPanel.h>
6#include <interface/SAdapter-i.h>
7#include <interface/SListViewItemLocator-i.h>
8#include <proxy/SPanelProxy.h>
9
10SNSBEGIN
11
12class SOUI_EXP SListView
13 : public TPanelProxy<IListView>
14 , protected SHostProxy
15 , protected IItemContainer {
16 DEF_SOBJECT(SPanel, L"listview")
17
18 friend class SListViewDataSetObserver;
19
20 public:
21 /**
22 * @brief Constructor
23 */
24 SListView();
25
26 /**
27 * @brief Destructor
28 */
29 ~SListView();
30
31 /**
32 * @brief Set the adapter for the list view
33 * @param adapter Pointer to the list view adapter
34 * @return TRUE if successful, FALSE otherwise
35 */
36 STDMETHOD_(BOOL, SetAdapter)(THIS_ ILvAdapter *adapter) OVERRIDE;
37
38 /**
39 * @brief Get the adapter for the list view
40 * @return Pointer to the list view adapter
41 */
42 STDMETHOD_(ILvAdapter *, GetAdapter)(THIS) SCONST OVERRIDE;
43
44 /**
45 * @brief Get the item locator for the list view
46 * @return Pointer to the item locator
47 */
48 STDMETHOD_(IListViewItemLocator *, GetItemLocator)(THIS) SCONST OVERRIDE;
49
50 /**
51 * @brief Set the item locator for the list view
52 * @param pItemLocator Pointer to the item locator
53 */
54 STDMETHOD_(void, SetItemLocator)(THIS_ IListViewItemLocator *pItemLocator) OVERRIDE;
55
56 /**
57 * @brief Ensure an item is visible
58 * @param iItem Index of the item to ensure visible
59 */
60 STDMETHOD_(void, EnsureVisible)(THIS_ int iItem) OVERRIDE;
61
62 /**
63 * @brief Set the selected item
64 * @param iItem Index of the item to select
65 * @param bNotify Whether to notify of the change
66 */
67 STDMETHOD_(void, SetSel)(THIS_ int iItem, BOOL bNotify = FALSE) OVERRIDE;
68
69 /**
70 * @brief Get the selected item
71 * @return Index of the selected item
72 */
73 STDMETHOD_(int, GetSel)(THIS) SCONST OVERRIDE;
74
75 /**
76 * @brief Hit test to determine the item under the mouse
77 * @param pt Pointer to the mouse coordinates
78 * @return Pointer to the item panel if found, NULL otherwise
79 */
80 STDMETHOD_(IItemPanel *, HitTest)(THIS_ const POINT *pt) SCONST OVERRIDE;
81
82 /**
83 * @brief Hit test to determine the item under the mouse
84 * @param pt Mouse coordinates
85 * @return Pointer to the item panel if found, NULL otherwise
86 */
87 SItemPanel *HitTest(CPoint &pt) const;
88
89 /**
90 * @brief Get the desired size of the control
91 * @param psz Output size
92 * @param nParentWid Parent container width
93 * @param nParentHei Parent container height
94 */
95 STDMETHOD_(void, GetDesiredSize)(THIS_ SIZE *psz, int nParentWid, int nParentHei) OVERRIDE;
96
97 protected:
98 /**
99 * @brief Handle item capture
100 * @param pItem Pointer to the item panel
101 * @param bCapture Capture flag
102 */
103 virtual void OnItemSetCapture(SOsrPanel *pItem, BOOL bCapture);
104
105 /**
106 * @brief Get the rectangle of an item
107 * @param pItem Pointer to the item panel
108 * @param rcItem Output rectangle
109 * @return TRUE if successful, FALSE otherwise
110 */
111 virtual BOOL OnItemGetRect(const SOsrPanel *pItem, CRect &rcItem) const;
112
113 /**
114 * @brief Check if item redraw is delayed
115 * @return TRUE if redraw is delayed, FALSE otherwise
116 */
117 virtual BOOL IsItemRedrawDelay() const;
118
119 protected:
120 /**
121 * @brief Handle data set changed event
122 */
123 void onDataSetChanged();
124
125 /**
126 * @brief Handle data set invalidated event
127 */
128 void onDataSetInvalidated();
129
130 /**
131 * @brief Handle item data changed event
132 * @param iItem Index of the item
133 */
134 void onItemDataChanged(int iItem);
135
136 protected:
137 /**
138 * @brief Handle item click event
139 * @param pEvt Event arguments
140 * @return TRUE if handled, FALSE otherwise
141 */
142 BOOL OnItemClick(IEvtArgs *pEvt);
143
144 protected:
145 /**
146 * @brief Handle scroll event
147 * @param bVertical Whether the scroll is vertical
148 * @param uCode Scroll type
149 * @param nPos Scroll position
150 * @return TRUE if handled, FALSE otherwise
151 */
152 virtual BOOL OnScroll(BOOL bVertical, UINT uCode, int nPos);
153
154 /**
155 * @brief Get the scroll line size
156 * @param bVertical Whether the scroll is vertical
157 * @return Scroll line size
158 */
159 virtual int GetScrollLineSize(BOOL bVertical);
160
161 /**
162 * @brief Create child items from XML configuration
163 * @param xmlNode XML node for the child items
164 * @return TRUE if successful, FALSE otherwise
165 */
166 virtual BOOL CreateChildren(SXmlNode xmlNode);
167
168 /**
169 * @brief Update tooltip information
170 * @param pt Mouse coordinates
171 * @param tipInfo Tooltip information
172 * @return TRUE if handled, FALSE otherwise
173 */
174 virtual BOOL UpdateToolTip(CPoint pt, SwndToolTipInfo &tipInfo);
175
176 /**
177 * @brief Get the dialog code
178 * @return Dialog code
179 */
180 virtual UINT WINAPI OnGetDlgCode() const;
181
182 /**
183 * @brief Handle set cursor event
184 * @param pt Mouse coordinates
185 * @return TRUE if handled, FALSE otherwise
186 */
187 virtual BOOL OnSetCursor(const CPoint &pt);
188
189 /**
190 * @brief Handle colorization event
191 * @param cr Color reference
192 */
193 virtual void OnColorize(COLORREF cr);
194
195 /**
196 * @brief Handle scale change event
197 * @param nScale Scale factor
198 */
199 virtual void OnScaleChanged(int nScale);
200
201 /**
202 * @brief Handle language change event
203 * @return HRESULT
204 */
205 virtual HRESULT OnLanguageChanged();
206
207 /**
208 * @brief Handle rebuild font event
209 */
210 virtual void OnRebuildFont();
211
212 protected:
213 /**
214 * @brief Dispatch messages to items
215 * @param uMsg Message identifier
216 * @param wParam Additional message-specific information
217 * @param lParam Additional message-specific information
218 */
219 void DispatchMessage2Items(UINT uMsg, WPARAM wParam, LPARAM lParam);
220
221 /**
222 * @brief Update the scroll bar
223 */
224 void UpdateScrollBar();
225
226 /**
227 * @brief Redraw a specific item
228 * @param pItem Pointer to the item panel
229 */
230 void RedrawItem(SOsrPanel *pItem);
231
232 /**
233 * @brief Get the item panel for a specific item
234 * @param iItem Index of the item
235 * @return Pointer to the item panel
236 */
237 SItemPanel *GetItemPanel(int iItem);
238
239 /**
240 * @brief Update visible items
241 */
242 void UpdateVisibleItems();
243
244 /**
245 * @brief Update a specific visible item
246 * @param iItem Index of the item
247 */
248 void UpdateVisibleItem(int iItem);
249
250 /**
251 * @brief Paint the control
252 * @param pRT Rendering target handle
253 */
254 void OnPaint(IRenderTarget *pRT);
255
256 /**
257 * @brief Handle size change event
258 * @param nType Size change type
259 * @param size New size
260 */
261 void OnSize(UINT nType, CSize size);
262
263 /**
264 * @brief Handle destroy event
265 */
266 void OnDestroy();
267
268 /**
269 * @brief Handle mouse event
270 * @param uMsg Message identifier
271 * @param wParam Additional message-specific information
272 * @param lParam Additional message-specific information
273 * @return Result of the message processing
274 */
275 LRESULT OnMouseEvent(UINT uMsg, WPARAM wParam, LPARAM lParam);
276
277 /**
278 * @brief Handle key event
279 * @param uMsg Message identifier
280 * @param wParam Additional message-specific information
281 * @param lParam Additional message-specific information
282 * @return Result of the message processing
283 */
284 LRESULT OnKeyEvent(UINT uMsg, WPARAM wParam, LPARAM lParam);
285
286 /**
287 * @brief Handle key down event
288 * @param nChar Key code
289 * @param nRepCnt Repeat count
290 * @param nFlags Flags
291 */
292 void OnKeyDown(TCHAR nChar, UINT nRepCnt, UINT nFlags);
293
294 /**
295 * @brief Handle mouse leave event
296 */
297 void OnMouseLeave();
298
299 /**
300 * @brief Handle mouse wheel event
301 * @param nFlags Flags
302 * @param zDelta Delta value
303 * @param pt Mouse coordinates
304 * @return TRUE if handled, FALSE otherwise
305 */
306 BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);
307
308 /**
309 * @brief Handle kill focus event
310 * @param wndFocus New focus window handle
311 */
312 void OnKillFocus(SWND wndFocus);
313
314 /**
315 * @brief Handle set focus event
316 * @param wndOld Previous focus window handle
317 */
318 void OnSetFocus(SWND wndOld);
319
320 /**
321 * @brief Handle show window event
322 * @param bShow Show flag
323 * @param nStatus Status code
324 */
325 void OnShowWindow(BOOL bShow, UINT nStatus);
326
327 SOUI_MSG_MAP_BEGIN()
328 MSG_WM_PAINT_EX(OnPaint)
329 MSG_WM_SIZE(OnSize)
330 MSG_WM_DESTROY(OnDestroy)
331 MSG_WM_MOUSEWHEEL(OnMouseWheel)
332 MSG_WM_MOUSELEAVE(OnMouseLeave)
333 MSG_WM_KEYDOWN(OnKeyDown)
334 MSG_WM_KILLFOCUS_EX(OnKillFocus)
335 MSG_WM_SETFOCUS_EX(OnSetFocus)
336 MSG_WM_SHOWWINDOW(OnShowWindow)
337 MESSAGE_RANGE_HANDLER_EX(WM_MOUSEFIRST, WM_MOUSELAST, OnMouseEvent)
338 MESSAGE_RANGE_HANDLER_EX(WM_KEYFIRST, WM_KEYLAST, OnKeyEvent)
339 MESSAGE_RANGE_HANDLER_EX(WM_IME_STARTCOMPOSITION, WM_IME_KEYLAST, OnKeyEvent)
340 MESSAGE_HANDLER_EX(WM_IME_CHAR, OnKeyEvent)
341 MESSAGE_HANDLER_EX(WM_IME_REQUEST, OnKeyEvent)
342 SOUI_MSG_MAP_END()
343
344 SOUI_ATTRS_BEGIN()
345 ATTR_SKIN(L"dividerSkin", m_pSkinDivider, TRUE)
346 ATTR_LAYOUTSIZE(L"dividerSize", m_nDividerSize, FALSE)
347 ATTR_BOOL(L"wantTab", m_bWantTab, FALSE)
348 ATTR_BOOL(L"vertical", m_bVertical, FALSE)
349 SOUI_ATTRS_END()
350
351 protected:
352 SAutoRefPtr<ILvAdapter> m_adapter; /**< Pointer to the list view adapter */
353 SAutoRefPtr<ILvDataSetObserver> m_observer; /**< Pointer to the data set observer */
354 SAutoRefPtr<IListViewItemLocator> m_lvItemLocator; /**< Pointer to the item locator */
355
356 struct ItemInfo
357 {
358 SItemPanel *pItem; /**< Pointer to the item panel */
359 int nType; /**< Type of the item */
360 };
361
362 bool m_bPendingUpdate; /**< Flag indicating pending update */
363 int m_iPendingUpdateItem; /**< Index of the item to update, -1 for all, -2 for nothing */
364 int m_iPendingViewItem; /**< Index of the item to view, -1 for init */
365
366 int m_iFirstVisible; /**< Index of the first visible item */
367 SList<ItemInfo> m_lstItems; /**< List of currently visible items */
368 SOsrPanel *m_itemCapture; /**< Item panel that has been set capture */
369
370 int m_iSelItem; /**< Index of the selected item */
371 SOsrPanel *m_pHoverItem; /**< Item panel under the mouse */
372 BOOL m_bDataSetInvalidated; /**< Flag indicating data set is invalidated */
373
374 SArray<SList<SItemPanel *> *> m_itemRecycle; /**< Recycle bin for item panels */
375
376 SXmlDoc m_xmlTemplate; /**< XML template for items */
377 SAutoRefPtr<ISkinObj> m_pSkinDivider; /**< Skin for dividers */
378 SLayoutSize m_nDividerSize; /**< Size of dividers */
379 BOOL m_bWantTab; /**< Flag indicating whether to want tab */
380 BOOL m_bVertical; /**< Flag indicating vertical orientation */
381};
382
383SNSEND
384
385#endif // __SLISTVIEW__H__
SOUI Panel with Scrollbar Support.
virtual int GetScrollLineSize(BOOL bVertical)
Gets the line size for scrolling.
Definition SPanel.cpp:616
virtual void OnColorize(COLORREF cr)
Handles colorization events.
Definition SPanel.cpp:631
virtual void OnScaleChanged(int nScale)
Handles scale change events.
Definition SPanel.cpp:638
void OnShowWindow(BOOL bShow, UINT nStatus)
Handles the WM_SHOWWINDOW message.
Definition SPanel.cpp:589
BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt)
Handles the WM_MOUSEWHEEL message.
Definition SPanel.cpp:484
virtual BOOL OnScroll(BOOL bVertical, UINT uCode, int nPos)
Handles scroll events.
Definition SPanel.cpp:517
void OnDestroy()
Handles the WM_DESTROY message.
Definition SPanel.cpp:326
UINT OnGetDlgCode() SCONST OVERRIDE
Retrieves the dialog code for the window.
Definition Swnd.cpp:1991
virtual BOOL UpdateToolTip(CPoint pt, SwndToolTipInfo &tipInfo)
Handle tooltip updates.
Definition Swnd.cpp:277
void OnKillFocus(SWND wndFocus)
Handles losing focus.
Definition Swnd.cpp:2274
void OnPaint(IRenderTarget *pRT)
Handles the painting of the window.
Definition Swnd.cpp:1785
void OnMouseLeave()
Handles the mouse leave event.
Definition Swnd.cpp:2147
virtual HRESULT OnLanguageChanged()
Called when the language of the window changes.
Definition Swnd.cpp:3229
void OnSize(UINT nType, CSize size)
Handles the resizing of the window.
Definition Swnd.cpp:2844
virtual void OnRebuildFont()
Called when the font of the window needs to be rebuilt.
Definition Swnd.cpp:3303
virtual BOOL OnSetCursor(const CPoint &pt)
Sets the cursor when the mouse hovers over the window.
Definition Swnd.cpp:429
virtual BOOL CreateChildren(SXmlNode xmlNode)
Create child windows from XML node.
Definition Swnd.cpp:823
void OnSetFocus(SWND wndOld)
Handles gaining focus.
Definition Swnd.cpp:2265