]>
git.saurik.com Git - wxWidgets.git/blob - interface/ctrlsub.h
f0211eef44b4840cb7c4f0818d0f2e0e8f40c7c2
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: documentation for wxControlWithItems class
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
10 @class wxControlWithItems
13 This class is an abstract base class for some wxWidgets controls which contain
14 several items, such as wxListBox and
15 wxCheckListBox derived from it,
16 wxChoice and wxComboBox.
18 It defines the methods for accessing the controls items and although each of
19 the derived classes implements them differently, they still all conform to the
22 The items in a wxControlWithItems have (non-empty) string labels and,
23 optionally, client data associated with them. Client data may be of two
24 different kinds: either simple untyped (@c void *) pointers which are simply
25 stored by the control but not used in any way by it, or typed pointers
26 (@c wxClientData *) which are owned by the control meaning that the typed
27 client data (and only it) will be deleted when an item is
28 @ref wxControlWithItems::delete deleted or the entire control is
29 @ref wxControlWithItems::clear cleared (which also happens when it is
30 destroyed). Finally note that in the same control all items must have client
31 data of the same type (typed or untyped), if any. This type is determined by
32 the first call to wxControlWithItems::Append (the version with
33 client data pointer) or wxControlWithItems::SetClientData.
39 wxControlWithItems::Clear
41 class wxControlWithItems
: public wxControl
46 Appends several items at once to the control. Notice that calling this method
47 is usually much faster than appending them one by one if you need to add a lot
54 Contains items to append to the control.
57 Array of strings of size n.
60 Number of items in the strings array.
63 Array of client data pointers of size n to associate with the new items.
65 @returns When appending a single item, the return value is the index of
66 the newly added item which may be different from the
67 last one if the control is sorted (e.g. has wxLB_SORT
70 int Append(const wxString
& item
);
71 int Append(const wxString
& item
, void * clientData
);
72 int Append(const wxString
& item
, wxClientData
* clientData
);
73 void Append(const wxArrayString
& strings
);
74 void Append(unsigned int n
, const wxString
* strings
);
75 void Append(unsigned int n
, const wxString
* strings
,
77 void Append(unsigned int n
, const wxString
* strings
,
78 wxClientData
** clientData
);
82 Removes all items from the control.
84 @e Clear() also deletes the client data of the existing items if it is owned
90 Deletes an item from the control. The client data associated with the item
91 will be also deleted if it is owned by the control.
93 Note that it is an error (signalled by an assert failure in debug builds) to
94 remove an item with the index negative or greater or equal than the number of
98 The zero-based item index.
102 void Delete(unsigned int n
);
105 Finds an item whose label matches the given string.
111 Whether search is case sensitive (default is not).
113 @returns The zero-based position of the item, or wxNOT_FOUND if the
114 string was not found.
116 int FindString(const wxString
& string
,
117 bool caseSensitive
= @
false);
120 Returns a pointer to the client data associated with the given item (if any).
121 It is an error to call this function for a control which doesn't have untyped
122 client data at all although it is ok to call it even if the given item doesn't
123 have any client data associated with it (but other items do).
126 The zero-based position of the item.
128 @returns A pointer to the client data, or @NULL if not present.
130 void * GetClientData(unsigned int n
);
133 Returns a pointer to the client data associated with the given item (if any).
134 It is an error to call this function for a control which doesn't have typed
135 client data at all although it is ok to call it even if the given item doesn't
136 have any client data associated with it (but other items do).
139 The zero-based position of the item.
141 @returns A pointer to the client data, or @NULL if not present.
143 wxClientData
* GetClientObject(unsigned int n
);
146 Returns the number of items in the control.
150 unsigned int GetCount();
153 Returns the index of the selected item or @c wxNOT_FOUND if no item is
156 @returns The position of the current selection.
158 @remarks This method can be used with single selection list boxes only,
159 you should use wxListBox::GetSelections for the list
160 boxes with wxLB_MULTIPLE style.
162 @sa SetSelection(), GetStringSelection()
167 Returns the label of the item with the given index.
170 The zero-based index.
172 @returns The label of the item or an empty string if the position was
175 wxString
GetString(unsigned int n
);
178 Returns the label of the selected item or an empty string if no item is
183 wxString
GetStringSelection();
186 Returns the array of the labels of all items in the control.
188 wxArrayString
GetStrings();
192 Inserts several items at once into the control. Notice that calling this method
193 is usually much faster than inserting them one by one if you need to insert a
201 Position to insert item before, zero based.
204 Contains items to insert into the control content
207 Array of strings of size n.
210 Number of items in the strings array.
213 Array of client data pointers of size n to associate with the new items.
215 @returns The return value is the index of the newly inserted item. If the
216 insertion failed for some reason, -1 is returned.
218 int Insert(const wxString
& item
, unsigned int pos
);
219 int Insert(const wxString
& item
, unsigned int pos
,
221 int Insert(const wxString
& item
, unsigned int pos
,
222 wxClientData
* clientData
);
223 void Insert(const wxArrayString
& strings
, unsigned int pos
);
224 void Insert(const wxArrayString
& strings
, unsigned int pos
);
225 void Insert(unsigned int n
, const wxString
* strings
,
227 void Insert(unsigned int n
, const wxString
* strings
,
230 void Insert(unsigned int n
, const wxString
* strings
,
232 wxClientData
** clientData
);
236 Returns @true if the control is empty or @false if it has some items.
243 This is the same as SetSelection() and
244 exists only because it is slightly more natural for controls which support
251 Replaces the current control contents with the given items. Notice that calling
252 this method is much faster than appending the items one by one if you need to
253 append a lot of them.
256 The single item to insert into the control.
259 Contains items to set as control content.
262 Raw C++ array of strings. Only used in conjunction with 'n'.
265 Number of items passed in 'strings'. Only used in conjunction with 'strings'.
268 Client data to associate with the item(s).
270 @returns When the control is sorted (e.g. has wxLB_SORT or wxCB_SORT
271 style) the return value could be different from
272 (GetCount() - 1). When setting a single item to the
273 container, the return value is the index of the newly
274 added item which may be different from the last one
275 if the control is sorted (e.g. has wxLB_SORT or
278 int Set(const wxString
& item
);
279 int Set(const wxString
& item
, void * clientData
);
280 int Set(const wxString
& item
, wxClientData
* clientData
);
281 void Set(const wxArrayString
& stringsArray
);
282 void Set(unsigned int n
, const wxString
* strings
);
283 void Set(unsigned int n
, const wxString
* strings
,
285 void Set(unsigned int n
, const wxString
* strings
,
286 wxClientData
** clientData
);
290 Associates the given untyped client data pointer with the given item. Note that
291 it is an error to call this function if any typed client data pointers had been
292 associated with the control items before.
295 The zero-based item index.
298 The client data to associate with the item.
300 void SetClientData(unsigned int n
, void * data
);
303 Associates the given typed client data pointer with the given item: the
304 @e data object will be deleted when the item is deleted (either explicitly
305 by using @ref delete() Deletes or implicitly when the
306 control itself is destroyed).
308 Note that it is an error to call this function if any untyped client data
309 pointers had been associated with the control items before.
312 The zero-based item index.
315 The client data to associate with the item.
317 void SetClientObject(unsigned int n
, wxClientData
* data
);
320 Sets the selection to the given item @e n or removes the selection entirely
321 if @e n == @c wxNOT_FOUND.
323 Note that this does not cause any command events to be emitted nor does it
324 deselect any other items in the controls which support multiple selections.
327 The string position to select, starting from zero.
329 @sa SetString(), SetStringSelection()
331 void SetSelection(int n
);
334 Sets the label for the given item.
337 The zero-based item index.
342 void SetString(unsigned int n
, const wxString
& string
);
345 Selects the item with the specified string in the control. This doesn't cause
346 any command events to be emitted.
349 The string to select.
351 @returns @true if the specified string has been selected, @false if it
352 wasn't found in the control.
354 bool SetStringSelection(const wxString
& string
);