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 377 378 379 380 381 382 383 384 385 386 387
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Name: vlbox.tex
%% Purpose: wxVListBox documentation
%% Author: Vadim Zeitlin
%% Modified by:
%% Created: 01.06.03
%% RCS-ID: $Id: vlbox.tex 53430 2008-05-02 15:46:36Z BP $
%% Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwindows.org>
%% License: wxWindows license
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{\class{wxVListBox}}\label{wxvlistbox}
wxVListBox is a listbox-like control with the following two main differences
from a regular listbox: it can have an arbitrarily huge number of items because
it doesn't store them itself but uses \helpref{OnDrawItem()}{wxvlistboxondrawitem}
callback to draw them (so it is a {\Large V}irtual listbox) and its items can
have variable height as determined by
\helpref{OnMeasureItem()}{wxvlistboxonmeasureitem} (so it is also a listbox
with the lines of {\Large V}ariable height).
Also, as a consequence of its virtual nature, it doesn't have any methods to
append or insert items in it as it isn't necessary to do it: you just have to
call \helpref{SetItemCount()}{wxvlistboxsetitemcount} to tell the control how
many items it should display. Of course, this also means that you will never
use this class directly because it has pure virtual functions, but will need to
derive your own class, such as \helpref{wxHtmlListBox}{wxhtmllistbox}, from it.
However it emits the same events as \helpref{wxListBox}{wxlistbox} and the same
event macros may be used with it.
\wxheading{Derived from}
\helpref{wxVScrolledWindow}{wxvscrolledwindow}\\
\helpref{wxPanel}{wxpanel}\\
\helpref{wxWindow}{wxwindow}\\
\helpref{wxEvtHandler}{wxevthandler}\\
\helpref{wxObject}{wxobject}
\wxheading{Include files}
<wx/vlbox.h>
\wxheading{See also}
\helpref{wxSimpleHtmlListBox}{wxsimplehtmllistbox}, \helpref{wxHtmlListBox}{wxhtmllistbox}
\latexignore{\rtfignore{\wxheading{Members}}}
\membersection{wxVListBox::wxVListBox}\label{wxvlistboxctor}
\func{}{wxVListBox}{\param{wxWindow* }{parent}, \param{wxWindowID }{id = wxID\_ANY}, \param{const wxPoint\& }{pos = wxDefaultPosition}, \param{const wxSize\& }{size = wxDefaultSize}, \param{long }{style = 0}, \param{const wxString\& }{name = wxVListBoxNameStr}}
Normal constructor which calls \helpref{Create()}{wxvlistboxcreate} internally.
\func{}{wxVListBox}{\void}
Default constructor, you must call \helpref{Create()}{wxvlistboxcreate} later.
\membersection{wxVListBox::Clear}\label{wxvlistboxclear}
\func{void}{Clear}{\void}
Deletes all items from the control.
\membersection{wxVListBox::Create}\label{wxvlistboxcreate}
\func{bool}{Create}{\param{wxWindow* }{parent}, \param{wxWindowID }{id = wxID\_ANY}, \param{const wxPoint\& }{pos = wxDefaultPosition}, \param{const wxSize\& }{size = wxDefaultSize}, \param{long }{style = 0}, \param{const wxString\& }{name = wxVListBoxNameStr}}
Creates the control. To finish creating it you also should call
\helpref{SetItemCount()}{wxvlistboxsetitemcount} to let it know about the
number of items it contains.
The only special style which may be used with wxVListBox is {\tt wxLB\_MULTIPLE}
which indicates that the listbox should support multiple selection.
Returns {\tt true} on success or {\tt false} if the control couldn't be created
\membersection{wxVListBox::DeselectAll}\label{wxvlistboxdeselectall}
\func{bool}{DeselectAll}{\void}
Deselects all the items in the listbox.
Returns {\tt true} if any items were changed, i.e. if there had been any
selected items before, or {\tt false} if all the items were already deselected.
This method is only valid for multi selection listboxes.
\wxheading{See also}
\helpref{SelectAll}{wxvlistboxselectall}, \helpref{Select}{wxvlistboxselect}
\membersection{wxVListBox::GetFirstSelected}\label{wxvlistboxgetfirstselected}
\constfunc{int}{GetFirstSelected}{\param{unsigned long\& }{cookie}}
Returns the index of the first selected item in the listbox or
{\tt wxNOT\_FOUND} if no items are currently selected.
\arg{cookie} is an opaque parameter which should be passed to the subsequent
calls to \helpref{GetNextSelected}{wxvlistboxgetnextselected}. It is needed in
order to allow parallel iterations over the selected items.
Here is a typical example of using these functions:
\begin{verbatim}
unsigned long cookie;
int item = hlbox->GetFirstSelected(cookie);
while ( item != wxNOT_FOUND )
{
... process item ...
item = hlbox->GetNextSelected(cookie);
}
\end{verbatim}
This method is only valid for multi selection listboxes.
\membersection{wxVListBox::GetItemCount}\label{wxvlistboxgetitemcount}
\constfunc{size\_t}{GetItemCount}{\void}
Get the number of items in the control.
\wxheading{See also}
\helpref{SetItemCount()}{wxvlistboxsetitemcount}
\membersection{wxVListBox::GetMargins}\label{wxvlistboxgetmargins}
\constfunc{wxPoint}{GetMargins}{\void}
Returns the margins used by the control. The {\tt x} field of the returned
point is the horizontal margin and the {\tt y} field is the vertical one.
\wxheading{See also}
\helpref{SetMargins}{wxvlistboxsetmargins}
\membersection{wxVListBox::GetNextSelected}\label{wxvlistboxgetnextselected}
\constfunc{int}{GetNextSelected}{\param{unsigned long\& }{cookie}}
Returns the index of the next selected item or {\tt wxNOT\_FOUND} if there are
no more.
This method is only valid for multi selection listboxes.
\wxheading{See also}
\helpref{GetFirstSelected}{wxvlistboxgetfirstselected}
\membersection{wxVListBox::GetSelectedCount}\label{wxvlistboxgetselectedcount}
\constfunc{size\_t}{GetSelectedCount}{\void}
Returns the number of the items currently selected.
It is valid for both single and multi selection controls. In the former case it
may only return $0$ or $1$ however.
\wxheading{See also}
\helpref{IsSelected}{wxvlistboxisselected},\\
\helpref{GetFirstSelected}{wxvlistboxgetfirstselected},\\
\helpref{GetNextSelected}{wxvlistboxgetnextselected}
\membersection{wxVListBox::GetSelection}\label{wxvlistboxgetselection}
\constfunc{int}{GetSelection}{\void}
Get the currently selected item or {\tt wxNOT\_FOUND} if there is no selection.
\membersection{wxVListBox::GetSelectionBackground}\label{wxvlistboxgetselectionbackground}
\constfunc{const wxColour\&}{GetSelectionBackground}{\void}
Returns the background colour used for the selected cells. By default the
standard system colour is used.
\wxheading{See also}
\helpref{wxSystemSettings::GetColour}{wxsystemsettingsgetcolour},\\
\helpref{SetSelectionBackground}{wxvlistboxsetselectionbackground}
\membersection{wxVListBox::HasMultipleSelection}\label{wxvlistboxishasmultipleselection}
\constfunc{bool}{HasMultipleSelection}{\void}
Returns {\tt true} if the listbox was created with {\tt wxLB\_MULTIPLE} style
and so supports multiple selection or {\tt false} if it is a single selection
listbox.
\membersection{wxVListBox::IsCurrent}\label{wxvlistboxiscurrent}
\constfunc{bool}{IsCurrent}{\param{size\_t }{item}}
Returns {\tt true} if this item is the current one, {\tt false} otherwise.
Current item is always the same as selected one for the single selection
listbox and in this case this method is equivalent to
\helpref{IsSelected}{wxvlistboxisselected} but they are different for multi
selection listboxes where many items may be selected but only one (at most) is
current.
\membersection{wxVListBox::IsSelected}\label{wxvlistboxisselected}
\constfunc{bool}{IsSelected}{\param{size\_t }{item}}
Returns {\tt true} if this item is selected, {\tt false} otherwise.
\membersection{wxVListBox::OnDrawBackground}\label{wxvlistboxondrawbackground}
\constfunc{void}{OnDrawBackground}{\param{wxDC\& }{dc}, \param{const wxRect\& }{rect}, \param{size\_t }{n}}
This method is used to draw the items background and, maybe, a border
around it.
The base class version implements a reasonable default behaviour which
consists in drawing the selected item with the standard background
colour and drawing a border around the item if it is either selected or
current.
\membersection{wxVListBox::OnDrawItem}\label{wxvlistboxondrawitem}
\constfunc{void}{OnDrawItem}{\param{wxDC\& }{dc}, \param{const wxRect\& }{rect}, \param{size\_t }{n}}
The derived class must implement this function to actually draw the item
with the given index on the provided DC.
\wxheading{Parameters}
\docparam{dc}{The device context to use for drawing}
\docparam{rect}{The bounding rectangle for the item being drawn (DC clipping
region is set to this rectangle before calling this function)}
\docparam{n}{The index of the item to be drawn}
\membersection{wxVListBox::OnDrawSeparator}\label{wxvlistboxondrawseparator}
\constfunc{void}{OnDrawSeparator}{\param{wxDC\& }{dc}, \param{wxRect\& }{rect}, \param{size\_t }{n}}
This method may be used to draw separators between the lines. The rectangle
passed to it may be modified, typically to deflate it a bit before passing to
\helpref{OnDrawItem()}{wxvlistboxondrawitem}.
The base class version of this method doesn't do anything.
\wxheading{Parameters}
\docparam{dc}{The device context to use for drawing}
\docparam{rect}{The bounding rectangle for the item}
\docparam{n}{The index of the item}
\membersection{wxVListBox::OnMeasureItem}\label{wxvlistboxonmeasureitem}
\constfunc{wxCoord}{OnMeasureItem}{\param{size\_t }{n}}
The derived class must implement this method to return the height of the
specified item (in pixels).
\membersection{wxVListBox::Select}\label{wxvlistboxselect}
\func{bool}{Select}{\param{size\_t }{item}, \param{bool }{select = true}}
Selects or deselects the specified item which must be valid (i.e. not
equal to {\tt wxNOT\_FOUND}).
Return {\tt true} if the items selection status has changed or {\tt false}
otherwise.
This function is only valid for the multiple selection listboxes, use
\helpref{SetSelection}{wxvlistboxsetselection} for the single selection ones.
\membersection{wxVListBox::SelectAll}\label{wxvlistboxselectall}
\func{bool}{SelectAll}{\void}
Selects all the items in the listbox.
Returns {\tt true} if any items were changed, i.e. if there had been any
unselected items before, or {\tt false} if all the items were already selected.
This method is only valid for multi selection listboxes.
\wxheading{See also}
\helpref{DeselectAll}{wxvlistboxdeselectall}, \helpref{Select}{wxvlistboxselect}
\membersection{wxVListBox::SelectRange}\label{wxvlistboxselectrange}
\func{bool}{SelectRange}{\param{size\_t }{from}, \param{size\_t }{to}}
Selects all items in the specified range which may be given in any order.
Return {\tt true} if the items selection status has changed or {\tt false}
otherwise.
This method is only valid for multi selection listboxes.
\wxheading{See also}
\helpref{SelectAll}{wxvlistboxselectall}, \helpref{Select}{wxvlistboxselect}
\membersection{wxVListBox::SetItemCount}\label{wxvlistboxsetitemcount}
\func{void}{SetItemCount}{\param{size\_t }{count}}
Set the number of items to be shown in the control.
This is just a synonym for
\helpref{wxVScrolledWindow::SetLineCount()}{wxvscrolledwindowsetlinecount}.
\membersection{wxVListBox::SetMargins}\label{wxvlistboxsetmargins}
\func{void}{SetMargins}{\param{const wxPoint\& }{pt}}
\func{void}{SetMargins}{\param{wxCoord }{x}, \param{wxCoord }{y}}
Set the margins: horizontal margin is the distance between the window
border and the item contents while vertical margin is half of the
distance between items.
By default both margins are $0$.
\membersection{wxVListBox::SetSelection}\label{wxvlistboxsetselection}
\func{void}{SetSelection}{\param{int }{selection}}
Set the selection to the specified item, if it is $-1$ the selection is
unset. The selected item will be automatically scrolled into view if it isn't
currently visible.
This method may be used both with single and multiple selection listboxes.
\membersection{wxVListBox::SetSelectionBackground}\label{wxvlistboxsetselectionbackground}
\func{void}{SetSelectionBackground}{\param{const wxColour\& }{col}}
Sets the colour to be used for the selected cells background. The background of
the standard cells may be changed by simply calling
\helpref{SetBackgroundColour}{wxwindowsetbackgroundcolour}.
\wxheading{See also}
\helpref{GetSelectionBackground}{wxvlistboxgetselectionbackground}
\membersection{wxVListBox::Toggle}\label{wxvlistboxtoggle}
\func{void}{Toggle}{\param{size\_t }{item}}
Toggles the state of the specified \arg{item}, i.e. selects it if it was
unselected and deselects it if it was selected.
This method is only valid for multi selection listboxes.
\wxheading{See also}
\helpref{Select}{wxvlistboxselect}
|