1998-05-20 10:25:30 -04:00
|
|
|
\section{\class{wxChoice}}\label{wxchoice}
|
|
|
|
|
|
|
|
A choice item is used to select one of a list of strings. Unlike a
|
|
|
|
listbox, only the selection is visible until the user pulls down the
|
|
|
|
menu of choices.
|
|
|
|
|
|
|
|
\wxheading{Derived from}
|
|
|
|
|
|
|
|
\helpref{wxControl}{wxcontrol}\\
|
|
|
|
\helpref{wxWindow}{wxwindow}\\
|
|
|
|
\helpref{wxEvtHandler}{wxevthandler}\\
|
|
|
|
\helpref{wxObject}{wxobject}
|
|
|
|
|
1999-02-15 15:41:29 -05:00
|
|
|
\wxheading{Include files}
|
|
|
|
|
|
|
|
<wx/choice.h>
|
|
|
|
|
1998-05-20 10:25:30 -04:00
|
|
|
\wxheading{Window styles}
|
|
|
|
|
|
|
|
There are no special styles for wxChoice.
|
|
|
|
|
|
|
|
See also \helpref{window styles overview}{windowstyles}.
|
|
|
|
|
1998-08-06 15:42:06 -04:00
|
|
|
\wxheading{Event handling}
|
|
|
|
|
|
|
|
\twocolwidtha{7cm}
|
|
|
|
\begin{twocollist}\itemsep=0pt
|
|
|
|
\twocolitem{{\bf EVT\_CHOICE(id, func)}}{Process a wxEVT\_COMMAND\_CHOICE\_SELECTED event,
|
|
|
|
when an item on the list is selected.}
|
|
|
|
\end{twocollist}
|
|
|
|
|
1998-05-20 10:25:30 -04:00
|
|
|
\wxheading{See also}
|
|
|
|
|
1998-08-06 15:42:06 -04:00
|
|
|
\helpref{wxListBox}{wxlistbox}, \helpref{wxComboBox}{wxcombobox},
|
|
|
|
\rtfsp\helpref{wxCommandEvent}{wxcommandevent}
|
1998-05-20 10:25:30 -04:00
|
|
|
|
|
|
|
\latexignore{\rtfignore{\wxheading{Members}}}
|
|
|
|
|
|
|
|
\membersection{wxChoice::wxChoice}\label{wxchoiceconstr}
|
|
|
|
|
|
|
|
\func{}{wxChoice}{\void}
|
|
|
|
|
|
|
|
Default constructor.
|
|
|
|
|
1998-06-14 08:11:50 -04:00
|
|
|
\func{}{wxChoice}{\param{wxWindow *}{parent}, \param{wxWindowID}{ id},\rtfsp
|
1998-05-20 10:25:30 -04:00
|
|
|
\param{const wxPoint\& }{pos}, \param{const wxSize\&}{ size},\rtfsp
|
1998-06-14 08:11:50 -04:00
|
|
|
\param{int}{ n}, \param{const wxString }{choices[]},\rtfsp
|
|
|
|
\param{long}{ style = 0}, \param{const wxValidator\& }{validator = wxDefaultValidator}, \param{const wxString\& }{name = ``choice"}}
|
1998-05-20 10:25:30 -04:00
|
|
|
|
|
|
|
Constructor, creating and showing a choice.
|
|
|
|
|
|
|
|
\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 choice is sized
|
|
|
|
appropriately.}
|
|
|
|
|
|
|
|
\docparam{n}{Number of strings with which to initialise the choice control.}
|
|
|
|
|
|
|
|
\docparam{choices}{An array of strings with which to initialise the choice control.}
|
|
|
|
|
|
|
|
\docparam{style}{Window style. See \helpref{wxChoice}{wxchoice}.}
|
|
|
|
|
|
|
|
\docparam{validator}{Window validator.}
|
|
|
|
|
|
|
|
\docparam{name}{Window name.}
|
|
|
|
|
|
|
|
\wxheading{See also}
|
|
|
|
|
|
|
|
\helpref{wxChoice::Create}{wxchoicecreate}, \helpref{wxValidator}{wxvalidator}
|
|
|
|
|
1999-12-25 15:34:56 -05:00
|
|
|
\pythonnote{The wxChoice constructor in wxPython reduces the {\tt n}
|
|
|
|
and {\tt choices} arguments are to a single argument, which is
|
1999-02-19 02:58:02 -05:00
|
|
|
a list of strings.}
|
|
|
|
|
2000-12-20 11:10:46 -05:00
|
|
|
\perlnote{In wxPerl there is just an array reference in place of {\tt n}
|
|
|
|
and {\tt choices}.}
|
|
|
|
|
1998-05-20 10:25:30 -04:00
|
|
|
\membersection{wxChoice::\destruct{wxChoice}}
|
|
|
|
|
|
|
|
\func{}{\destruct{wxChoice}}{\void}
|
|
|
|
|
|
|
|
Destructor, destroying the choice item.
|
|
|
|
|
|
|
|
\membersection{wxChoice::Append}\label{wxchoiceappend}
|
|
|
|
|
2002-12-06 18:27:29 -05:00
|
|
|
\func{int}{Append}{\param{const wxString\& }{ item}}
|
1998-05-20 10:25:30 -04:00
|
|
|
|
|
|
|
Adds the item to the end of the choice control.
|
|
|
|
|
2002-12-06 18:27:29 -05:00
|
|
|
\func{int}{Append}{\param{const wxString\& }{ item}, \param{void* }{clientData}}
|
1999-08-19 14:41:41 -04:00
|
|
|
|
|
|
|
Adds the item to the end of the combobox, associating the given data
|
|
|
|
with the item.
|
|
|
|
|
1998-05-20 10:25:30 -04:00
|
|
|
\wxheading{Parameters}
|
|
|
|
|
|
|
|
\docparam{item}{String to add.}
|
|
|
|
|
1999-08-19 14:41:41 -04:00
|
|
|
\docparam{clientData}{Client data to associate with the item.}
|
|
|
|
|
2002-12-06 18:27:29 -05:00
|
|
|
\wxheading{Return value}
|
|
|
|
|
|
|
|
The index of the newly added item, may be different from the last one if the
|
|
|
|
control has {\tt wxLB\_SORT} style.
|
|
|
|
|
1998-05-20 10:25:30 -04:00
|
|
|
\membersection{wxChoice::Clear}\label{wxchoiceclear}
|
|
|
|
|
|
|
|
\func{void}{Clear}{\void}
|
|
|
|
|
|
|
|
Clears the strings from the choice item.
|
|
|
|
|
|
|
|
\membersection{wxChoice::Create}\label{wxchoicecreate}
|
|
|
|
|
1998-06-14 08:11:50 -04:00
|
|
|
\func{bool}{Create}{\param{wxWindow *}{parent}, \param{wxWindowID}{ id},\rtfsp
|
1998-05-20 10:25:30 -04:00
|
|
|
\param{const wxPoint\& }{pos}, \param{const wxSize\&}{ size},\rtfsp
|
1998-06-14 08:11:50 -04:00
|
|
|
\param{int}{ n}, \param{const wxString }{choices[]},\rtfsp
|
|
|
|
\param{long}{ style = 0}, \param{const wxString\& }{name = ``choice"}}
|
1998-05-20 10:25:30 -04:00
|
|
|
|
|
|
|
Creates the choice for two-step construction. See \helpref{wxChoice::wxChoice}{wxchoiceconstr}.
|
|
|
|
|
2002-04-12 05:31:12 -04:00
|
|
|
\membersection{wxChoice::Delete}\label{wxchoicedelete}
|
|
|
|
|
|
|
|
\func{void}{Delete}{\param{int }{n}}
|
|
|
|
|
|
|
|
Deletes the item with the given index from the control.
|
|
|
|
|
|
|
|
\wxheading{Parameters}
|
|
|
|
|
|
|
|
\docparam{n}{The item to delete.}
|
|
|
|
|
1998-05-20 10:25:30 -04:00
|
|
|
\membersection{wxChoice::FindString}\label{wxchoicefindstring}
|
|
|
|
|
|
|
|
\constfunc{int}{FindString}{\param{const wxString\& }{string}}
|
|
|
|
|
|
|
|
Finds a choice matching the given string.
|
|
|
|
|
|
|
|
\wxheading{Parameters}
|
|
|
|
|
|
|
|
\docparam{string}{String to find.}
|
|
|
|
|
|
|
|
\wxheading{Return value}
|
|
|
|
|
|
|
|
Returns the position if found, or -1 if not found.
|
|
|
|
|
|
|
|
\membersection{wxChoice::GetColumns}\label{wxchoicegetcolumns}
|
|
|
|
|
|
|
|
\constfunc{int}{GetColumns}{\void}
|
|
|
|
|
|
|
|
Gets the number of columns in this choice item.
|
|
|
|
|
|
|
|
\wxheading{Remarks}
|
|
|
|
|
|
|
|
This is implemented for Motif only.
|
|
|
|
|
1999-08-19 14:41:41 -04:00
|
|
|
\membersection{wxChoice::GetClientData}\label{wxchoicegetclientdata}
|
|
|
|
|
|
|
|
\constfunc{void*}{GetClientData}{\param{int}{ n}}
|
|
|
|
|
|
|
|
Returns a pointer to the client data associated with the given item (if any).
|
|
|
|
|
|
|
|
\wxheading{Parameters}
|
|
|
|
|
|
|
|
\docparam{n}{An item, starting from zero.}
|
|
|
|
|
|
|
|
\wxheading{Return value}
|
|
|
|
|
|
|
|
A pointer to the client data, or NULL if the item was not found.
|
|
|
|
|
2001-12-25 17:29:48 -05:00
|
|
|
\membersection{wxChoice::GetCount}\label{wxchoicegetcount}
|
|
|
|
|
|
|
|
\constfunc{int}{GetCount}{\void}
|
|
|
|
|
|
|
|
Returns the number of items in the choice.
|
|
|
|
|
1998-05-20 10:25:30 -04:00
|
|
|
\membersection{wxChoice::GetSelection}\label{wxchoicegetselection}
|
|
|
|
|
|
|
|
\constfunc{int}{GetSelection}{\void}
|
|
|
|
|
|
|
|
Gets the id (position) of the selected string, or -1 if there is no selection.
|
|
|
|
|
|
|
|
\membersection{wxChoice::GetString}\label{wxchoicegetstring}
|
|
|
|
|
1998-06-14 08:11:50 -04:00
|
|
|
\constfunc{wxString}{GetString}{\param{int}{ n}}
|
1998-05-20 10:25:30 -04:00
|
|
|
|
|
|
|
Returns the string at the given position.
|
|
|
|
|
|
|
|
\wxheading{Parameters}
|
|
|
|
|
|
|
|
\docparam{n}{The zero-based position.}
|
|
|
|
|
|
|
|
\wxheading{Return value}
|
|
|
|
|
|
|
|
The string at the given position, or the empty string if {\it n} is invalid.
|
|
|
|
|
|
|
|
\membersection{wxChoice::GetStringSelection}\label{wxchoicegetstringselection}
|
|
|
|
|
|
|
|
\constfunc{wxString}{GetStringSelection}{\void}
|
|
|
|
|
|
|
|
Gets the selected string, or the empty string if no string is selected.
|
|
|
|
|
|
|
|
\membersection{wxChoice::Number}\label{wxchoicenumber}
|
|
|
|
|
|
|
|
\constfunc{int}{Number}{\void}
|
|
|
|
|
2001-12-25 17:29:48 -05:00
|
|
|
{\bf Obsolescence note:} This method is obsolete and was replaced with
|
|
|
|
\helpref{GetCount}{wxchoicegetcount}, please use the new method in the new
|
|
|
|
code. This method is only available if wxWindows was compiled with
|
|
|
|
{\tt WXWIN\_COMPATIBILITY\_2\_2} defined and will disappear completely in
|
|
|
|
future versions.
|
|
|
|
|
1998-05-20 10:25:30 -04:00
|
|
|
Returns the number of strings in the choice control.
|
|
|
|
|
1999-08-19 14:41:41 -04:00
|
|
|
\membersection{wxChoice::SetClientData}\label{wxchoicesetclientdata}
|
|
|
|
|
|
|
|
\func{void}{SetClientData}{\param{int}{ n}, \param{void* }{data}}
|
|
|
|
|
|
|
|
Associates the given client data pointer with the given item.
|
|
|
|
|
|
|
|
\wxheading{Parameters}
|
|
|
|
|
|
|
|
\docparam{n}{The zero-based item.}
|
|
|
|
|
|
|
|
\docparam{data}{The client data.}
|
|
|
|
|
1998-05-20 10:25:30 -04:00
|
|
|
\membersection{wxChoice::SetColumns}\label{wxchoicesetcolumns}
|
|
|
|
|
1998-06-14 08:11:50 -04:00
|
|
|
\func{void}{SetColumns}{\param{int}{ n = 1}}
|
1998-05-20 10:25:30 -04:00
|
|
|
|
|
|
|
Sets the number of columns in this choice item.
|
|
|
|
|
|
|
|
\wxheading{Parameters}
|
|
|
|
|
|
|
|
\docparam{n}{Number of columns.}
|
|
|
|
|
|
|
|
\wxheading{Remarks}
|
|
|
|
|
|
|
|
This is implemented for Motif only.
|
|
|
|
|
|
|
|
\membersection{wxChoice::SetSelection}\label{wxchoicesetselection}
|
|
|
|
|
1998-06-14 08:11:50 -04:00
|
|
|
\func{void}{SetSelection}{\param{int}{ n}}
|
1998-05-20 10:25:30 -04:00
|
|
|
|
1999-07-22 19:28:55 -04:00
|
|
|
Sets the choice by passing the desired string position. This does not cause
|
|
|
|
a wxEVT\_COMMAND\_CHOICE\_SELECTED event to get emitted.
|
1998-05-20 10:25:30 -04:00
|
|
|
|
|
|
|
\wxheading{Parameters}
|
|
|
|
|
|
|
|
\docparam{n}{The string position to select, starting from zero.}
|
|
|
|
|
|
|
|
\wxheading{See also}
|
|
|
|
|
2002-02-11 16:27:27 -05:00
|
|
|
\membersection{wxChoice::SetString}\label{wxchoicesetstring}
|
|
|
|
|
|
|
|
\func{void}{SetString}{\param{int }{n}, \param{const wxString\& }{text}}
|
|
|
|
|
|
|
|
Replaces the specified string in the control with another one.
|
|
|
|
|
|
|
|
\wxheading{Parameters}
|
|
|
|
|
|
|
|
\docparam{n}{The zero-based index of the string to replace}
|
|
|
|
|
|
|
|
\docparam{text}{The new value for this item}
|
|
|
|
|
|
|
|
{\bf NB:} This method is currently not implemented in wxGTK.
|
|
|
|
|
1998-05-20 10:25:30 -04:00
|
|
|
\helpref{wxChoice::SetStringSelection}{wxchoicesetstringselection}
|
|
|
|
|
|
|
|
\membersection{wxChoice::SetStringSelection}\label{wxchoicesetstringselection}
|
|
|
|
|
|
|
|
\func{void}{SetStringSelection}{\param{const wxString\& }{ string}}
|
|
|
|
|
1999-07-22 19:28:55 -04:00
|
|
|
Sets the choice by passing the desired string. This does not cause
|
|
|
|
a wxEVT\_COMMAND\_CHOICE\_SELECTED event to get emitted.
|
1998-05-20 10:25:30 -04:00
|
|
|
|
|
|
|
\wxheading{Parameters}
|
|
|
|
|
|
|
|
\docparam{string}{The string to select.}
|
|
|
|
|
|
|
|
\wxheading{See also}
|
|
|
|
|
|
|
|
\helpref{wxChoice::SetSelection}{wxchoicesetselection}
|
|
|
|
|
|
|
|
|