1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Name: ctrlsub.tex
%% Purpose: wxControlWithItems documentation
%% Author: Vadim Zeitlin
%% Modified by:
%% Created: 01.01.03
%% RCS-ID: $Id: ctrlsub.tex 41905 2006-10-10 17:46:49Z JS $
%% Copyright: (c) 2003 Vadim Zeitlin
%% License: wxWindows license
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{\class{wxControlWithItems}}\label{wxcontrolwithitems}
This class is an abstract base class for some wxWidgets controls which contain
several items, such as \helpref{wxListBox}{wxlistbox} and
\helpref{wxCheckListBox}{wxchecklistbox} derived from it,
\helpref{wxChoice}{wxchoice} and \helpref{wxComboBox}{wxcombobox}.
It defines the methods for accessing the controls items and although each of
the derived classes implements them differently, they still all conform to the
same interface.
The items in a wxControlWithItems have (non-empty) string labels and,
optionally, client data associated with them. Client data may be of two
different kinds: either simple untyped ({\tt void *}) pointers which are simply
stored by the control but not used in any way by it, or typed pointers
({\tt wxClientData *}) which are owned by the control meaning that the typed
client data (and only it) will be deleted when an item is
\helpref{deleted}{wxcontrolwithitemsdelete} or the entire control is
\helpref{cleared}{wxcontrolwithitemsclear} (which also happens when it is
destroyed). Finally note that in the same control all items must have client
data of the same type (typed or untyped), if any. This type is determined by
the first call to \helpref{Append}{wxcontrolwithitemsappend} (the version with
client data pointer) or \helpref{SetClientData}{wxcontrolwithitemssetclientdata}.
\wxheading{Derived from}
\helpref{wxControl}{wxcontrol}\\
\helpref{wxWindow}{wxwindow}\\
\helpref{wxEvtHandler}{wxevthandler}\\
\helpref{wxObject}{wxobject}
\wxheading{Include files}
<wx/ctrlsub.h> but usually never included directly
\latexignore{\rtfignore{\wxheading{Members}}}
\membersection{wxControlWithItems::Append}\label{wxcontrolwithitemsappend}
\func{int}{Append}{\param{const wxString\& }{ item}}
Adds the item to the end of the list box.
\func{int}{Append}{\param{const wxString\& }{ item}, \param{void *}{clientData}}
\func{int}{Append}{\param{const wxString\& }{ item}, \param{wxClientData *}{clientData}}
Adds the item to the end of the list box, associating the given, typed or
untyped, client data pointer with the item.
\func{void}{Append}{\param{const wxArrayString\& }{strings}}
Appends several items at once to the control. Notice that calling this method
may be much faster than appending the items one by one if you need to add a lot
of items.
\wxheading{Parameters}
\docparam{item}{String to add.}
\docparam{clientData}{Client data to associate with the item.}
\wxheading{Return value}
When appending a single item, the return value is the index of the newly added
item which may be different from the last one if the control is sorted (e.g.
has {\tt wxLB\_SORT} or {\tt wxCB\_SORT} style).
\membersection{wxControlWithItems::Clear}\label{wxcontrolwithitemsclear}
\func{void}{Clear}{\void}
Removes all items from the control.
{\it Clear()} also deletes the client data of the existing items if it is owned
by the control.
\membersection{wxControlWithItems::Delete}\label{wxcontrolwithitemsdelete}
\func{void}{Delete}{\param{unsigned int}{ n}}
Deletes an item from the control. The client data associated with the item
will be also deleted if it is owned by the control.
Note that it is an error (signalled by an assert failure in debug builds) to
remove an item with the index negative or greater or equal than the number of
items in the control.
\wxheading{Parameters}
\docparam{n}{The zero-based item index.}
\wxheading{See also}
\helpref{Clear}{wxcontrolwithitemsclear}
\membersection{wxControlWithItems::FindString}\label{wxcontrolwithitemsfindstring}
\func{int}{FindString}{\param{const wxString\& }{string}, \param{bool}{ caseSensitive = false}}
Finds an item whose label matches the given string.
\wxheading{Parameters}
\docparam{string}{String to find.}
\docparam{caseSensitive}{Whether search is case sensitive (default is not).}
\wxheading{Return value}
The zero-based position of the item, or {\tt wxNOT\_FOUND} if the string was
not found.
\membersection{wxControlWithItems::GetClientData}\label{wxcontrolwithitemsgetclientdata}
\constfunc{void *}{GetClientData}{\param{unsigned int}{ n}}
Returns a pointer to the client data associated with the given item (if any).
It is an error to call this function for a control which doesn't have untyped
client data at all although it is ok to call it even if the given item doesn't
have any client data associated with it (but other items do).
\wxheading{Parameters}
\docparam{n}{The zero-based position of the item.}
\wxheading{Return value}
A pointer to the client data, or {\tt NULL} if not present.
\membersection{wxControlWithItems::GetClientObject}\label{wxcontrolwithitemsgetclientobject}
\constfunc{wxClientData *}{GetClientObject}{\param{unsigned int}{ n}}
Returns a pointer to the client data associated with the given item (if any).
It is an error to call this function for a control which doesn't have typed
client data at all although it is ok to call it even if the given item doesn't
have any client data associated with it (but other items do).
\wxheading{Parameters}
\docparam{n}{The zero-based position of the item.}
\wxheading{Return value}
A pointer to the client data, or {\tt NULL} if not present.
\membersection{wxControlWithItems::GetCount}\label{wxcontrolwithitemsgetcount}
\constfunc{unsigned int}{GetCount}{\void}
Returns the number of items in the control.
\wxheading{See also}
\helpref{IsEmpty}{wxcontrolwithitemsisempty}
\membersection{wxControlWithItems::GetSelection}\label{wxcontrolwithitemsgetselection}
\constfunc{int}{GetSelection}{\void}
Returns the index of the selected item or {\tt wxNOT\_FOUND} if no item is
selected.
\wxheading{Return value}
The position of the current selection.
\wxheading{Remarks}
This method can be used with single selection list boxes only, you should use
\helpref{wxListBox::GetSelections}{wxlistboxgetselections} for the list boxes
with {\tt wxLB\_MULTIPLE} style.
\wxheading{See also}
\helpref{SetSelection}{wxcontrolwithitemssetselection},\rtfsp
\helpref{GetStringSelection}{wxcontrolwithitemsgetstringselection}
\membersection{wxControlWithItems::GetString}\label{wxcontrolwithitemsgetstring}
\constfunc{wxString}{GetString}{\param{unsigned int}{ n}}
Returns the label of the item with the given index.
\wxheading{Parameters}
\docparam{n}{The zero-based index.}
\wxheading{Return value}
The label of the item or an empty string if the position was invalid.
\membersection{wxControlWithItems::GetStrings}\label{wxcontrolwithitemsgetstrings}
\constfunc{wxArrayString}{GetStrings}{\void}
Returns the array of the labels of all items in the control.
\membersection{wxControlWithItems::GetStringSelection}\label{wxcontrolwithitemsgetstringselection}
\constfunc{wxString}{GetStringSelection}{\void}
Returns the label of the selected item or an empty string if no item is
selected.
\wxheading{See also}
\helpref{GetSelection}{wxcontrolwithitemsgetselection}
\membersection{wxControlWithItems::Insert}\label{wxcontrolwithitemsinsert}
\func{int}{Insert}{\param{const wxString\& }{ item}, \param{unsigned int }{pos}}
Inserts the item into the list before pos.
Not valid for {\tt wxLB\_SORT} or {\tt wxCB\_SORT} styles, use Append instead.
\func{int}{Insert}{\param{const wxString\& }{ item}, \param{unsigned int }{pos}, \param{void *}{clientData}}
\func{int}{Insert}{\param{const wxString\& }{ item}, \param{unsigned int }{pos}, \param{wxClientData *}{clientData}}
Inserts the item into the list before pos, associating the given, typed or
untyped, client data pointer with the item.
Not valid for {\tt wxLB\_SORT} or {\tt wxCB\_SORT} styles, use Append instead.
\wxheading{Parameters}
\docparam{item}{String to add.}
\docparam{pos}{Position to insert item before, zero based.}
\docparam{clientData}{Client data to associate with the item.}
\wxheading{Return value}
The return value is the index of the newly inserted item. If the insertion failed
for some reason, -1 is returned.
\membersection{wxControlWithItems::IsEmpty}\label{wxcontrolwithitemsisempty}
\constfunc{bool}{IsEmpty}{\void}
Returns {\tt true} if the control is empty or {\tt false} if it has some items.
\wxheading{See also}
\helpref{GetCount}{wxcontrolwithitemsgetcount}
\membersection{wxControlWithItems::Number}\label{wxcontrolwithitemsnumber}
\constfunc{int}{Number}{\void}
{\bf Obsolescence note:} This method is obsolete and was replaced with
\helpref{GetCount}{wxcontrolwithitemsgetcount}, please use the new method in
the new code. This method is only available if wxWidgets was compiled with
{\tt WXWIN\_COMPATIBILITY\_2\_2} defined and will disappear completely in
future versions.
\membersection{wxControlWithItems::Select}\label{wxcontrolwithitemsselect}
\func{void}{Select}{\param{int}{ n}}
This is the same as \helpref{SetSelection}{wxcontrolwithitemssetselection} and
exists only because it is slightly more natural for controls which support
multiple selection.
\membersection{wxControlWithItems::SetClientData}\label{wxcontrolwithitemssetclientdata}
\func{void}{SetClientData}{\param{unsigned int}{ n}, \param{void *}{data}}
Associates the given untyped client data pointer with the given item. Note that
it is an error to call this function if any typed client data pointers had been
associated with the control items before.
\wxheading{Parameters}
\docparam{n}{The zero-based item index.}
\docparam{data}{The client data to associate with the item.}
\membersection{wxControlWithItems::SetClientObject}\label{wxcontrolwithitemssetclientobject}
\func{void}{SetClientObject}{\param{unsigned int}{ n}, \param{wxClientData *}{data}}
Associates the given typed client data pointer with the given item: the
{\it data} object will be deleted when the item is deleted (either explicitly
by using \helpref{Deletes}{wxcontrolwithitemsdelete} or implicitly when the
control itself is destroyed).
Note that it is an error to call this function if any untyped client data
pointers had been associated with the control items before.
\wxheading{Parameters}
\docparam{n}{The zero-based item index.}
\docparam{data}{The client data to associate with the item.}
\membersection{wxControlWithItems::SetSelection}\label{wxcontrolwithitemssetselection}
\func{void}{SetSelection}{\param{int}{ n}}
Sets the selection to the given item \arg{n} or removes the selection entirely
if \arg{n} $==$ {\tt wxNOT\_FOUND}.
Note that this does not cause any command events to be emitted nor does it
deselect any other items in the controls which support multiple selections.
\wxheading{Parameters}
\docparam{n}{The string position to select, starting from zero.}
\wxheading{See also}
\helpref{SetString}{wxcontrolwithitemssetstring},\rtfsp
\helpref{SetStringSelection}{wxcontrolwithitemssetstringselection}
\membersection{wxControlWithItems::SetString}\label{wxcontrolwithitemssetstring}
\func{void}{SetString}{\param{unsigned int}{ n}, \param{const wxString\& }{ string}}
Sets the label for the given item.
\wxheading{Parameters}
\docparam{n}{The zero-based item index.}
\docparam{string}{The label to set.}
\membersection{wxControlWithItems::SetStringSelection}\label{wxcontrolwithitemssetstringselection}
\func{bool}{SetStringSelection}{\param{const wxString\& }{ string}}
Selects the item with the specified string in the control. This doesn't cause
any command events being emitted.
\wxheading{Parameters}
\docparam{string}{The string to select.}
\wxheading{Return value}
\true if the specified string has been selected, \false if it wasn't found in
the control.
\wxheading{See also}
\helpref{SetSelection}{wxcontrolwithitemssetselection}
|