soui 5.0.0.1
Soui5 Doc
 
Loading...
Searching...
No Matches
SComboBox.h
1#ifndef __SCOMBOBOX__H__
2#define __SCOMBOBOX__H__
3
4#include <control/SComboBase.h>
5#include <control/SListbox.h>
6#include <control/SCmnCtrl.h>
7
8SNSBEGIN
9
10/**
11 * @class SComboBox
12 * @brief Editable ComboBox Control
13 * @details A ComboBox control that can be editable and includes a dropdown list.
14 */
15class SOUI_EXP SComboBox : public TComboBaseProxy<IComboBox> {
16 DEF_SOBJECT(SComboBase, L"combobox")
17
18 public:
19 /**
20 * @brief Constructor
21 */
22 SComboBox();
23
24 /**
25 * @brief Destructor
26 */
27 virtual ~SComboBox();
28
29 public:
30 /**
31 * @brief Set the current selection index
32 * @param iSel Index to set as the current selection
33 * @return TRUE if successful, FALSE otherwise
34 */
35 STDMETHOD_(BOOL, SetCurSel)(THIS_ int iSel) OVERRIDE;
36
37 /**
38 * @brief Get the current selection index
39 * @return Current selection index
40 */
41 STDMETHOD_(int, GetCurSel)(THIS) SCONST OVERRIDE;
42
43 /**
44 * @brief Get the number of items in the list box
45 * @return Number of items
46 */
47 STDMETHOD_(int, GetCount)(THIS) SCONST OVERRIDE;
48
49 /**
50 * @brief Get the data associated with a list box item
51 * @param iItem Item index
52 * @return Data associated with the item
53 */
54 STDMETHOD_(LPARAM, GetItemData)(THIS_ UINT iItem) SCONST OVERRIDE;
55
56 /**
57 * @brief Set the data associated with a list box item
58 * @param iItem Item index
59 * @param lParam Data to associate with the item
60 * @return TRUE if successful, FALSE otherwise
61 */
62 STDMETHOD_(BOOL, SetItemData)(THIS_ UINT iItem, LPARAM lParam) OVERRIDE;
63
64 /**
65 * @brief Insert an item into the list box
66 * @param iPos Position to insert the item
67 * @param pszText Text of the item
68 * @param iIcon Icon index for the item
69 * @param lParam Data to associate with the item
70 * @return Index of the inserted item or -1 if failed
71 */
72 STDMETHOD_(int, InsertItem)(THIS_ int iPos, LPCTSTR pszText, int iIcon, LPARAM lParam) OVERRIDE;
73
74 /**
75 * @brief Insert an item into the list box (ANSI version)
76 * @param iPos Position to insert the item
77 * @param pszText Text of the item
78 * @param iIcon Icon index for the item
79 * @param lParam Data to associate with the item
80 * @return Index of the inserted item or -1 if failed
81 */
82 STDMETHOD_(int, InsertItemA)(THIS_ int iPos, LPCSTR pszText, int iIcon, LPARAM lParam) OVERRIDE
83 {
84 SStringT str = S_CA2T(pszText, CP_UTF8);
85 return InsertItem(iPos, str, iIcon, lParam);
86 }
87
88 /**
89 * @brief Delete a string from the list box
90 * @param iPos Index of the item to delete
91 * @return TRUE if successful, FALSE otherwise
92 */
93 STDMETHOD_(BOOL, DeleteString)(THIS_ int iPos) OVERRIDE;
94
95 /**
96 * @brief Reset the content of the list box
97 */
98 STDMETHOD_(void, ResetContent)(THIS) OVERRIDE;
99
100 /**
101 * @brief Get the text of a list box item
102 * @param iItem Item index
103 * @param bRawText Whether to get raw text
104 * @param str Output string for the item text
105 * @return TRUE if successful, FALSE otherwise
106 */
107 STDMETHOD_(BOOL, GetItemText)(int iItem, BOOL bRawText, IStringT *str) SCONST OVERRIDE;
108
109 /**
110 * @brief Get the text of a list box item (ANSI version)
111 * @param iItem Item index
112 * @param bRawText Whether to get raw text
113 * @param str Output string for the item text
114 * @return TRUE if successful, FALSE otherwise
115 */
116 STDMETHOD_(BOOL, GetItemTextA)(int iItem, BOOL bRawText, IStringA *str) SCONST OVERRIDE
117 {
118 SStringT strBuf;
119 BOOL bRet = GetItemText(iItem, bRawText, &strBuf);
120 SStringA strBufA = S_CT2A(strBuf, CP_UTF8);
121 str->Copy(&strBufA);
122 return bRet;
123 }
124
125 /**
126 * @brief Get the list box interface
127 * @return Pointer to the list box interface
128 */
129 STDMETHOD_(IListBox *, GetIListBox)(THIS) OVERRIDE;
130
131 public:
132 /**
133 * @brief Get the list box pointer
134 * @return Pointer to the list box
135 */
137 {
138 return m_pListBox;
139 }
140
141 protected:
142 /**
143 * @brief Notify event
144 * @param evt Event object
145 * @return TRUE if successful, FALSE otherwise
146 * @details This function is a message handler.
147 */
148 STDMETHOD_(BOOL, FireEvent)(THIS_ IEvtArgs *evt) OVERRIDE;
149
150 /**
151 * @brief Handle scale change event
152 * @param nScale Scale factor
153 */
154 virtual void OnScaleChanged(int nScale);
155
156 /**
157 * @brief Handle language change event
158 * @return HRESULT
159 */
160 virtual HRESULT OnLanguageChanged();
161
162 /**
163 * @brief Create the list box
164 * @param xmlNode XML node for the list box
165 * @return TRUE if successful, FALSE otherwise
166 */
167 virtual BOOL CreateListBox(SXmlNode xmlNode);
168
169 /**
170 * @brief Get the height of the list box
171 * @return Height of the list box
172 */
173 virtual int GetListBoxHeight();
174
175 /**
176 * @brief Handle creation of the dropdown window
177 * @param pDropDown Dropdown window pointer
178 */
179 virtual void OnCreateDropDown(SDropDownWnd *pDropDown);
180
181 /**
182 * @brief Handle destruction of the dropdown window
183 * @param pDropDown Dropdown window pointer
184 */
185 virtual void OnDestroyDropDown(SDropDownWnd *pDropDown);
186
187 /**
188 * @brief Handle selection change in the dropdown window
189 */
190 virtual void OnSelChanged();
191
192 protected:
193 SListBox *m_pListBox; /**< Pointer to the list box */
194};
195
196SNSEND
197
198#endif // __SCOMBOBOX__H__
通用控件
int GetCurSel() SCONST OVERRIDE
Get the current selection index.
BOOL GetItemTextA(int iItem, BOOL bRawText, IStringA *str) SCONST OVERRIDE
Get the text of a list box item (ANSI version)
Definition SComboBox.h:116
LPARAM GetItemData(UINT iItem) SCONST OVERRIDE
Get the data associated with a list box item.
int InsertItem(int iPos, LPCTSTR pszText, int iIcon, LPARAM lParam) OVERRIDE
Insert an item into the list box.
SComboBox()
Constructor.
Definition SComboBox.cpp:7
SListBox * GetListBox()
Get the list box pointer.
Definition SComboBox.h:136
BOOL GetItemText(int iItem, BOOL bRawText, IStringT *str) SCONST OVERRIDE
Get the text of a list box item.
SListBox * m_pListBox
Definition SComboBox.h:193
int InsertItemA(int iPos, LPCSTR pszText, int iIcon, LPARAM lParam) OVERRIDE
Insert an item into the list box (ANSI version)
Definition SComboBox.h:82
BOOL SetItemData(UINT iItem, LPARAM lParam) OVERRIDE
Set the data associated with a list box item.
BOOL SetCurSel(int iSel) OVERRIDE
Set the current selection index.
int GetCount() SCONST OVERRIDE
Get the number of items in the list box.
Dropdown Window Class.
Definition SDropDown.h:43
List Box Control.
Definition SListbox.h:38
A class representing an ASCII string.
Definition sstringa.h:96
Class representing an XML node.
Definition SXml.h:352