1998-05-20 14:25:30 +00:00
|
|
|
\section{\class{wxListBox}}\label{wxlistbox}
|
|
|
|
|
|
|
|
A listbox is used to select one or more of a list of strings. The
|
|
|
|
strings are displayed in a scrolling box, with the selected string(s)
|
|
|
|
marked in reverse video. A listbox can be single selection (if an item
|
|
|
|
is selected, the previous selection is removed) or multiple selection
|
|
|
|
(clicking an item toggles the item on or off independently of other
|
|
|
|
selections).
|
|
|
|
|
1999-10-11 10:48:43 +00:00
|
|
|
List box elements are numbered from zero. Their number is limited in
|
|
|
|
some platforms (e.g. ca. 2000 on GTK).
|
1998-05-20 14:25:30 +00:00
|
|
|
|
2006-01-01 18:44:06 +00:00
|
|
|
A listbox callback gets an event wxEVT\_COMMAND\_LISTBOX\_SELECTED for single clicks, and
|
1998-07-04 15:17:59 +00:00
|
|
|
wxEVT\_COMMAND\_LISTBOX\_DOUBLE\_CLICKED for double clicks.
|
1998-05-20 14:25:30 +00:00
|
|
|
|
|
|
|
\wxheading{Derived from}
|
|
|
|
|
2003-01-01 22:08:11 +00:00
|
|
|
\helpref{wxControlWithItems}{wxcontrolwithitems}\\
|
1998-05-20 14:25:30 +00:00
|
|
|
\helpref{wxControl}{wxcontrol}\\
|
|
|
|
\helpref{wxWindow}{wxwindow}\\
|
|
|
|
\helpref{wxEvtHandler}{wxevthandler}\\
|
|
|
|
\helpref{wxObject}{wxobject}
|
|
|
|
|
1999-02-15 20:41:29 +00:00
|
|
|
\wxheading{Include files}
|
|
|
|
|
|
|
|
<wx/listbox.h>
|
|
|
|
|
1998-05-20 14:25:30 +00:00
|
|
|
\wxheading{Window styles}
|
|
|
|
|
|
|
|
\twocolwidtha{5cm}%
|
|
|
|
\begin{twocollist}\itemsep=0pt
|
|
|
|
\twocolitem{\windowstyle{wxLB\_SINGLE}}{Single-selection list.}
|
|
|
|
\twocolitem{\windowstyle{wxLB\_MULTIPLE}}{Multiple-selection list: the user can toggle multiple
|
|
|
|
items on and off.}
|
|
|
|
\twocolitem{\windowstyle{wxLB\_EXTENDED}}{Extended-selection list: the user can
|
|
|
|
select multiple items using the SHIFT key and the mouse or special key combinations.}
|
|
|
|
\twocolitem{\windowstyle{wxLB\_HSCROLL}}{Create horizontal scrollbar if contents are too wide (Windows only).}
|
|
|
|
\twocolitem{\windowstyle{wxLB\_ALWAYS\_SB}}{Always show a vertical scrollbar.}
|
|
|
|
\twocolitem{\windowstyle{wxLB\_NEEDED\_SB}}{Only create a vertical scrollbar if needed.}
|
2001-01-28 16:11:20 +00:00
|
|
|
\twocolitem{\windowstyle{wxLB\_SORT}}{The listbox contents are sorted in alphabetical order.}
|
1998-05-20 14:25:30 +00:00
|
|
|
\end{twocollist}
|
|
|
|
|
2001-04-07 00:29:08 +00:00
|
|
|
Note that {\tt wxLB\_SINGLE}, {\tt wxLB\_MULTIPLE} and {\tt wxLB\_EXTENDED}
|
|
|
|
styles are mutually exclusive and you can specify at most one of them (single
|
|
|
|
selection is the default).
|
|
|
|
|
1998-05-20 14:25:30 +00:00
|
|
|
See also \helpref{window styles overview}{windowstyles}.
|
|
|
|
|
1998-08-06 19:42:06 +00:00
|
|
|
\wxheading{Event handling}
|
|
|
|
|
|
|
|
\twocolwidtha{7cm}
|
|
|
|
\begin{twocollist}\itemsep=0pt
|
|
|
|
\twocolitem{{\bf EVT\_LISTBOX(id, func)}}{Process a wxEVT\_COMMAND\_LISTBOX\_SELECTED event,
|
|
|
|
when an item on the list is selected.}
|
1998-08-23 04:50:00 +00:00
|
|
|
\twocolitem{{\bf EVT\_LISTBOX\_DCLICK(id, func)}}{Process a wxEVT\_COMMAND\_LISTBOX\_DOUBLECLICKED event,
|
2002-06-07 20:15:28 +00:00
|
|
|
when the listbox is double-clicked.}
|
1998-08-06 19:42:06 +00:00
|
|
|
\end{twocollist}
|
|
|
|
|
1998-05-20 14:25:30 +00:00
|
|
|
\wxheading{See also}
|
|
|
|
|
1998-08-06 19:42:06 +00:00
|
|
|
\helpref{wxChoice}{wxchoice}, \helpref{wxComboBox}{wxcombobox}, \helpref{wxListCtrl}{wxlistctrl},
|
|
|
|
\rtfsp\helpref{wxCommandEvent}{wxcommandevent}
|
1998-05-20 14:25:30 +00:00
|
|
|
|
|
|
|
\latexignore{\rtfignore{\wxheading{Members}}}
|
|
|
|
|
2004-09-29 11:25:34 +00:00
|
|
|
\membersection{wxListBox::wxListBox}\label{wxlistboxctor}
|
1998-05-20 14:25:30 +00:00
|
|
|
|
|
|
|
\func{}{wxListBox}{\void}
|
|
|
|
|
|
|
|
Default constructor.
|
|
|
|
|
1998-06-14 12:11:50 +00:00
|
|
|
\func{}{wxListBox}{\param{wxWindow*}{ parent}, \param{wxWindowID}{ id},\rtfsp
|
1998-05-20 14:25:30 +00:00
|
|
|
\param{const wxPoint\&}{ pos = wxDefaultPosition}, \param{const wxSize\&}{ size = wxDefaultSize},\rtfsp
|
2006-04-30 11:40:56 +00:00
|
|
|
\param{int}{ n = 0}, \param{const wxString }{choices[] = NULL},\rtfsp
|
1998-06-14 12:11:50 +00:00
|
|
|
\param{long}{ style = 0}, \param{const wxValidator\& }{validator = wxDefaultValidator}, \param{const wxString\& }{name = ``listBox"}}
|
1998-05-20 14:25:30 +00:00
|
|
|
|
2004-02-08 08:27:29 +00:00
|
|
|
\func{}{wxListBox}{\param{wxWindow*}{ parent}, \param{wxWindowID}{ id},\rtfsp
|
|
|
|
\param{const wxPoint\&}{ pos}, \param{const wxSize\&}{ size},\rtfsp
|
|
|
|
\param{const wxArrayString\& }{choices},\rtfsp
|
|
|
|
\param{long}{ style = 0}, \param{const wxValidator\& }{validator = wxDefaultValidator}, \param{const wxString\& }{name = ``listBox"}}
|
|
|
|
|
1998-05-20 14:25:30 +00:00
|
|
|
Constructor, creating and showing a list box.
|
|
|
|
|
|
|
|
\wxheading{Parameters}
|
|
|
|
|
|
|
|
\docparam{parent}{Parent window. Must not be NULL.}
|
|
|
|
|
|
|
|
\docparam{id}{Window identifier. A value of -1 indicates a default value.}
|
|
|
|
|
|
|
|
\docparam{pos}{Window position.}
|
|
|
|
|
|
|
|
\docparam{size}{Window size. If the default size (-1, -1) is specified then the window is sized
|
|
|
|
appropriately.}
|
|
|
|
|
|
|
|
\docparam{n}{Number of strings with which to initialise the control.}
|
|
|
|
|
|
|
|
\docparam{choices}{An array of strings with which to initialise the control.}
|
|
|
|
|
|
|
|
\docparam{style}{Window style. See \helpref{wxListBox}{wxlistbox}.}
|
|
|
|
|
|
|
|
\docparam{validator}{Window validator.}
|
|
|
|
|
|
|
|
\docparam{name}{Window name.}
|
|
|
|
|
|
|
|
\wxheading{See also}
|
|
|
|
|
|
|
|
\helpref{wxListBox::Create}{wxlistboxcreate}, \helpref{wxValidator}{wxvalidator}
|
|
|
|
|
1999-12-25 20:34:56 +00:00
|
|
|
\pythonnote{The wxListBox constructor in wxPython reduces the {\tt n}
|
|
|
|
and {\tt choices} arguments are to a single argument, which is
|
1999-02-19 07:58:02 +00:00
|
|
|
a list of strings.}
|
|
|
|
|
2000-12-20 16:10:46 +00:00
|
|
|
\perlnote{In wxPerl there is just an array reference in place of {\tt n}
|
|
|
|
and {\tt choices}.}
|
1999-02-19 07:58:02 +00:00
|
|
|
|
2004-09-29 11:25:34 +00:00
|
|
|
\membersection{wxListBox::\destruct{wxListBox}}\label{wxlistboxdtor}
|
1998-05-20 14:25:30 +00:00
|
|
|
|
|
|
|
\func{void}{\destruct{wxListBox}}{\void}
|
|
|
|
|
|
|
|
Destructor, destroying the list box.
|
|
|
|
|
|
|
|
\membersection{wxListBox::Create}\label{wxlistboxcreate}
|
|
|
|
|
1998-06-14 12:11:50 +00:00
|
|
|
\func{bool}{Create}{\param{wxWindow*}{ parent}, \param{wxWindowID}{ id},\rtfsp
|
1998-05-20 14:25:30 +00:00
|
|
|
\param{const wxPoint\&}{ pos = wxDefaultPosition}, \param{const wxSize\&}{ size = wxDefaultSize},\rtfsp
|
1998-06-14 12:11:50 +00:00
|
|
|
\param{int}{ n}, \param{const wxString }{choices[] = NULL},\rtfsp
|
|
|
|
\param{long}{ style = 0}, \param{const wxValidator\& }{validator = wxDefaultValidator}, \param{const wxString\& }{name = ``listBox"}}
|
1998-05-20 14:25:30 +00:00
|
|
|
|
2004-02-08 08:27:29 +00:00
|
|
|
\func{bool}{Create}{\param{wxWindow*}{ parent}, \param{wxWindowID}{ id},\rtfsp
|
|
|
|
\param{const wxPoint\&}{ pos}, \param{const wxSize\&}{ size},\rtfsp
|
|
|
|
\param{const wxArrayString\& }{choices},\rtfsp
|
|
|
|
\param{long}{ style = 0}, \param{const wxValidator\& }{validator = wxDefaultValidator}, \param{const wxString\& }{name = ``listBox"}}
|
|
|
|
|
2004-09-29 11:25:34 +00:00
|
|
|
Creates the listbox for two-step construction. See \helpref{wxListBox::wxListBox}{wxlistboxctor}\rtfsp
|
1998-05-20 14:25:30 +00:00
|
|
|
for further details.
|
|
|
|
|
|
|
|
\membersection{wxListBox::Deselect}\label{wxlistboxdeselect}
|
|
|
|
|
|
|
|
\func{void}{Deselect}{\param{int}{ n}}
|
|
|
|
|
|
|
|
Deselects an item in the list box.
|
|
|
|
|
|
|
|
\wxheading{Parameters}
|
|
|
|
|
|
|
|
\docparam{n}{The zero-based item to deselect.}
|
|
|
|
|
|
|
|
\wxheading{Remarks}
|
|
|
|
|
|
|
|
This applies to multiple selection listboxes only.
|
|
|
|
|
|
|
|
\membersection{wxListBox::GetSelections}\label{wxlistboxgetselections}
|
|
|
|
|
1999-12-24 23:40:13 +00:00
|
|
|
\constfunc{int}{GetSelections}{\param{wxArrayInt\& }{selections}}
|
1998-05-20 14:25:30 +00:00
|
|
|
|
1999-08-16 12:18:40 +00:00
|
|
|
Fill an array of ints with the positions of the currently selected items.
|
1998-05-20 14:25:30 +00:00
|
|
|
|
|
|
|
\wxheading{Parameters}
|
|
|
|
|
1999-08-16 12:18:40 +00:00
|
|
|
\docparam{selections}{A reference to an wxArrayInt instance that is used to store the result of the query.}
|
1998-05-20 14:25:30 +00:00
|
|
|
|
|
|
|
\wxheading{Return value}
|
|
|
|
|
|
|
|
The number of selections.
|
|
|
|
|
|
|
|
\wxheading{Remarks}
|
|
|
|
|
|
|
|
Use this with a multiple selection listbox.
|
|
|
|
|
|
|
|
\wxheading{See also}
|
|
|
|
|
2003-01-01 22:08:11 +00:00
|
|
|
\helpref{wxControlWithItems::GetSelection}{wxcontrolwithitemsgetselection},\rtfsp
|
|
|
|
\helpref{wxControlWithItems::GetStringSelection}{wxcontrolwithitemsgetstringselection},\rtfsp
|
|
|
|
\helpref{wxControlWithItems::SetSelection}{wxcontrolwithitemssetselection}
|
1998-05-20 14:25:30 +00:00
|
|
|
|
1999-04-29 16:12:07 +00:00
|
|
|
\pythonnote{The wxPython version of this method takes no parameters
|
|
|
|
and returns a tuple of the selected items.}
|
|
|
|
|
2002-06-07 20:15:28 +00:00
|
|
|
\perlnote{In wxPerl this method takes no parameters and return the
|
2000-12-20 16:10:46 +00:00
|
|
|
selected items as a list.}
|
|
|
|
|
1999-02-25 12:38:56 +00:00
|
|
|
\membersection{wxListBox::InsertItems}\label{wxlistboxinsertitems}
|
|
|
|
|
2006-04-30 09:59:07 +00:00
|
|
|
\func{void}{InsertItems}{\param{int}{ nItems}, \param{const wxString}{ *items}, \param{unsigned int}{ pos}}
|
1999-02-25 12:38:56 +00:00
|
|
|
|
2006-04-30 09:59:07 +00:00
|
|
|
\func{void}{InsertItems}{\param{const wxArrayString\&}{ nItems}, \param{unsigned int}{ pos}}
|
2004-12-11 21:33:17 +00:00
|
|
|
|
1999-02-25 12:38:56 +00:00
|
|
|
Insert the given number of strings before the specified position.
|
|
|
|
|
|
|
|
\wxheading{Parameters}
|
|
|
|
|
|
|
|
\docparam{nItems}{Number of items in the array {\it items}}
|
|
|
|
|
|
|
|
\docparam{items}{Labels of items to be inserted}
|
|
|
|
|
|
|
|
\docparam{pos}{Position before which to insert the items: for example, if {\it pos} is 0 the items
|
|
|
|
will be inserted in the beginning of the listbox}
|
|
|
|
|
1999-09-30 07:13:40 +00:00
|
|
|
\pythonnote{The first two parameters are collapsed into a single
|
|
|
|
parameter for wxPython, which is a list of strings.}
|
|
|
|
|
2000-12-20 16:10:46 +00:00
|
|
|
\perlnote{In wxPerl there is just an array reference in place of {\tt nItems}
|
|
|
|
and {\tt items}.}
|
|
|
|
|
2006-03-09 12:48:52 +00:00
|
|
|
\membersection{wxListBox::HitTest}\label{wxlistboxhittest}
|
|
|
|
|
|
|
|
\constfunc{int}{HitTest}{\param{const wxPoint&}{ point}}
|
|
|
|
|
|
|
|
Returns the item located at \arg{point}, or \texttt{wxNOT\_FOUND} if there
|
|
|
|
is no item located at \arg{point}.
|
|
|
|
|
|
|
|
\newsince{2.7.0}. It is currently implemented for wxMSW, wxMac and wxGTK2
|
|
|
|
ports.
|
|
|
|
|
|
|
|
\wxheading{Parameters}
|
|
|
|
|
|
|
|
\docparam{point}{Point of item (in client coordinates) to obtain}
|
|
|
|
|
|
|
|
\wxheading{Return value}
|
|
|
|
|
|
|
|
Item located at \arg{point}, or \texttt{wxNOT\_FOUND} if unimplemented
|
|
|
|
or the item does not exist.
|
|
|
|
|
2005-02-03 19:12:57 +00:00
|
|
|
\membersection{wxListBox::IsSelected}\label{wxlistboxisselected}
|
1998-05-20 14:25:30 +00:00
|
|
|
|
2005-02-03 19:12:57 +00:00
|
|
|
\constfunc{bool}{IsSelected}{\param{int}{ n}}
|
1998-05-20 14:25:30 +00:00
|
|
|
|
|
|
|
Determines whether an item is selected.
|
|
|
|
|
|
|
|
\wxheading{Parameters}
|
|
|
|
|
|
|
|
\docparam{n}{The zero-based item index.}
|
|
|
|
|
|
|
|
\wxheading{Return value}
|
|
|
|
|
2003-01-18 00:16:34 +00:00
|
|
|
true if the given item is selected, false otherwise.
|
1998-05-20 14:25:30 +00:00
|
|
|
|
|
|
|
\membersection{wxListBox::Set}\label{wxlistboxset}
|
|
|
|
|
2002-12-04 14:11:26 +00:00
|
|
|
\func{void}{Set}{\param{int}{ n}, \param{const wxString*}{ choices}, \param{void}{ **clientData = {\tt NULL}}}
|
1998-05-20 14:25:30 +00:00
|
|
|
|
2002-12-04 14:11:26 +00:00
|
|
|
\func{void}{Set}{\param{const wxArrayString\&}{ choices}, \param{void}{ **clientData = {\tt NULL}}}
|
|
|
|
|
|
|
|
Clears the list box and adds the given strings to it.
|
1998-05-20 14:25:30 +00:00
|
|
|
|
|
|
|
\wxheading{Parameters}
|
|
|
|
|
|
|
|
\docparam{n}{The number of strings to set.}
|
|
|
|
|
|
|
|
\docparam{choices}{An array of strings to set.}
|
|
|
|
|
2002-12-04 14:11:26 +00:00
|
|
|
\docparam{clientData}{Options array of client data pointers}
|
|
|
|
|
1998-05-20 14:25:30 +00:00
|
|
|
\wxheading{Remarks}
|
|
|
|
|
2002-12-04 14:11:26 +00:00
|
|
|
You may free the array from the calling program after this function has been
|
|
|
|
called.
|
1998-05-20 14:25:30 +00:00
|
|
|
|
|
|
|
\membersection{wxListBox::SetFirstItem}\label{wxlistboxsetfirstitem}
|
|
|
|
|
|
|
|
\func{void}{SetFirstItem}{\param{int}{ n}}
|
|
|
|
|
|
|
|
\func{void}{SetFirstItem}{\param{const wxString\& }{string}}
|
|
|
|
|
1999-07-22 23:28:55 +00:00
|
|
|
Set the specified item to be the first visible item. Windows only.
|
1998-05-20 14:25:30 +00:00
|
|
|
|
|
|
|
\wxheading{Parameters}
|
|
|
|
|
|
|
|
\docparam{n}{The zero-based item index.}
|
|
|
|
|
|
|
|
\docparam{string}{The string that should be visible.}
|
|
|
|
|