1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %% Purpose: wxVListBox documentation
4 %% Author: Vadim Zeitlin
8 %% Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwindows.org>
9 %% License: wxWindows license
10 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
12 \section{\class{wxVListBox
}}\label{wxvlistbox
}
14 wxVListBox is a listbox-like control with the following two main differences
15 from a regular listbox: it can have an arbitrarily huge number of items because
16 it doesn't store them itself but uses
\helpref{OnDrawItem()
}{wxvlistboxondrawitem
}
17 callback to draw them (so it is a
{\Large V
}irtual listbox) and its items can
18 have variable height as determined by
19 \helpref{OnMeasureItem()
}{wxvlistboxonmeasureitem
} (so it is also a listbox
20 with the lines of
{\Large V
}ariable height).
22 Also, as a consequence of its virtual nature, it doesn't have any methods to
23 append or insert items in it as it isn't necessary to do it: you just have to
24 call
\helpref{SetItemCount()
}{wxvlistboxsetitemcount
} to tell the control how
25 many items it should display. Of course, this also means that you will never
26 use this class directly because it has pure virtual functions, but will need to
27 derive your own class, such as
\helpref{wxHtmlListBox
}{wxhtmllistbox
}, from it.
29 However it emits the same events as
\helpref{wxListBox
}{wxlistbox
} and the same
30 event macros may be used with it. Since wxVListBox does not store its items
31 itself, the events will only contain the index, not any contents such as the
34 \wxheading{Derived from
}
36 \helpref{wxVScrolledWindow
}{wxvscrolledwindow
}\\
37 \helpref{wxPanel
}{wxpanel
}\\
38 \helpref{wxWindow
}{wxwindow
}\\
39 \helpref{wxEvtHandler
}{wxevthandler
}\\
40 \helpref{wxObject
}{wxobject
}
42 \wxheading{Include files
}
48 \helpref{wxCore
}{librarieslist
}
52 \helpref{wxSimpleHtmlListBox
}{wxsimplehtmllistbox
},
\helpref{wxHtmlListBox
}{wxhtmllistbox
}
54 \latexignore{\rtfignore{\wxheading{Members
}}}
57 \membersection{wxVListBox::wxVListBox
}\label{wxvlistboxctor
}
59 \func{}{wxVListBox
}{\param{wxWindow*
}{parent
},
\param{wxWindowID
}{id = wxID
\_ANY},
\param{const wxPoint\&
}{pos = wxDefaultPosition
},
\param{const wxSize\&
}{size = wxDefaultSize
},
\param{size
\_t }{countItems =
0},
\param{long
}{style =
0},
\param{const wxString\&
}{name = wxVListBoxNameStr
}}
61 Normal constructor which calls
\helpref{Create()
}{wxvlistboxcreate
} internally.
63 \func{}{wxVListBox
}{\void}
65 Default constructor, you must call
\helpref{Create()
}{wxvlistboxcreate
} later.
68 \membersection{wxVListBox::Clear
}\label{wxvlistboxclear
}
70 \func{void
}{Clear
}{\void}
72 Deletes all items from the control.
75 \membersection{wxVListBox::Create
}\label{wxvlistboxcreate
}
77 \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
}}
79 Creates the control. To finish creating it you also should call
80 \helpref{SetItemCount()
}{wxvlistboxsetitemcount
} to let it know about the
81 number of items it contains.
83 The only special style which may be used with wxVListBox is
{\tt wxLB
\_MULTIPLE}
84 which indicates that the listbox should support multiple selection.
86 Returns
{\tt true
} on success or
{\tt false
} if the control couldn't be created
89 \membersection{wxVListBox::DeselectAll
}\label{wxvlistboxdeselectall
}
91 \func{bool
}{DeselectAll
}{\void}
93 Deselects all the items in the listbox.
95 Returns
{\tt true
} if any items were changed, i.e. if there had been any
96 selected items before, or
{\tt false
} if all the items were already deselected.
98 This method is only valid for multi selection listboxes.
102 \helpref{SelectAll
}{wxvlistboxselectall
},
\helpref{Select
}{wxvlistboxselect
}
105 \membersection{wxVListBox::GetFirstSelected
}\label{wxvlistboxgetfirstselected
}
107 \constfunc{int
}{GetFirstSelected
}{\param{unsigned long\&
}{cookie
}}
109 Returns the index of the first selected item in the listbox or
110 {\tt wxNOT
\_FOUND} if no items are currently selected.
112 \arg{cookie
} is an opaque parameter which should be passed to the subsequent
113 calls to
\helpref{GetNextSelected
}{wxvlistboxgetnextselected
}. It is needed in
114 order to allow parallel iterations over the selected items.
116 Here is a typical example of using these functions:
118 unsigned long cookie;
119 int item = hlbox->GetFirstSelected(cookie);
120 while ( item != wxNOT_FOUND )
123 item = hlbox->GetNextSelected(cookie);
127 This method is only valid for multi selection listboxes.
130 \membersection{wxVListBox::GetItemCount
}\label{wxvlistboxgetitemcount
}
132 \constfunc{size
\_t}{GetItemCount
}{\void}
134 Get the number of items in the control.
138 \helpref{SetItemCount()
}{wxvlistboxsetitemcount
}
141 \membersection{wxVListBox::GetMargins
}\label{wxvlistboxgetmargins
}
143 \constfunc{wxPoint
}{GetMargins
}{\void}
145 Returns the margins used by the control. The
{\tt x
} field of the returned
146 point is the horizontal margin and the
{\tt y
} field is the vertical one.
150 \helpref{SetMargins
}{wxvlistboxsetmargins
}
153 \membersection{wxVListBox::GetNextSelected
}\label{wxvlistboxgetnextselected
}
155 \constfunc{int
}{GetNextSelected
}{\param{unsigned long\&
}{cookie
}}
157 Returns the index of the next selected item or
{\tt wxNOT
\_FOUND} if there are
160 This method is only valid for multi selection listboxes.
164 \helpref{GetFirstSelected
}{wxvlistboxgetfirstselected
}
167 \membersection{wxVListBox::GetSelectedCount
}\label{wxvlistboxgetselectedcount
}
169 \constfunc{size
\_t}{GetSelectedCount
}{\void}
171 Returns the number of the items currently selected.
173 It is valid for both single and multi selection controls. In the former case it
174 may only return $
0$ or $
1$ however.
178 \helpref{IsSelected
}{wxvlistboxisselected
},\\
179 \helpref{GetFirstSelected
}{wxvlistboxgetfirstselected
},\\
180 \helpref{GetNextSelected
}{wxvlistboxgetnextselected
}
183 \membersection{wxVListBox::GetSelection
}\label{wxvlistboxgetselection
}
185 \constfunc{int
}{GetSelection
}{\void}
187 Get the currently selected item or
{\tt wxNOT
\_FOUND} if there is no selection.
190 \membersection{wxVListBox::GetSelectionBackground
}\label{wxvlistboxgetselectionbackground
}
192 \constfunc{const wxColour\&
}{GetSelectionBackground
}{\void}
194 Returns the background colour used for the selected cells. By default the
195 standard system colour is used.
199 \helpref{wxSystemSettings::GetColour
}{wxsystemsettingsgetcolour
},\\
200 \helpref{SetSelectionBackground
}{wxvlistboxsetselectionbackground
}
203 \membersection{wxVListBox::HasMultipleSelection
}\label{wxvlistboxishasmultipleselection
}
205 \constfunc{bool
}{HasMultipleSelection
}{\void}
207 Returns
{\tt true
} if the listbox was created with
{\tt wxLB
\_MULTIPLE} style
208 and so supports multiple selection or
{\tt false
} if it is a single selection
212 \membersection{wxVListBox::IsCurrent
}\label{wxvlistboxiscurrent
}
214 \constfunc{bool
}{IsCurrent
}{\param{size
\_t }{item
}}
216 Returns
{\tt true
} if this item is the current one,
{\tt false
} otherwise.
218 Current item is always the same as selected one for the single selection
219 listbox and in this case this method is equivalent to
220 \helpref{IsSelected
}{wxvlistboxisselected
} but they are different for multi
221 selection listboxes where many items may be selected but only one (at most) is
225 \membersection{wxVListBox::IsSelected
}\label{wxvlistboxisselected
}
227 \constfunc{bool
}{IsSelected
}{\param{size
\_t }{item
}}
229 Returns
{\tt true
} if this item is selected,
{\tt false
} otherwise.
232 \membersection{wxVListBox::OnDrawBackground
}\label{wxvlistboxondrawbackground
}
234 \constfunc{void
}{OnDrawBackground
}{\param{wxDC\&
}{dc
},
\param{const wxRect\&
}{rect
},
\param{size
\_t }{n
}}
236 This method is used to draw the items background and, maybe, a border
239 The base class version implements a reasonable default behaviour which
240 consists in drawing the selected item with the standard background
241 colour and drawing a border around the item if it is either selected or
245 \membersection{wxVListBox::OnDrawItem
}\label{wxvlistboxondrawitem
}
247 \constfunc{void
}{OnDrawItem
}{\param{wxDC\&
}{dc
},
\param{const wxRect\&
}{rect
},
\param{size
\_t }{n
}}
249 The derived class must implement this function to actually draw the item
250 with the given index on the provided DC.
252 \wxheading{Parameters
}
254 \docparam{dc
}{The device context to use for drawing
}
256 \docparam{rect
}{The bounding rectangle for the item being drawn (DC clipping
257 region is set to this rectangle before calling this function)
}
259 \docparam{n
}{The index of the item to be drawn
}
262 \membersection{wxVListBox::OnDrawSeparator
}\label{wxvlistboxondrawseparator
}
264 \constfunc{void
}{OnDrawSeparator
}{\param{wxDC\&
}{dc
},
\param{wxRect\&
}{rect
},
\param{size
\_t }{n
}}
266 This method may be used to draw separators between the lines. The rectangle
267 passed to it may be modified, typically to deflate it a bit before passing to
268 \helpref{OnDrawItem()
}{wxvlistboxondrawitem
}.
270 The base class version of this method doesn't do anything.
272 \wxheading{Parameters
}
274 \docparam{dc
}{The device context to use for drawing
}
276 \docparam{rect
}{The bounding rectangle for the item
}
278 \docparam{n
}{The index of the item
}
281 \membersection{wxVListBox::OnMeasureItem
}\label{wxvlistboxonmeasureitem
}
283 \constfunc{wxCoord
}{OnMeasureItem
}{\param{size
\_t }{n
}}
285 The derived class must implement this method to return the height of the
286 specified item (in pixels).
289 \membersection{wxVListBox::Select
}\label{wxvlistboxselect
}
291 \func{bool
}{Select
}{\param{size
\_t }{item
},
\param{bool
}{select = true
}}
293 Selects or deselects the specified item which must be valid (i.e. not
294 equal to
{\tt wxNOT
\_FOUND}).
296 Return
{\tt true
} if the items selection status has changed or
{\tt false
}
299 This function is only valid for the multiple selection listboxes, use
300 \helpref{SetSelection
}{wxvlistboxsetselection
} for the single selection ones.
303 \membersection{wxVListBox::SelectAll
}\label{wxvlistboxselectall
}
305 \func{bool
}{SelectAll
}{\void}
307 Selects all the items in the listbox.
309 Returns
{\tt true
} if any items were changed, i.e. if there had been any
310 unselected items before, or
{\tt false
} if all the items were already selected.
312 This method is only valid for multi selection listboxes.
316 \helpref{DeselectAll
}{wxvlistboxdeselectall
},
\helpref{Select
}{wxvlistboxselect
}
319 \membersection{wxVListBox::SelectRange
}\label{wxvlistboxselectrange
}
321 \func{bool
}{SelectRange
}{\param{size
\_t }{from
},
\param{size
\_t }{to
}}
323 Selects all items in the specified range which may be given in any order.
325 Return
{\tt true
} if the items selection status has changed or
{\tt false
}
328 This method is only valid for multi selection listboxes.
332 \helpref{SelectAll
}{wxvlistboxselectall
},
\helpref{Select
}{wxvlistboxselect
}
334 \membersection{wxVListBox::SetItemCount
}\label{wxvlistboxsetitemcount
}
336 \func{void
}{SetItemCount
}{\param{size
\_t }{count
}}
338 Set the number of items to be shown in the control.
340 This is just a synonym for
341 \helpref{wxVScrolledWindow::SetRowCount()
}{wxvarvscrollhelpersetrowcount
}.
344 \membersection{wxVListBox::SetMargins
}\label{wxvlistboxsetmargins
}
346 \func{void
}{SetMargins
}{\param{const wxPoint\&
}{pt
}}
348 \func{void
}{SetMargins
}{\param{wxCoord
}{x
},
\param{wxCoord
}{y
}}
350 Set the margins: horizontal margin is the distance between the window
351 border and the item contents while vertical margin is half of the
352 distance between items.
354 By default both margins are $
0$.
357 \membersection{wxVListBox::SetSelection
}\label{wxvlistboxsetselection
}
359 \func{void
}{SetSelection
}{\param{int
}{selection
}}
361 Set the selection to the specified item, if it is $-
1$ the selection is
362 unset. The selected item will be automatically scrolled into view if it isn't
365 This method may be used both with single and multiple selection listboxes.
368 \membersection{wxVListBox::SetSelectionBackground
}\label{wxvlistboxsetselectionbackground
}
370 \func{void
}{SetSelectionBackground
}{\param{const wxColour\&
}{col
}}
372 Sets the colour to be used for the selected cells background. The background of
373 the standard cells may be changed by simply calling
374 \helpref{SetBackgroundColour
}{wxwindowsetbackgroundcolour
}.
376 Notice that using non-default background colour may result in control having
377 appearance different from the similar native controls and so should in general
382 \helpref{GetSelectionBackground
}{wxvlistboxgetselectionbackground
}
385 \membersection{wxVListBox::Toggle
}\label{wxvlistboxtoggle
}
387 \func{void
}{Toggle
}{\param{size
\_t }{item
}}
389 Toggles the state of the specified
\arg{item
}, i.e. selects it if it was
390 unselected and deselects it if it was selected.
392 This method is only valid for multi selection listboxes.
396 \helpref{Select
}{wxvlistboxselect
}