]>
git.saurik.com Git - wxWidgets.git/blob - interface/choice.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxChoice
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
13 A choice item is used to select one of a list of strings. Unlike a
14 wxListBox, only the selection is visible until the user pulls down the
19 Sorts the entries alphabetically.
22 @beginEventTable{wxCommandEvent}
23 @event{EVT_CHOICE(id, func)}
24 Process a wxEVT_COMMAND_CHOICE_SELECTED event, when an item on the
30 <!-- @appearance{choice.png} -->
32 @see wxListBox, wxComboBox, wxCommandEvent
34 class wxChoice
: public wxControlWithItems
40 @see Create(), wxValidator
46 Constructor, creating and showing a choice.
49 Parent window. Must not be @NULL.
51 Window identifier. The value wxID_ANY indicates a default value.
55 Window size. If wxDefaultSize is specified then the choice is sized
58 Number of strings with which to initialise the choice control.
60 An array of strings with which to initialise the choice control.
62 Window style. See wxChoice.
68 @see Create(), wxValidator
72 The wxChoice constructor in wxPython reduces the @a n and @a choices
73 arguments to a single argument, which is a list of strings.
77 wxChoice(wxWindow
* parent
, wxWindowID id
,
79 const wxSize
& size
, int n
,
80 const wxString choices
[],
82 const wxValidator
& validator
= wxDefaultValidator
,
83 const wxString
& name
= "choice");
84 wxChoice(wxWindow
* parent
, wxWindowID id
,
87 const wxArrayString
& choices
,
89 const wxValidator
& validator
= wxDefaultValidator
,
90 const wxString
& name
= "choice");
94 Destructor, destroying the choice item.
100 Creates the choice for two-step construction. See wxChoice().
102 bool Create(wxWindow
* parent
, wxWindowID id
, const wxPoint
& pos
,
103 const wxSize
& size
, int n
,
104 const wxString choices
[],
106 const wxValidator
& validator
= wxDefaultValidator
,
107 const wxString
& name
= "choice");
108 bool Create(wxWindow
* parent
, wxWindowID id
,
111 const wxArrayString
& choices
,
113 const wxValidator
& validator
= wxDefaultValidator
,
114 const wxString
& name
= "choice");
118 Gets the number of columns in this choice item.
120 @remarks This is implemented for GTK and Motif only and always
121 returns 1 for the other platforms.
123 int GetColumns() const;
126 Unlike wxControlWithItems::GetSelection() which only returns the
127 accepted selection value, i.e. the selection in the control once the
128 user closes the dropdown list, this function returns the current
129 selection. That is, while the dropdown list is shown, it returns the
130 currently selected item in it. When it is not shown, its result is the
131 same as for the other function.
134 In older versions, wxControlWithItems::GetSelection() itself
137 int GetCurrentSelection() const;
140 Sets the number of columns in this choice item.
145 @remarks This is implemented for GTK and Motif only and doesn’t do
146 anything under other platforms.
148 void SetColumns(int n
= 1);