1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %% Purpose: wxControlWithItems documentation
4 %% Author: Vadim Zeitlin
8 %% Copyright: (c) 2003 Vadim Zeitlin
9 %% License: wxWindows license
10 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
12 \section{\class{wxControlWithItems
}}\label{wxcontrolwithitems
}
14 This class is an abstract base class for some wxWidgets controls which contain
15 several items, such as
\helpref{wxListBox
}{wxlistbox
} and
16 \helpref{wxCheckListBox
}{wxchecklistbox
} derived from it,
17 \helpref{wxChoice
}{wxchoice
} and
\helpref{wxComboBox
}{wxcombobox
}.
19 It defines the methods for accessing the controls items and although each of
20 the derived classes implements them differently, they still all conform to the
23 The items in a wxControlWithItems have (non-empty) string labels and,
24 optionally, client data associated with them. Client data may be of two
25 different kinds: either simple untyped (
{\tt void *
}) pointers which are simply
26 stored by the control but not used in any way by it, or typed pointers
27 (
{\tt wxClientData *
}) which are owned by the control meaning that the typed
28 client data (and only it) will be deleted when an item is
29 \helpref{deleted
}{wxcontrolwithitemsdelete
} or the entire control is
30 \helpref{cleared
}{wxcontrolwithitemsclear
} (which also happens when it is
31 destroyed). Finally note that in the same control all items must have client
32 data of the same type (typed or untyped), if any. This type is determined by
33 the first call to
\helpref{Append
}{wxcontrolwithitemsappend
} (the version with
34 client data pointer) or
\helpref{SetClientData
}{wxcontrolwithitemssetclientdata
}.
36 \wxheading{Derived from
}
38 \helpref{wxControl
}{wxcontrol
}\\
39 \helpref{wxWindow
}{wxwindow
}\\
40 \helpref{wxEvtHandler
}{wxevthandler
}\\
41 \helpref{wxObject
}{wxobject
}
43 \wxheading{Include files
}
45 <wx/ctrlsub.h> but usually never included directly
47 \latexignore{\rtfignore{\wxheading{Members
}}}
49 \membersection{wxControlWithItems::Append
}\label{wxcontrolwithitemsappend
}
51 \func{int
}{Append
}{\param{const wxString\&
}{ item
}}
53 Adds the item to the end of the list box.
55 \func{int
}{Append
}{\param{const wxString\&
}{ item
},
\param{void *
}{clientData
}}
57 \func{int
}{Append
}{\param{const wxString\&
}{ item
},
\param{wxClientData *
}{clientData
}}
59 Adds the item to the end of the list box, associating the given, typed or
60 untyped, client data pointer with the item.
62 \func{void
}{Append
}{\param{const wxArrayString\&
}{strings
}}
64 Appends several items at once to the control. Notice that calling this method
65 may be much faster than appending the items one by one if you need to add a lot
68 \wxheading{Parameters
}
70 \docparam{item
}{String to add.
}
72 \docparam{clientData
}{Client data to associate with the item.
}
74 \wxheading{Return value
}
76 When appending a single item, the return value is the index of the newly added
77 item which may be different from the last one if the control is sorted (e.g.
78 has
{\tt wxLB
\_SORT} or
{\tt wxCB
\_SORT} style).
80 \membersection{wxControlWithItems::Clear
}\label{wxcontrolwithitemsclear
}
82 \func{void
}{Clear
}{\void}
84 Removes all items from the control.
86 {\it Clear()
} also deletes the client data of the existing items if it is owned
89 \membersection{wxControlWithItems::Delete
}\label{wxcontrolwithitemsdelete
}
91 \func{void
}{Delete
}{\param{unsigned int
}{ n
}}
93 Deletes an item from the control. The client data associated with the item
94 will be also deleted if it is owned by the control.
96 Note that it is an error (signalled by an assert failure in debug builds) to
97 remove an item with the index negative or greater or equal than the number of
100 \wxheading{Parameters
}
102 \docparam{n
}{The zero-based item index.
}
106 \helpref{Clear
}{wxcontrolwithitemsclear
}
108 \membersection{wxControlWithItems::FindString
}\label{wxcontrolwithitemsfindstring
}
110 \func{int
}{FindString
}{\param{const wxString\&
}{string
},
\param{bool
}{ caseSensitive = false
}}
112 Finds an item whose label matches the given string.
114 \wxheading{Parameters
}
116 \docparam{string
}{String to find.
}
118 \docparam{caseSensitive
}{Whether search is case sensitive (default is not).
}
120 \wxheading{Return value
}
122 The zero-based position of the item, or
{\tt wxNOT
\_FOUND} if the string was
126 \membersection{wxControlWithItems::GetClientData
}\label{wxcontrolwithitemsgetclientdata
}
128 \constfunc{void *
}{GetClientData
}{\param{unsigned int
}{ n
}}
130 Returns a pointer to the client data associated with the given item (if any).
131 It is an error to call this function for a control which doesn't have untyped
132 client data at all although it is ok to call it even if the given item doesn't
133 have any client data associated with it (but other items do).
135 \wxheading{Parameters
}
137 \docparam{n
}{The zero-based position of the item.
}
139 \wxheading{Return value
}
141 A pointer to the client data, or
{\tt NULL
} if not present.
144 \membersection{wxControlWithItems::GetClientObject
}\label{wxcontrolwithitemsgetclientobject
}
146 \constfunc{wxClientData *
}{GetClientObject
}{\param{unsigned int
}{ n
}}
148 Returns a pointer to the client data associated with the given item (if any).
149 It is an error to call this function for a control which doesn't have typed
150 client data at all although it is ok to call it even if the given item doesn't
151 have any client data associated with it (but other items do).
153 \wxheading{Parameters
}
155 \docparam{n
}{The zero-based position of the item.
}
157 \wxheading{Return value
}
159 A pointer to the client data, or
{\tt NULL
} if not present.
162 \membersection{wxControlWithItems::GetCount
}\label{wxcontrolwithitemsgetcount
}
164 \constfunc{unsigned int
}{GetCount
}{\void}
166 Returns the number of items in the control.
170 \helpref{IsEmpty
}{wxcontrolwithitemsisempty
}
173 \membersection{wxControlWithItems::GetSelection
}\label{wxcontrolwithitemsgetselection
}
175 \constfunc{int
}{GetSelection
}{\void}
177 Returns the index of the selected item or
{\tt wxNOT
\_FOUND} if no item is
180 \wxheading{Return value
}
182 The position of the current selection.
186 This method can be used with single selection list boxes only, you should use
187 \helpref{wxListBox::GetSelections
}{wxlistboxgetselections
} for the list boxes
188 with
{\tt wxLB
\_MULTIPLE} style.
192 \helpref{SetSelection
}{wxcontrolwithitemssetselection
},
\rtfsp
193 \helpref{GetStringSelection
}{wxcontrolwithitemsgetstringselection
}
196 \membersection{wxControlWithItems::GetString
}\label{wxcontrolwithitemsgetstring
}
198 \constfunc{wxString
}{GetString
}{\param{unsigned int
}{ n
}}
200 Returns the label of the item with the given index.
202 \wxheading{Parameters
}
204 \docparam{n
}{The zero-based index.
}
206 \wxheading{Return value
}
208 The label of the item or an empty string if the position was invalid.
211 \membersection{wxControlWithItems::GetStrings
}\label{wxcontrolwithitemsgetstrings
}
213 \constfunc{wxArrayString
}{GetStrings
}{\void}
215 Returns the array of the labels of all items in the control.
218 \membersection{wxControlWithItems::GetStringSelection
}\label{wxcontrolwithitemsgetstringselection
}
220 \constfunc{wxString
}{GetStringSelection
}{\void}
222 Returns the label of the selected item or an empty string if no item is
227 \helpref{GetSelection
}{wxcontrolwithitemsgetselection
}
230 \membersection{wxControlWithItems::Insert
}\label{wxcontrolwithitemsinsert
}
232 \func{int
}{Insert
}{\param{const wxString\&
}{ item
},
\param{unsigned int
}{pos
}}
234 Inserts the item into the list before pos.
235 Not valid for
{\tt wxLB
\_SORT} or
{\tt wxCB
\_SORT} styles, use Append instead.
237 \func{int
}{Insert
}{\param{const wxString\&
}{ item
},
\param{unsigned int
}{pos
},
\param{void *
}{clientData
}}
239 \func{int
}{Insert
}{\param{const wxString\&
}{ item
},
\param{unsigned int
}{pos
},
\param{wxClientData *
}{clientData
}}
241 Inserts the item into the list before pos, associating the given, typed or
242 untyped, client data pointer with the item.
243 Not valid for
{\tt wxLB
\_SORT} or
{\tt wxCB
\_SORT} styles, use Append instead.
245 \wxheading{Parameters
}
247 \docparam{item
}{String to add.
}
249 \docparam{pos
}{Position to insert item before, zero based.
}
251 \docparam{clientData
}{Client data to associate with the item.
}
253 \wxheading{Return value
}
255 The return value is the index of the newly inserted item. If the insertion failed
256 for some reason, -
1 is returned.
259 \membersection{wxControlWithItems::IsEmpty
}\label{wxcontrolwithitemsisempty
}
261 \constfunc{bool
}{IsEmpty
}{\void}
263 Returns
{\tt true
} if the control is empty or
{\tt false
} if it has some items.
267 \helpref{GetCount
}{wxcontrolwithitemsgetcount
}
270 \membersection{wxControlWithItems::Number
}\label{wxcontrolwithitemsnumber
}
272 \constfunc{int
}{Number
}{\void}
274 {\bf Obsolescence note:
} This method is obsolete and was replaced with
275 \helpref{GetCount
}{wxcontrolwithitemsgetcount
}, please use the new method in
276 the new code. This method is only available if wxWidgets was compiled with
277 {\tt WXWIN
\_COMPATIBILITY\_2\_2} defined and will disappear completely in
281 \membersection{wxControlWithItems::Select
}\label{wxcontrolwithitemsselect
}
283 \func{void
}{Select
}{\param{int
}{ n
}}
285 This is the same as
\helpref{SetSelection
}{wxcontrolwithitemssetselection
} and
286 exists only because it is slightly more natural for controls which support
290 \membersection{wxControlWithItems::SetClientData
}\label{wxcontrolwithitemssetclientdata
}
292 \func{void
}{SetClientData
}{\param{unsigned int
}{ n
},
\param{void *
}{data
}}
294 Associates the given untyped client data pointer with the given item. Note that
295 it is an error to call this function if any typed client data pointers had been
296 associated with the control items before.
298 \wxheading{Parameters
}
300 \docparam{n
}{The zero-based item index.
}
302 \docparam{data
}{The client data to associate with the item.
}
305 \membersection{wxControlWithItems::SetClientObject
}\label{wxcontrolwithitemssetclientobject
}
307 \func{void
}{SetClientObject
}{\param{unsigned int
}{ n
},
\param{wxClientData *
}{data
}}
309 Associates the given typed client data pointer with the given item: the
310 {\it data
} object will be deleted when the item is deleted (either explicitly
311 by using
\helpref{Deletes
}{wxcontrolwithitemsdelete
} or implicitly when the
312 control itself is destroyed).
314 Note that it is an error to call this function if any untyped client data
315 pointers had been associated with the control items before.
317 \wxheading{Parameters
}
319 \docparam{n
}{The zero-based item index.
}
321 \docparam{data
}{The client data to associate with the item.
}
324 \membersection{wxControlWithItems::SetSelection
}\label{wxcontrolwithitemssetselection
}
326 \func{void
}{SetSelection
}{\param{int
}{ n
}}
328 Sets the selection to the given item
\arg{n
} or removes the selection entirely
329 if
\arg{n
} $==$
{\tt wxNOT
\_FOUND}.
331 Note that this does not cause any command events to be emitted nor does it
332 deselect any other items in the controls which support multiple selections.
334 \wxheading{Parameters
}
336 \docparam{n
}{The string position to select, starting from zero.
}
340 \helpref{SetString
}{wxcontrolwithitemssetstring
},
\rtfsp
341 \helpref{SetStringSelection
}{wxcontrolwithitemssetstringselection
}
344 \membersection{wxControlWithItems::SetString
}\label{wxcontrolwithitemssetstring
}
346 \func{void
}{SetString
}{\param{unsigned int
}{ n
},
\param{const wxString\&
}{ string
}}
348 Sets the label for the given item.
350 \wxheading{Parameters
}
352 \docparam{n
}{The zero-based item index.
}
354 \docparam{string
}{The label to set.
}
357 \membersection{wxControlWithItems::SetStringSelection
}\label{wxcontrolwithitemssetstringselection
}
359 \func{bool
}{SetStringSelection
}{\param{const wxString\&
}{ string
}}
361 Selects the item with the specified string in the control. This doesn't cause
362 any command events being emitted.
364 \wxheading{Parameters
}
366 \docparam{string
}{The string to select.
}
368 \wxheading{Return value
}
370 \true if the specified string has been selected,
\false if it wasn't found in
375 \helpref{SetSelection
}{wxcontrolwithitemssetselection
}