]>
git.saurik.com Git - wxWidgets.git/blob - interface/wx/choice.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxChoice
4 // Author: wxWidgets team
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
12 A choice item is used to select one of a list of strings. Unlike a
13 wxListBox, only the selection is visible until the user pulls down the
18 Sorts the entries alphabetically.
21 @beginEventEmissionTable{wxCommandEvent}
22 @event{EVT_CHOICE(id, func)}
23 Process a @c wxEVT_COMMAND_CHOICE_SELECTED event, when an item on the
31 @see wxListBox, wxComboBox, wxCommandEvent
33 class wxChoice
: public wxControlWithItems
39 @see Create(), wxValidator
44 Constructor, creating and showing a choice.
47 Parent window. Must not be @NULL.
49 Window identifier. The value wxID_ANY indicates a default value.
52 If ::wxDefaultPosition is specified then a default position is chosen.
55 If ::wxDefaultSize is specified then the choice is sized appropriately.
57 Number of strings with which to initialise the choice control.
59 An array of strings with which to initialise the choice control.
61 Window style. See wxChoice.
67 @see Create(), wxValidator
70 Not supported by wxPerl.
73 wxChoice( wxWindow
*parent
, wxWindowID id
,
74 const wxPoint
& pos
= wxDefaultPosition
,
75 const wxSize
& size
= wxDefaultSize
,
76 int n
= 0, const wxString choices
[] = NULL
,
78 const wxValidator
& validator
= wxDefaultValidator
,
79 const wxString
& name
= wxChoiceNameStr
);
82 Constructor, creating and showing a choice.
85 Parent window. Must not be @NULL.
87 Window identifier. The value wxID_ANY indicates a default value.
91 Window size. If wxDefaultSize is specified then the choice is sized
94 An array of strings with which to initialise the choice control.
96 Window style. See wxChoice.
102 @see Create(), wxValidator
105 Use an array reference for the @a choices parameter.
108 wxChoice( wxWindow
*parent
, wxWindowID id
,
111 const wxArrayString
& choices
,
113 const wxValidator
& validator
= wxDefaultValidator
,
114 const wxString
& name
= wxChoiceNameStr
);
117 Destructor, destroying the choice item.
123 Creates the choice for two-step construction. See wxChoice().
125 bool Create( wxWindow
*parent
, wxWindowID id
,
126 const wxPoint
& pos
= wxDefaultPosition
,
127 const wxSize
& size
= wxDefaultSize
,
128 int n
= 0, const wxString choices
[] = NULL
,
130 const wxValidator
& validator
= wxDefaultValidator
,
131 const wxString
& name
= wxChoiceNameStr
);
132 bool Create( wxWindow
*parent
, wxWindowID id
,
135 const wxArrayString
& choices
,
137 const wxValidator
& validator
= wxDefaultValidator
,
138 const wxString
& name
= wxChoiceNameStr
);
142 Gets the number of columns in this choice item.
144 @remarks This is implemented for GTK and Motif only and always
145 returns 1 for the other platforms.
147 virtual int GetColumns() const;
150 Unlike wxControlWithItems::GetSelection() which only returns the
151 accepted selection value, i.e. the selection in the control once the
152 user closes the dropdown list, this function returns the current
153 selection. That is, while the dropdown list is shown, it returns the
154 currently selected item in it. When it is not shown, its result is the
155 same as for the other function.
158 In older versions, wxControlWithItems::GetSelection() itself
161 virtual int GetCurrentSelection() const;
164 Sets the number of columns in this choice item.
169 @remarks This is implemented for GTK and Motif only and doesn’t do
170 anything under other platforms.
172 virtual void SetColumns(int n
= 1);
174 virtual bool IsSorted() const;
176 virtual unsigned int GetCount() const ;
177 virtual int GetSelection() const ;
178 virtual void SetSelection(int n
);
180 virtual int FindString(const wxString
& s
, bool bCase
= false) const;
181 virtual wxString
GetString(unsigned int n
) const ;
182 virtual void SetString(unsigned int pos
, const wxString
& s
);