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{wxSimpleHtmlListBox
}{wxsimplehtmllistbox
},
\helpref{wxHtmlListBox
}{wxhtmllistbox
}
50 \latexignore{\rtfignore{\wxheading{Members
}}}
53 \membersection{wxVListBox::wxVListBox
}\label{wxvlistboxctor
}
55 \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
}}
57 Normal constructor which calls
\helpref{Create()
}{wxvlistboxcreate
} internally.
59 \func{}{wxVListBox
}{\void}
61 Default constructor, you must call
\helpref{Create()
}{wxvlistboxcreate
} later.
64 \membersection{wxVListBox::Clear
}\label{wxvlistboxclear
}
66 \func{void
}{Clear
}{\void}
68 Deletes all items from the control.
71 \membersection{wxVListBox::Create
}\label{wxvlistboxcreate
}
73 \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
}}
75 Creates the control. To finish creating it you also should call
76 \helpref{SetItemCount()
}{wxvlistboxsetitemcount
} to let it know about the
77 number of items it contains.
79 The only special style which may be used with wxVListBox is
{\tt wxLB
\_MULTIPLE}
80 which indicates that the listbox should support multiple selection.
82 Returns
{\tt true
} on success or
{\tt false
} if the control couldn't be created
85 \membersection{wxVListBox::DeselectAll
}\label{wxvlistboxdeselectall
}
87 \func{bool
}{DeselectAll
}{\void}
89 Deselects all the items in the listbox.
91 Returns
{\tt true
} if any items were changed, i.e. if there had been any
92 selected items before, or
{\tt false
} if all the items were already deselected.
94 This method is only valid for multi selection listboxes.
98 \helpref{SelectAll
}{wxvlistboxselectall
},
\helpref{Select
}{wxvlistboxselect
}
101 \membersection{wxVListBox::GetFirstSelected
}\label{wxvlistboxgetfirstselected
}
103 \constfunc{int
}{GetFirstSelected
}{\param{unsigned long\&
}{cookie
}}
105 Returns the index of the first selected item in the listbox or
106 {\tt wxNOT
\_FOUND} if no items are currently selected.
108 \arg{cookie
} is an opaque parameter which should be passed to the subsequent
109 calls to
\helpref{GetNextSelected
}{wxvlistboxgetnextselected
}. It is needed in
110 order to allow parallel iterations over the selected items.
112 Here is a typical example of using these functions:
114 unsigned long cookie;
115 int item = hlbox->GetFirstSelected(cookie);
116 while ( item != wxNOT_FOUND )
119 item = hlbox->GetNextSelected(cookie);
123 This method is only valid for multi selection listboxes.
126 \membersection{wxVListBox::GetItemCount
}\label{wxvlistboxgetitemcount
}
128 \constfunc{size
\_t}{GetItemCount
}{\void}
130 Get the number of items in the control.
134 \helpref{SetItemCount()
}{wxvlistboxsetitemcount
}
137 \membersection{wxVListBox::GetMargins
}\label{wxvlistboxgetmargins
}
139 \constfunc{wxPoint
}{GetMargins
}{\void}
141 Returns the margins used by the control. The
{\tt x
} field of the returned
142 point is the horizontal margin and the
{\tt y
} field is the vertical one.
146 \helpref{SetMargins
}{wxvlistboxsetmargins
}
149 \membersection{wxVListBox::GetNextSelected
}\label{wxvlistboxgetnextselected
}
151 \constfunc{int
}{GetNextSelected
}{\param{unsigned long\&
}{cookie
}}
153 Returns the index of the next selected item or
{\tt wxNOT
\_FOUND} if there are
156 This method is only valid for multi selection listboxes.
160 \helpref{GetFirstSelected
}{wxvlistboxgetfirstselected
}
163 \membersection{wxVListBox::GetSelectedCount
}\label{wxvlistboxgetselectedcount
}
165 \constfunc{size
\_t}{GetSelectedCount
}{\void}
167 Returns the number of the items currently selected.
169 It is valid for both single and multi selection controls. In the former case it
170 may only return $
0$ or $
1$ however.
174 \helpref{IsSelected
}{wxvlistboxisselected
},\\
175 \helpref{GetFirstSelected
}{wxvlistboxgetfirstselected
},\\
176 \helpref{GetNextSelected
}{wxvlistboxgetnextselected
}
179 \membersection{wxVListBox::GetSelection
}\label{wxvlistboxgetselection
}
181 \constfunc{int
}{GetSelection
}{\void}
183 Get the currently selected item or
{\tt wxNOT
\_FOUND} if there is no selection.
186 \membersection{wxVListBox::GetSelectionBackground
}\label{wxvlistboxgetselectionbackground
}
188 \constfunc{const wxColour\&
}{GetSelectionBackground
}{\void}
190 Returns the background colour used for the selected cells. By default the
191 standard system colour is used.
195 \helpref{wxSystemSettings::GetColour
}{wxsystemsettingsgetcolour
},\\
196 \helpref{SetSelectionBackground
}{wxvlistboxsetselectionbackground
}
199 \membersection{wxVListBox::HasMultipleSelection
}\label{wxvlistboxishasmultipleselection
}
201 \constfunc{bool
}{HasMultipleSelection
}{\void}
203 Returns
{\tt true
} if the listbox was created with
{\tt wxLB
\_MULTIPLE} style
204 and so supports multiple selection or
{\tt false
} if it is a single selection
208 \membersection{wxVListBox::IsCurrent
}\label{wxvlistboxiscurrent
}
210 \constfunc{bool
}{IsCurrent
}{\param{size
\_t }{item
}}
212 Returns
{\tt true
} if this item is the current one,
{\tt false
} otherwise.
214 Current item is always the same as selected one for the single selection
215 listbox and in this case this method is equivalent to
216 \helpref{IsSelected
}{wxvlistboxisselected
} but they are different for multi
217 selection listboxes where many items may be selected but only one (at most) is
221 \membersection{wxVListBox::IsSelected
}\label{wxvlistboxisselected
}
223 \constfunc{bool
}{IsSelected
}{\param{size
\_t }{item
}}
225 Returns
{\tt true
} if this item is selected,
{\tt false
} otherwise.
228 \membersection{wxVListBox::OnDrawBackground
}\label{wxvlistboxondrawbackground
}
230 \constfunc{void
}{OnDrawBackground
}{\param{wxDC\&
}{dc
},
\param{const wxRect\&
}{rect
},
\param{size
\_t }{n
}}
232 This method is used to draw the items background and, maybe, a border
235 The base class version implements a reasonable default behaviour which
236 consists in drawing the selected item with the standard background
237 colour and drawing a border around the item if it is either selected or
241 \membersection{wxVListBox::OnDrawItem
}\label{wxvlistboxondrawitem
}
243 \constfunc{void
}{OnDrawItem
}{\param{wxDC\&
}{dc
},
\param{const wxRect\&
}{rect
},
\param{size
\_t }{n
}}
245 The derived class must implement this function to actually draw the item
246 with the given index on the provided DC.
248 \wxheading{Parameters
}
250 \docparam{dc
}{The device context to use for drawing
}
252 \docparam{rect
}{The bounding rectangle for the item being drawn (DC clipping
253 region is set to this rectangle before calling this function)
}
255 \docparam{n
}{The index of the item to be drawn
}
258 \membersection{wxVListBox::OnDrawSeparator
}\label{wxvlistboxondrawseparator
}
260 \constfunc{void
}{OnDrawSeparator
}{\param{wxDC\&
}{dc
},
\param{wxRect\&
}{rect
},
\param{size
\_t }{n
}}
262 This method may be used to draw separators between the lines. The rectangle
263 passed to it may be modified, typically to deflate it a bit before passing to
264 \helpref{OnDrawItem()
}{wxvlistboxondrawitem
}.
266 The base class version of this method doesn't do anything.
268 \wxheading{Parameters
}
270 \docparam{dc
}{The device context to use for drawing
}
272 \docparam{rect
}{The bounding rectangle for the item
}
274 \docparam{n
}{The index of the item
}
277 \membersection{wxVListBox::OnMeasureItem
}\label{wxvlistboxonmeasureitem
}
279 \constfunc{wxCoord
}{OnMeasureItem
}{\param{size
\_t }{n
}}
281 The derived class must implement this method to return the height of the
282 specified item (in pixels).
285 \membersection{wxVListBox::Select
}\label{wxvlistboxselect
}
287 \func{bool
}{Select
}{\param{size
\_t }{item
},
\param{bool
}{select = true
}}
289 Selects or deselects the specified item which must be valid (i.e. not
290 equal to
{\tt wxNOT
\_FOUND}).
292 Return
{\tt true
} if the items selection status has changed or
{\tt false
}
295 This function is only valid for the multiple selection listboxes, use
296 \helpref{SetSelection
}{wxvlistboxsetselection
} for the single selection ones.
299 \membersection{wxVListBox::SelectAll
}\label{wxvlistboxselectall
}
301 \func{bool
}{SelectAll
}{\void}
303 Selects all the items in the listbox.
305 Returns
{\tt true
} if any items were changed, i.e. if there had been any
306 unselected items before, or
{\tt false
} if all the items were already selected.
308 This method is only valid for multi selection listboxes.
312 \helpref{DeselectAll
}{wxvlistboxdeselectall
},
\helpref{Select
}{wxvlistboxselect
}
315 \membersection{wxVListBox::SelectRange
}\label{wxvlistboxselectrange
}
317 \func{bool
}{SelectRange
}{\param{size
\_t }{from
},
\param{size
\_t }{to
}}
319 Selects all items in the specified range which may be given in any order.
321 Return
{\tt true
} if the items selection status has changed or
{\tt false
}
324 This method is only valid for multi selection listboxes.
328 \helpref{SelectAll
}{wxvlistboxselectall
},
\helpref{Select
}{wxvlistboxselect
}
330 \membersection{wxVListBox::SetItemCount
}\label{wxvlistboxsetitemcount
}
332 \func{void
}{SetItemCount
}{\param{size
\_t }{count
}}
334 Set the number of items to be shown in the control.
336 This is just a synonym for
337 \helpref{wxVScrolledWindow::SetRowCount()
}{wxvarvscrollhelpersetrowcount
}.
340 \membersection{wxVListBox::SetMargins
}\label{wxvlistboxsetmargins
}
342 \func{void
}{SetMargins
}{\param{const wxPoint\&
}{pt
}}
344 \func{void
}{SetMargins
}{\param{wxCoord
}{x
},
\param{wxCoord
}{y
}}
346 Set the margins: horizontal margin is the distance between the window
347 border and the item contents while vertical margin is half of the
348 distance between items.
350 By default both margins are $
0$.
353 \membersection{wxVListBox::SetSelection
}\label{wxvlistboxsetselection
}
355 \func{void
}{SetSelection
}{\param{int
}{selection
}}
357 Set the selection to the specified item, if it is $-
1$ the selection is
358 unset. The selected item will be automatically scrolled into view if it isn't
361 This method may be used both with single and multiple selection listboxes.
364 \membersection{wxVListBox::SetSelectionBackground
}\label{wxvlistboxsetselectionbackground
}
366 \func{void
}{SetSelectionBackground
}{\param{const wxColour\&
}{col
}}
368 Sets the colour to be used for the selected cells background. The background of
369 the standard cells may be changed by simply calling
370 \helpref{SetBackgroundColour
}{wxwindowsetbackgroundcolour
}.
372 Notice that using non-default background colour may result in control having
373 appearance different from the similar native controls and so should in general
378 \helpref{GetSelectionBackground
}{wxvlistboxgetselectionbackground
}
381 \membersection{wxVListBox::Toggle
}\label{wxvlistboxtoggle
}
383 \func{void
}{Toggle
}{\param{size
\_t }{item
}}
385 Toggles the state of the specified
\arg{item
}, i.e. selects it if it was
386 unselected and deselects it if it was selected.
388 This method is only valid for multi selection listboxes.
392 \helpref{Select
}{wxvlistboxselect
}