soui 5.0.0.1
Soui5 Doc
 
Loading...
Searching...
No Matches
SListbox.cpp
1//////////////////////////////////////////////////////////////////////////
2// Class Name: SListBox
3// Description: A DuiWindow Based ListBox Control.
4// Creator: JinHui
5// Version: 2012.12.18 - 1.0 - Create
6//////////////////////////////////////////////////////////////////////////
7#include "souistd.h"
8#include <control/SListbox.h>
9
10#pragma warning(disable : 4018)
11#pragma warning(disable : 4267)
12
13SNSBEGIN
14
16 : m_itemHeight(20.f, SLayoutSize::dp)
17 , m_iSelItem(-1)
18 , m_iHoverItem(-1)
19 , m_crItemBg(CR_INVALID)
20 , m_crItemBg2(CR_INVALID)
21 , m_crItemSelBg(RGBA(57, 145, 209, 255))
22 , m_crItemHotBg(RGBA(57, 145, 209, 128))
23 , m_crText(CR_INVALID)
24 , m_crSelText(CR_INVALID)
25 , m_pItemSkin(NULL)
26 , m_pIconSkin(NULL)
27 , m_bHotTrack(FALSE)
28{
29 m_bFocusable = TRUE;
30 m_bClipClient = TRUE;
31 m_ptIcon[0].fSize = m_ptIcon[1].fSize = SIZE_UNDEF;
32 m_ptText[0].fSize = m_ptText[1].fSize = SIZE_UNDEF;
33 m_evtSet.addEvent(EVENTID(EventLBSelChanging));
34 m_evtSet.addEvent(EVENTID(EventLBSelChanged));
35 m_evtSet.addEvent(EVENTID(EventLBDbClick));
36}
37
41
43{
44 return m_arrItems.GetCount();
45}
46
48{
49 return m_iSelItem;
50}
51
52BOOL SListBox::SetCurSel(int nIndex, BOOL bNotifyChange)
53{
54 if (nIndex >= GetCount())
55 return FALSE;
56
57 if (nIndex < 0)
58 nIndex = -1;
59
60 if (m_iSelItem == nIndex)
61 return 0;
62 int nOldSelItem = m_iSelItem;
63 m_iSelItem = nIndex;
64
65 if (IsVisible(TRUE))
66 {
67 if (nOldSelItem != -1)
68 RedrawItem(nOldSelItem);
69 if (m_iSelItem != -1)
71 }
72 if (bNotifyChange)
73 {
74 NotifySelChange(nOldSelItem, nIndex);
75 }
76 return TRUE;
77}
78
80{
81 return m_siVer.nPos / m_itemHeight.toPixelSize(GetScale());
82}
83
84BOOL SListBox::SetTopIndex(int nIndex)
85{
86 if (nIndex < 0 || nIndex >= GetCount())
87 return FALSE;
88
89 OnScroll(TRUE, SB_THUMBPOSITION, nIndex * m_itemHeight.toPixelSize(GetScale()));
90 return TRUE;
91}
92
93LPARAM SListBox::GetItemData(int nIndex) const
94{
95 if (nIndex < 0 || nIndex >= GetCount())
96 return 0;
97
98 return m_arrItems[nIndex]->lParam;
99}
100
101BOOL SListBox::SetItemData(int nIndex, LPARAM lParam)
102{
103 if (nIndex < 0 || nIndex >= GetCount())
104 return FALSE;
105
106 m_arrItems[nIndex]->lParam = lParam;
107 return TRUE;
108}
109
110BOOL SListBox::SetItemImage(THIS_ int nIndex, int iImage)
111{
112 if (nIndex < 0 || nIndex >= GetCount())
113 return FALSE;
114
115 m_arrItems[nIndex]->nImage = iImage;
116 return TRUE;
117}
118
119int SListBox::GetItemImage(THIS_ int nIndex)
120{
121 if (nIndex < 0 || nIndex >= GetCount())
122 return -1;
123
124 return m_arrItems[nIndex]->nImage;
125}
126
127BOOL SListBox::GetIText(int nIndex, BOOL bRawText, IStringT *str) const
128{
129 if (nIndex < 0 || nIndex >= GetCount())
130 return FALSE;
131
132 SStringT strRet = m_arrItems[nIndex]->strText.GetText(bRawText);
133 str->Copy(&strRet);
134 return TRUE;
135}
136
138{
139 return m_itemHeight.toPixelSize(GetScale());
140}
141
142void SListBox::SetItemHeight(int cyItemHeight)
143{
144 m_itemHeight = SLayoutSize((float)cyItemHeight, SLayoutSize::px);
146}
147
149{
150 for (int i = 0; i < GetCount(); i++)
151 {
152 if (m_arrItems[i])
153 delete m_arrItems[i];
154 }
155 m_arrItems.RemoveAll();
156
157 m_iSelItem = -1;
158 m_iHoverItem = -1;
159
160 Invalidate();
162}
163
165{
166 if (nIndex < 0 || nIndex >= GetCount())
167 return FALSE;
168
169 if (m_arrItems[nIndex])
170 delete m_arrItems[nIndex];
171 m_arrItems.RemoveAt(nIndex);
172
173 if (m_iSelItem == nIndex)
174 m_iSelItem = -1;
175 else if (m_iSelItem > nIndex)
176 m_iSelItem--;
177 if (m_iHoverItem == nIndex)
178 m_iHoverItem = -1;
179 else if (m_iHoverItem > nIndex)
180 m_iHoverItem--;
181
183
184 return TRUE;
185}
186
187int SListBox::AddString(LPCTSTR lpszItem, int nImage, LPARAM lParam)
188{
189 return InsertString(-1, lpszItem, nImage, lParam);
190}
191
192int SListBox::InsertString(int nIndex, LPCTSTR lpszItem, int nImage, LPARAM lParam)
193{
194 // SASSERT(lpszItem);
195
196 LPLBITEM pItem = new LBITEM(this);
197 pItem->strText.SetText(lpszItem, false);
198 pItem->nImage = nImage;
199 pItem->lParam = lParam;
200
201 return InsertItem(nIndex, pItem);
202}
203
205{
206 if (nIndex < 0 || nIndex >= GetCount())
207 return;
208
209 CRect rcClient;
210 GetClientRect(&rcClient);
211
212 int nItemHei = m_itemHeight.toPixelSize(GetScale());
213 int iFirstVisible = (m_siVer.nPos + nItemHei - 1) / nItemHei;
214 int nVisibleItems = rcClient.Height() / nItemHei;
215 if (nIndex < iFirstVisible || nIndex > iFirstVisible + nVisibleItems - 1)
216 {
217 int nOffset = GetScrollPos(TRUE);
218 if (nIndex < iFirstVisible)
219 nOffset = (nIndex - iFirstVisible) * nItemHei;
220 else
221 nOffset = (nIndex - iFirstVisible - nVisibleItems + 1) * nItemHei;
222 nOffset -= nOffset % nItemHei; //让当前行刚好显示
223 OnScroll(TRUE, SB_THUMBPOSITION, nOffset + GetScrollPos(TRUE));
224 }
225}
226
227//自动修改pt的位置为相对当前项的偏移量
228int SListBox::HitTest(CPoint &pt)
229{
230 CRect rcClient;
231 GetClientRect(&rcClient);
232 if (!rcClient.PtInRect(pt))
233 return -1;
234
235 CPoint pt2 = pt;
236 pt2.y -= rcClient.top - m_siVer.nPos;
237 int nItemHei = m_itemHeight.toPixelSize(GetScale());
238 int nRet = pt2.y / nItemHei;
239 if (nRet >= GetCount())
240 nRet = -1;
241 else
242 {
243 pt.x -= rcClient.left;
244 pt.y = pt2.y % nItemHei;
245 }
246
247 return nRet;
248}
249
250int SListBox::FindString(int iFindAfter, LPCTSTR pszText) const
251{
252 if (iFindAfter < 0)
253 iFindAfter = -1;
254 int iStart = iFindAfter + 1;
255 for (int i = 0; i < m_arrItems.GetCount(); i++)
256 {
257 int iTarget = (i + iStart) % m_arrItems.GetCount();
258 if (m_arrItems[iTarget]->strText.GetText(TRUE).StartsWith(pszText))
259 return iTarget;
260 }
261 return -1;
262}
263
265{
266 if (!xmlNode)
267 return TRUE;
268
269 SXmlNode xmlItems = xmlNode.child(L"items");
270 if (xmlItems)
271 {
272 SXmlNode xmlItem = xmlItems.child(L"item");
273 while (xmlItem)
274 {
275 LPLBITEM pItemObj = new LBITEM(this);
276 LoadItemAttribute(xmlItem, pItemObj);
277 InsertItem(-1, pItemObj);
278 xmlItem = xmlItem.next_sibling();
279 }
280 }
281
282 int nSelItem = xmlNode.attribute(L"curSel").as_int(-1);
283 SetCurSel(nSelItem);
284
285 return TRUE;
286}
287
288void SListBox::LoadItemAttribute(SXmlNode xmlNode, LPLBITEM pItem)
289{
290 pItem->nImage = xmlNode.attribute(L"icon").as_int(pItem->nImage);
291 pItem->lParam = xmlNode.attribute(L"data").as_uint((UINT)pItem->lParam);
292 SStringW strText = GETSTRING(xmlNode.attribute(L"text").value());
293 if (strText.IsEmpty())
294 strText = GetXmlText(xmlNode);
295 pItem->strText.SetText(S_CW2T(GETSTRING(strText)));
296}
297
298int SListBox::InsertItem(int nIndex, LPLBITEM pItem)
299{
300 SASSERT(pItem);
301
302 if (nIndex == -1 || nIndex > GetCount())
303 {
304 nIndex = GetCount();
305 }
306
307 m_arrItems.InsertAt(nIndex, pItem);
308
309 if (m_iSelItem >= nIndex)
310 m_iSelItem++;
311 if (m_iHoverItem >= nIndex)
312 m_iHoverItem++;
313
315
316 return nIndex;
317}
318
319void SListBox::RedrawItem(int iItem)
320{
321 if (!IsVisible(TRUE))
322 return;
323
324 CRect rcClient;
325 GetClientRect(&rcClient);
326 int iFirstVisible = GetTopIndex();
327 int nItemHei = m_itemHeight.toPixelSize(GetScale());
328 int nPageItems = (rcClient.Height() + nItemHei - 1) / nItemHei + 1;
329
330 if (iItem >= iFirstVisible && iItem < GetCount() && iItem < iFirstVisible + nPageItems)
331 {
332 CRect rcItem(0, 0, rcClient.Width(), nItemHei);
333 rcItem.OffsetRect(0, nItemHei * iItem - m_siVer.nPos);
334 rcItem.OffsetRect(rcClient.TopLeft());
335 InvalidateRect(rcItem);
336 }
337}
338
339void SListBox::DrawItem(IRenderTarget *pRT, CRect &rc, int iItem)
340{
341 if (iItem < 0 || iItem >= GetCount())
342 return;
343
344 BOOL bTextColorChanged = FALSE;
345 int nBgImg = 0;
346 COLORREF crOldText = RGBA(0xFF, 0xFF, 0xFF, 0xFF);
347 COLORREF crItemBg = m_crItemBg;
348 COLORREF crText = m_crText;
349 LPLBITEM pItem = m_arrItems[iItem];
350 CRect rcIcon, rcText;
351
352 if (iItem % 2)
353 {
354 if (CR_INVALID != m_crItemBg2)
355 crItemBg = m_crItemBg2;
356 }
357
358 if (iItem == m_iSelItem)
359 { //和下面那个if的条件分开,才会有sel和hot的区别
360 if (m_pItemSkin != NULL)
361 nBgImg = 2;
362 else if (CR_INVALID != m_crItemSelBg)
363 crItemBg = m_crItemSelBg;
364
365 if (CR_INVALID != m_crSelText)
366 crText = m_crSelText;
367 }
368 else if ((iItem == m_iHoverItem || (m_iHoverItem == -1 && iItem == m_iSelItem)) && m_bHotTrack)
369 {
370 if (m_pItemSkin != NULL)
371 nBgImg = 1;
372 else if (CR_INVALID != m_crItemHotBg)
373 crItemBg = m_crItemHotBg;
374
375 if (CR_INVALID != m_crSelText)
376 crText = m_crSelText;
377 }
378
379 if (CR_INVALID != crItemBg) //先画背景
380 pRT->FillSolidRect(rc, crItemBg);
381
382 if (m_pItemSkin != NULL) //有skin,则覆盖背景
383 m_pItemSkin->DrawByIndex(pRT, rc, nBgImg);
384
385 if (CR_INVALID != crText)
386 {
387 bTextColorChanged = TRUE;
388 crOldText = pRT->SetTextColor(crText);
389 }
390
391 int nItemHei = m_itemHeight.toPixelSize(GetScale());
392 if (pItem->nImage != -1 && m_pIconSkin)
393 {
394 int nOffsetX = m_ptIcon[0].toPixelSize(GetScale()), nOffsetY = m_ptIcon[1].toPixelSize(GetScale());
395 CSize sizeSkin = m_pIconSkin->GetSkinSize();
396 rcIcon.SetRect(0, 0, sizeSkin.cx, sizeSkin.cy);
397
398 if (!m_ptIcon[0].isValid())
399 nOffsetX = nItemHei / 6;
400
401 if (!m_ptIcon[1].isValid())
402 nOffsetY = (nItemHei - sizeSkin.cy) / 2; // y 默认居中
403
404 rcIcon.OffsetRect(rc.left + nOffsetX, rc.top + nOffsetY);
405 m_pIconSkin->DrawByIndex(pRT, rcIcon, pItem->nImage);
406 }
407
408 UINT align = DT_SINGLELINE;
409 rcText = rc;
410
411 if (!m_ptText[0].isValid())
412 rcText.left = rcIcon.Width() > 0 ? rcIcon.right + nItemHei / 6 : rc.left;
413 else
414 rcText.left = rc.left + m_ptText[0].toPixelSize(GetScale());
415
416 if (!m_ptText[1].isValid())
417 align |= DT_VCENTER;
418 else
419 rcText.top = rc.top + m_ptText[1].toPixelSize(GetScale());
420
421 pRT->DrawText(pItem->strText.GetText(FALSE), -1, rcText, align);
422
423 if (bTextColorChanged)
424 pRT->SetTextColor(crOldText);
425}
426
427void SListBox::NotifySelChange(int nOldSel, int nNewSel)
428{
429 EventLBSelChanging evt1(this);
430 evt1.bCancel = FALSE;
431 evt1.nOldSel = nOldSel;
432 evt1.nNewSel = nNewSel;
433
434 FireEvent(evt1);
435 if (evt1.bCancel)
436 return;
437
438 m_iSelItem = nNewSel;
439 if (nOldSel != -1)
440 RedrawItem(nOldSel);
441
442 if (m_iSelItem != -1)
444
445 EventLBSelChanged evt2(this);
446 evt2.nOldSel = nOldSel;
447 evt2.nNewSel = nNewSel;
448 FireEvent(evt2);
449}
450
452{
453 SPainter painter;
454 BeforePaint(pRT, painter);
455
456 int nItemHei = m_itemHeight.toPixelSize(GetScale());
457 int iFirstVisible = GetTopIndex();
458 int nPageItems = (m_rcClient.Height() + nItemHei - 1) / nItemHei + 1;
459
460 for (int iItem = iFirstVisible; iItem < GetCount() && iItem < iFirstVisible + nPageItems; iItem++)
461 {
462 CRect rcItem(0, 0, m_rcClient.Width(), nItemHei);
463 rcItem.OffsetRect(0, nItemHei * iItem - m_siVer.nPos);
464 rcItem.OffsetRect(m_rcClient.TopLeft());
465 DrawItem(pRT, rcItem, iItem);
466 }
467
468 AfterPaint(pRT, painter);
469}
470
471void SListBox::OnSize(UINT nType, CSize size)
472{
473 __baseCls::OnSize(nType, size);
475}
476
477void SListBox::OnLButtonDown(UINT nFlags, CPoint pt)
478{
479 __baseCls::OnLButtonDown(nFlags, pt);
480 if (!m_bHotTrack)
481 {
482 m_iHoverItem = HitTest(pt);
485 }
486}
487
488void SListBox::OnLButtonUp(UINT nFlags, CPoint pt)
489{
490 if (m_bHotTrack)
491 {
492 CPoint pt2(pt);
493 m_iHoverItem = HitTest(pt2);
496 }
497 __baseCls::OnLButtonUp(nFlags, pt);
498}
499
500void SListBox::OnLButtonDbClick(UINT nFlags, CPoint pt)
501{
502 __baseCls::OnLButtonDbClick(nFlags, pt);
503 m_iHoverItem = HitTest(pt);
506
507 EventLBDbClick evt2(this);
508 evt2.nCurSel = m_iHoverItem;
509 FireEvent(evt2);
510}
511
512void SListBox::OnMouseMove(UINT nFlags, CPoint pt)
513{
514 int nOldHover = m_iHoverItem;
515 m_iHoverItem = HitTest(pt);
516
517 if (m_bHotTrack && nOldHover != m_iHoverItem)
518 {
519 if (nOldHover != -1)
520 RedrawItem(nOldHover);
521 if (m_iHoverItem != -1)
523 if (m_iSelItem != -1)
525 }
526}
527
528void SListBox::OnKeyDown(TCHAR nChar, UINT nRepCnt, UINT nFlags)
529{
530 int nNewSelItem = -1;
531 int iCurSel = m_iSelItem;
532 if (m_bHotTrack && m_iHoverItem != -1)
533 iCurSel = m_iHoverItem;
534 if (nChar == VK_DOWN && m_iSelItem < GetCount() - 1)
535 nNewSelItem = iCurSel + 1;
536 else if (nChar == VK_UP && m_iSelItem > 0)
537 nNewSelItem = iCurSel - 1;
538
539 if (nNewSelItem != -1)
540 {
541 int iHover = m_iHoverItem;
542 if (m_bHotTrack)
543 m_iHoverItem = -1;
544 EnsureVisible(nNewSelItem);
545 NotifySelChange(m_iSelItem, nNewSelItem);
546 if (iHover != -1 && iHover != m_iSelItem && iHover != nNewSelItem)
547 RedrawItem(iHover);
548 }
549}
550
551void SListBox::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
552{
553 SWindow *pOwner = GetOwner();
554 if (pOwner)
555 pOwner->SSendMessage(WM_CHAR, nChar, MAKELONG(nFlags, nRepCnt));
556}
557
559{
560 return SC_WANTARROWS | SC_WANTCHARS;
561}
562
564{
565 DeleteAll();
566 __baseCls::OnDestroy();
567}
568
569void SListBox::OnShowWindow(BOOL bShow, UINT nStatus)
570{
571 if (!bShow)
572 {
573 m_iHoverItem = -1;
574 }
575 __baseCls::OnShowWindow(bShow, nStatus);
576}
577
579{
580 __baseCls::OnMouseLeave();
581 if (m_iHoverItem != -1)
582 {
583 int nOldHover = m_iHoverItem;
584 m_iHoverItem = -1;
585 RedrawItem(nOldHover);
586 }
587}
588
590{
591 HRESULT hr = __baseCls::OnLanguageChanged();
592 for (size_t i = 0; i < m_arrItems.GetCount(); i++)
593 {
594 m_arrItems[i]->strText.TranslateText();
595 }
596 Invalidate();
597 return hr;
598}
599
601{
602 __baseCls::OnScaleChanged(nScale);
603 GetScaleSkin(m_pItemSkin, nScale);
604 GetScaleSkin(m_pIconSkin, nScale);
605}
606
608{
609 CRect rcClient = SWindow::GetClientRect();
610 CSize size = rcClient.Size();
611 CSize szView;
612 szView.cx = rcClient.Width();
613 szView.cy = GetCount() * GetItemHeight();
614
615 // 关闭滚动条
616 m_wBarVisible = SSB_NULL;
617
618 if (size.cy < szView.cy)
619 {
620 // 需要纵向滚动条
621 m_wBarVisible |= SSB_VERT;
622 m_siVer.nMin = 0;
623 m_siVer.nMax = szView.cy - 1;
624 m_siVer.nPage = size.cy;
625 m_siVer.nPos = smin(m_siVer.nPos, m_siVer.nMax - (int)m_siVer.nPage);
626 }
627 else
628 {
629 // 不需要纵向滚动条
630 m_siVer.nPage = size.cy;
631 m_siVer.nMin = 0;
632 m_siVer.nMax = size.cy - 1;
633 m_siVer.nPos = 0;
634 }
635
636 SetScrollPos(TRUE, m_siVer.nPos, FALSE);
637
638 // 重新计算客户区及非客户区
639 SSendMessage(WM_NCCALCSIZE);
640
641 InvalidateRect(NULL);
642}
643
644void SListBox::GetDesiredSize(THIS_ SIZE *psz, int nParentWid, int nParentHei)
645{
646 __baseCls::GetDesiredSize(psz, nParentWid, nParentHei);
647 ILayoutParam *pLayoutParam = GetLayoutParam();
648 if (pLayoutParam->IsWrapContent(Vert))
649 {
650 CRect rcPadding = GetStyle().GetPadding();
651 psz->cy = GetItemHeight() * GetCount() + rcPadding.top + rcPadding.bottom;
652 if (nParentHei > 0 && psz->cy > nParentHei)
653 psz->cy = nParentHei;
654 }
655}
656
657SNSEND
布局大小类
Definition SLayoutSize.h:10
virtual void DrawItem(IRenderTarget *pRT, CRect &rc, int iItem)
Draw an item.
Definition SListbox.cpp:339
BOOL GetIText(int nIndex, BOOL bRawText, IStringT *str) SCONST OVERRIDE
Get the text of an item.
Definition SListbox.cpp:127
void EnsureVisible(int nIndex) OVERRIDE
Ensure an item is visible.
Definition SListbox.cpp:204
int GetItemImage(int nIndex) OVERRIDE
Get the image of an item.
Definition SListbox.cpp:119
void OnPaint(IRenderTarget *pRT)
Paint the control.
Definition SListbox.cpp:451
COLORREF m_crItemSelBg
Definition SListbox.h:368
SLayoutSize m_ptText[2]
Definition SListbox.h:364
BOOL DeleteString(int nIndex) OVERRIDE
Delete a specific item.
Definition SListbox.cpp:164
COLORREF m_crItemBg2
Definition SListbox.h:367
virtual ~SListBox()
Destructor.
Definition SListbox.cpp:38
int GetCount() SCONST OVERRIDE
Get the number of items in the list box.
Definition SListbox.cpp:42
COLORREF m_crSelText
Definition SListbox.h:371
SListBox()
Constructor.
Definition SListbox.cpp:15
COLORREF m_crItemHotBg
Definition SListbox.h:369
int GetTopIndex() SCONST OVERRIDE
Get the index of the top visible item.
Definition SListbox.cpp:79
virtual UINT WINAPI OnGetDlgCode() const
Get the dialog code.
Definition SListbox.cpp:558
void SetItemHeight(int nItemHeight) OVERRIDE
Set the height of the items.
Definition SListbox.cpp:142
int GetItemHeight() SCONST OVERRIDE
Get the height of the items.
Definition SListbox.cpp:137
void OnMouseMove(UINT nFlags, CPoint pt)
Handle mouse move event.
Definition SListbox.cpp:512
BOOL SetItemData(int nIndex, LPARAM lParam) OVERRIDE
Set the data associated with an item.
Definition SListbox.cpp:101
COLORREF m_crItemBg
Definition SListbox.h:366
int FindString(int iFindAfter, LPCTSTR pszText) SCONST OVERRIDE
Find a string in the list box.
Definition SListbox.cpp:250
LPARAM GetItemData(int nIndex) SCONST OVERRIDE
Get the data associated with an item.
Definition SListbox.cpp:93
virtual BOOL CreateChildren(SXmlNode xmlNode)
Create child items from XML configuration.
Definition SListbox.cpp:264
void UpdateScrollBar()
Update the scroll bar.
Definition SListbox.cpp:607
BOOL SetTopIndex(int nIndex) OVERRIDE
Set the index of the top visible item.
Definition SListbox.cpp:84
SLayoutSize m_ptIcon[2]
Definition SListbox.h:363
void LoadItemAttribute(SXmlNode xmlNode, LPLBITEM pItem)
Load attributes for an item from XML.
Definition SListbox.cpp:288
int m_iHoverItem
Definition SListbox.h:359
void OnLButtonDown(UINT nFlags, CPoint pt)
Handle left mouse button down event.
Definition SListbox.cpp:477
void OnSize(UINT nType, CSize size)
Handle size change event.
Definition SListbox.cpp:471
int HitTest(CPoint &pt)
Hit test to determine the item under the mouse.
Definition SListbox.cpp:228
void OnMouseLeave()
Handle mouse leave event.
Definition SListbox.cpp:578
void NotifySelChange(int nOldSel, int nNewSel)
Notify of selection change.
Definition SListbox.cpp:427
virtual HRESULT OnLanguageChanged()
Handle language change event.
Definition SListbox.cpp:589
void OnKeyDown(TCHAR nChar, UINT nRepCnt, UINT nFlags)
Handle key down event.
Definition SListbox.cpp:528
SArray< LPLBITEM > m_arrItems
Definition SListbox.h:355
void DeleteAll() OVERRIDE
Delete all items in the list box.
Definition SListbox.cpp:148
void OnScaleChanged(int nScale) override
Handle scale change event.
Definition SListbox.cpp:600
int AddString(LPCTSTR lpszItem, int nImage=-1, LPARAM lParam=0) OVERRIDE
Add a string to the list box.
Definition SListbox.cpp:187
BOOL m_bHotTrack
Definition SListbox.h:361
int GetCurSel() SCONST OVERRIDE
Get the index of the currently selected item.
Definition SListbox.cpp:47
void GetDesiredSize(SIZE *psz, int nParentWid, int nParentHei) OVERRIDE
Get the desired size of the control.
Definition SListbox.cpp:644
int InsertItem(int nIndex, LPLBITEM pItem)
Insert a new item.
Definition SListbox.cpp:298
void OnLButtonUp(UINT nFlags, CPoint pt)
Handle left mouse button up event.
Definition SListbox.cpp:488
void OnShowWindow(BOOL bShow, UINT nStatus)
Handle show window event.
Definition SListbox.cpp:569
COLORREF m_crText
Definition SListbox.h:370
int m_iSelItem
Definition SListbox.h:358
SLayoutSize m_itemHeight
Definition SListbox.h:357
int InsertString(int nIndex, LPCTSTR lpszItem, int nImage=-1, LPARAM lParam=0) OVERRIDE
Insert a string into the list box.
Definition SListbox.cpp:192
void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
Handle character input event.
Definition SListbox.cpp:551
void RedrawItem(int iItem)
Redraw a specific item.
Definition SListbox.cpp:319
BOOL SetItemImage(int nIndex, int iImage) OVERRIDE
Set the image of an item.
Definition SListbox.cpp:110
void OnLButtonDbClick(UINT nFlags, CPoint pt)
Handle left mouse button double-click event.
Definition SListbox.cpp:500
BOOL SetCurSel(int nIndex, BOOL bNotifyChange=FALSE) OVERRIDE
Set the currently selected item.
Definition SListbox.cpp:52
void OnDestroy()
Handle destroy event.
Definition SListbox.cpp:563
Helper class for painting.
Definition SWnd.h:178
virtual CRect GetClientRect() const
Gets the client rectangle.
Definition SPanel.cpp:368
virtual BOOL OnScroll(BOOL bVertical, UINT uCode, int nPos)
Handles scroll events.
Definition SPanel.cpp:517
A class representing an ASCII string.
Definition sstringw.h:96
BOOL IsEmpty() SCONST
Checks if the string is empty.
void SetText(const SStringT &strText, bool bAutoEscape=true)
Sets the text.
Definition Swnd.cpp:35
SStringT GetText(BOOL bRawText=FALSE) const
Gets the text.
Definition Swnd.cpp:30
Base class for SOUI DUI windows.
Definition SWnd.h:286
BOOL FireEvent(IEvtArgs *evt) OVERRIDE
Fires an event.
Definition Swnd.cpp:1540
SWindow * GetOwner() const
Retrieves the current owner of the window.
Definition Swnd.cpp:706
int GetScale() SCONST OVERRIDE
Retrieves the scale factor of the window.
Definition Swnd.cpp:3266
BOOL IsVisible(BOOL bCheckParent=FALSE) SCONST OVERRIDE
Checks if the window is visible.
Definition Swnd.cpp:646
virtual CRect GetClientRect() const
Retrieves the client rectangle of the window.
Definition Swnd.cpp:243
LRESULT SSendMessage(UINT uMsg, WPARAM wParam=0, LPARAM lParam=0, BOOL *pbMsgHandled=NULL) OVERRIDE
Sends a message to the window.
Definition Swnd.cpp:364
virtual void BeforePaint(IRenderTarget *pRT, SPainter &painter)
Prepare rendering environment.
Definition Swnd.cpp:1755
static SStringW GetXmlText(const SXmlNode &xmlNode)
Gets the XML text from a node.
Definition Swnd.cpp:2955
void InvalidateRect(LPCRECT lprect) OVERRIDE
Invalidates a specific rectangle area of the window.
Definition Swnd.cpp:1444
BOOL m_bFocusable
Definition SWnd.h:2609
virtual void AfterPaint(IRenderTarget *pRT, SPainter &painter)
Restore rendering environment.
Definition Swnd.cpp:1776
ILayoutParam * GetLayoutParam() SCONST OVERRIDE
Retrieves the layout parameter object associated with the window.
Definition SWnd.h:405
void Invalidate() OVERRIDE
Invalidates the entire window.
Definition Swnd.cpp:1437
SEventSet m_evtSet
Definition SWnd.h:2581
void GetScaleSkin(SAutoRefPtr< ISkinObj > &pSkin, int nScale)
Retrieves a scaled skin object based on the current scale factor.
Definition Swnd.cpp:3290
const SwndStyle & GetStyle() const
Retrieves the style of the window.
Definition Swnd.cpp:716
BOOL m_bClipClient
Definition SWnd.h:2607
int as_int(int def=0) const
Converts the attribute value to an integer.
Definition SXml.cpp:100
unsigned int as_uint(unsigned int def=0) const
Converts the attribute value to an unsigned integer.
Definition SXml.cpp:105
const wchar_t * value() const
Gets the attribute value.
Definition SXml.cpp:90
Class representing an XML node.
Definition SXml.h:352
SXmlNode next_sibling() const
Gets the next sibling node in the children list of the parent node.
Definition SXml.cpp:393
SXmlAttr attribute(const wchar_t *name, bool bCaseSensitive=false) const
Gets the attribute with the specified name.
Definition SXml.cpp:428
SXmlNode child(const wchar_t *name, bool bCaseSensitive=false) const
Gets the child node, attribute, or next/previous sibling with the specified name.
Definition SXml.cpp:423
CRect GetPadding() const
Retrieves the padding rectangle.
Interface for rendering target objects.
Definition SRender-i.h:1440
HRESULT DrawText(LPCTSTR pszText, int cchLen, LPRECT pRc, UINT uFormat) PURE
Draw text within a rectangle.
HRESULT FillSolidRect(LPCRECT pRect, COLORREF cr) PURE
Fill a rectangle with a solid color.
COLORREF SetTextColor(COLORREF color) PURE
Sets the current text color.
int nImage
Definition SListbox.h:18
STrText strText
Definition SListbox.h:17
LPARAM lParam
Definition SListbox.h:19