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.
32 \wxheading{Derived from
}
34 \helpref{wxVScrolledWindow
}{wxvscrolledwindow
}
36 \wxheading{Include files
}
40 \latexignore{\rtfignore{\wxheading{Members
}}}
43 \membersection{wxVListBox::wxVListBox
}\label{wxvlistboxctor
}
45 \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
}}
47 Normal constructor which calls
\helpref{Create()
}{wxvlistboxcreate
} internally.
49 \func{}{wxVListBox
}{\void}
51 Default constructor, you must call
\helpref{Create()
}{wxvlistboxcreate
} later.
54 \membersection{wxVListBox::Clear
}\label{wxvlistboxclear
}
56 \func{void
}{Clear
}{\void}
58 Deletes all items from the control.
61 \membersection{wxVListBox::Create
}\label{wxvlistboxcreate
}
63 \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
}}
65 Creates the control. To finish creating it you also should call
66 \helpref{SetItemCount()
}{wxvlistboxsetitemcount
} to let it know about the
67 number of items it contains.
69 The only special style which may be used with wxVListBox is
{\tt wxLB
\_MULTIPLE}
70 which indicates that the listbox should support multiple selection.
72 Returns
{\tt true
} on success or
{\tt false
} if the control couldn't be created
75 \membersection{wxVListBox::DeselectAll
}\label{wxvlistboxdeselectall
}
77 \func{bool
}{DeselectAll
}{\void}
79 Deselects all the items in the listbox.
81 Returns
{\tt true
} if any items were changed, i.e. if there had been any
82 selected items before, or
{\tt false
} if all the items were already deselected.
84 This method is only valid for multi selection listboxes.
88 \helpref{SelectAll
}{wxvlistboxselectall
},
\helpref{Select
}{wxvlistboxselect
}
91 \membersection{wxVListBox::GetFirstSelected
}\label{wxvlistboxgetfirstselected
}
93 \constfunc{int
}{GetFirstSelected
}{\param{unsigned long\&
}{cookie
}}
95 Returns the index of the first selected item in the listbox or
96 {\tt wxNOT
\_FOUND} if no items are currently selected.
98 {\it cookie
} is an opaque parameter which should be passed to the subsequent
99 calls to
\helpref{GetNextSelected
}{wxvlistboxgetnextselected
}. It is needed in
100 order to allow parallel iterations over the selected items.
102 Here is a typical example of using these functions:
104 unsigned long cookie;
105 int item = hlbox->GetFirstSelected(cookie);
106 while ( item != wxNOT_FOUND )
109 item = hlbox->GetNextSelected(cookie);
113 This method is only valid for multi selection listboxes.
116 \membersection{wxVListBox::GetItemCount
}\label{wxvlistboxgetitemcount
}
118 \constfunc{size
\_t}{GetItemCount
}{\void}
120 Get the number of items in the control.
124 \helpref{SetItemCount()
}{wxvlistboxsetitemcount
}
127 \membersection{wxVListBox::GetMargins
}\label{wxvlistboxgetmargins
}
129 \constfunc{wxPoint
}{GetMargins
}{\void}
131 Returns the margins used by the control. The
{\tt x
} field of the returned
132 point is the horizontal margine and the
{\tt y
} field is the vertical one.
136 \helpref{SetMargins
}{wxvlistboxsetmargins
}
139 \membersection{wxVListBox::GetNextSelected
}\label{wxvlistboxgetnextselected
}
141 \constfunc{int
}{GetNextSelected
}{\param{unsigned long\&
}{cookie
}}
143 Returns the index of the next selected item or
{\tt wxNOT
\_FOUND} if there are
146 This method is only valid for multi selection listboxes.
150 \helpref{GetFirstSelected
}{wxvlistboxgetfirstselected
}
153 \membersection{wxVListBox::GetSelectedCount
}\label{wxvlistboxgetselectedcount
}
155 \constfunc{size
\_t}{GetSelectedCount
}{\void}
157 Returns the number of the items currently selected.
159 It is valid for both single and multi selection controls. In the former case it
160 may only return $
0$ or $
1$ however.
164 \helpref{IsSelected
}{wxvlistboxisselected
},\\
165 \helpref{GetFirstSelected
}{wxvlistboxgetfirstselected
},\\
166 \helpref{GetNextSelected
}{wxvlistboxgetnextselected
}
169 \membersection{wxVListBox::GetSelection
}\label{wxvlistboxgetselection
}
171 \constfunc{int
}{GetSelection
}{\void}
173 Get the currently selected item or $-
1$ if there is no selection.
176 \membersection{wxVListBox::HasMultipleSelection
}\label{wxvlistboxishasmultipleselection
}
178 \constfunc{bool
}{HasMultipleSelection
}{\void}
180 Returns
{\tt true
} if the listbox was created with
{\tt wxLB
\_MULTIPLE} style
181 and so supports multiple selection or
{\tt false
} if it is a single selection
185 \membersection{wxVListBox::IsCurrent
}\label{wxvlistboxiscurrent
}
187 \constfunc{bool
}{IsCurrent
}{\param{size
\_t }{item
}}
189 Returns
{\tt true
} if this item is the current one,
{\tt false
} otherwise.
191 Current item is always the same as selected one for the single selection
192 listbox and in this case this method is equivalent to
193 \helpref{IsSelected
}{wxvlistboxisselected
} but they are different for multi
194 selection listboxes where many items may be selected but only one (at most) is
198 \membersection{wxVListBox::IsSelected
}\label{wxvlistboxisselected
}
200 \constfunc{bool
}{IsSelected
}{\param{size
\_t }{item
}}
202 Returns
{\tt true
} if this item is selected,
{\tt false
} otherwise.
205 \membersection{wxVListBox::OnDrawItem
}\label{wxvlistboxondrawitem
}
207 \constfunc{void
}{OnDrawItem
}{\param{wxDC\&
}{dc
},
\param{const wxRect\&
}{rect
},
\param{size
\_t }{n
}}
209 The derived class must implement this function to actually draw the item
210 with the given index on the provided DC.
212 \wxheading{Parameters
}
214 \docparam{dc
}{The device context to use for drawing
}
216 \docparam{rect
}{The bounding rectangle for the item being drawn (DC clipping
217 region is set to this rectangle before calling this function)
}
219 \docparam{n
}{The index of the item to be drawn
}
222 \membersection{wxVListBox::OnDrawSeparator
}\label{wxvlistboxondrawseparator
}
224 \constfunc{void
}{OnDrawSeparator
}{\param{wxDC\&
}{dc
},
\param{wxRect\&
}{rect
},
\param{size
\_t }{n
}}
226 This method may be used to draw separators between the lines. The rectangle
227 passed to it may be modified, typically to deflate it a bit before passing to
228 \helpref{OnDrawItem()
}{wxvlistboxondrawitem
}.
230 The base class version of this method doesn't do anything.
232 \wxheading{Parameters
}
234 \docparam{dc
}{The device context to use for drawing
}
236 \docparam{rect
}{The bounding rectangle for the item
}
238 \docparam{n
}{The index of the item
}
241 \membersection{wxVListBox::OnMeasureItem
}\label{wxvlistboxonmeasureitem
}
243 \constfunc{wxCoord
}{OnMeasureItem
}{\param{size
\_t }{n
}}
245 The derived class must implement this method to return the height of the
246 specified item (in pixels).
249 \membersection{wxVListBox::Select
}\label{wxvlistboxselect
}
251 \func{bool
}{Select
}{\param{size
\_t }{item
},
\param{bool
}{select = true
}}
253 Selects or deselects the specified item which must be valid (i.e. not
254 equal to
{\tt wxNOT
\_FOUND}).
256 Return
{\tt true
} if the items selection status has changed or
{\tt false
}
259 This function is only valid for the multiple selection listboxes, use
260 \helpref{SetSelection
}{wxvlistboxsetselection
} for the single selection ones.
263 \membersection{wxVListBox::SelectAll
}\label{wxvlistboxselectall
}
265 \func{bool
}{SelectAll
}{\void}
267 Selects all the items in the listbox.
269 Returns
{\tt true
} if any items were changed, i.e. if there had been any
270 unselected items before, or
{\tt false
} if all the items were already selected.
272 This method is only valid for multi selection listboxes.
276 \helpref{DeselectAll
}{wxvlistboxdeselectall
},
\helpref{Select
}{wxvlistboxselect
}
279 \membersection{wxVListBox::SelectRange
}\label{wxvlistboxselectrange
}
281 \func{bool
}{SelectRange
}{\param{size
\_t }{from
},
\param{size
\_t }{to
}}
283 Selects all items in the specified range which may be given in any order.
285 Return
{\tt true
} if the items selection status has changed or
{\tt false
}
288 This method is only valid for multi selection listboxes.
292 \helpref{SelectAll
}{wxvlistboxselectall
},
\helpref{Select
}{wxvlistboxselect
}
295 \func{void
}{SetItemCount
}{\param{size
\_t }{count
}}
297 Set the number of items to be shown in the control.
299 This is just a synonym for
300 \helpref{wxVScrolledWindow::SetLineCount()
}{wxvscrolledwindowsetlinecount
}.
303 \membersection{wxVListBox::SetMargins
}\label{wxvlistboxsetmargins
}
305 \func{void
}{SetMargins
}{\param{const wxPoint\&
}{pt
}}
307 \func{void
}{SetMargins
}{\param{wxCoord
}{x
},
\param{wxCoord
}{y
}}
309 Set the margins: horizontal margin is the distance between the window
310 border and the item contents while vertical margin is half of the
311 distance between items.
313 By default both margins are $
0$.
316 \membersection{wxVListBox::SetSelection
}\label{wxvlistboxsetselection
}
318 \func{void
}{SetSelection
}{\param{int
}{selection
}}
320 Set the selection to the specified item, if it is $-
1$ the selection is
321 unset. The selected item will be automatically scrolled into view if it isn't
325 \membersection{wxVListBox::Toggle
}\label{wxvlistboxtoggle
}
327 \func{void
}{Toggle
}{\param{size
\_t }{item
}}
329 Toggles the state of the specified
{\it item
}, i.e. selects it if it was
330 unselected and deselects it if it was selected.
332 This method is only valid for multi selection listboxes.
336 \helpref{Select
}{wxvlistboxselect
}