]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/choice.h
Applied #15226 with modifications: wxRichTextCtrl: Implement setting properties with...
[wxWidgets.git] / interface / wx / choice.h
CommitLineData
23324ae1
FM
1/////////////////////////////////////////////////////////////////////////////
2// Name: choice.h
e54c96f1 3// Purpose: interface of wxChoice
23324ae1 4// Author: wxWidgets team
526954c5 5// Licence: wxWindows licence
23324ae1
FM
6/////////////////////////////////////////////////////////////////////////////
7
8/**
9 @class wxChoice
7c913512 10
23324ae1 11 A choice item is used to select one of a list of strings. Unlike a
bfac6166 12 wxListBox, only the selection is visible until the user pulls down the
23324ae1 13 menu of choices.
7c913512 14
23324ae1 15 @beginStyleTable
8c6791e4 16 @style{wxCB_SORT}
23324ae1
FM
17 Sorts the entries alphabetically.
18 @endStyleTable
7c913512 19
3051a44a 20 @beginEventEmissionTable{wxCommandEvent}
8c6791e4 21 @event{EVT_CHOICE(id, func)}
ce7fe42e 22 Process a @c wxEVT_CHOICE event, when an item on the
23324ae1
FM
23 list is selected.
24 @endEventTable
7c913512 25
23324ae1
FM
26 @library{wxcore}
27 @category{ctrl}
ce154616 28 @appearance{choice}
7c913512 29
e54c96f1 30 @see wxListBox, wxComboBox, wxCommandEvent
23324ae1 31*/
3bb9348f
VZ
32class wxChoice : public wxControl,
33 public wxItemContainer
23324ae1
FM
34{
35public:
bfac6166
BP
36 /**
37 Default constructor.
38
39 @see Create(), wxValidator
40 */
41 wxChoice();
42
23324ae1
FM
43 /**
44 Constructor, creating and showing a choice.
3c4f71cc 45
7c913512 46 @param parent
4cc4bfaf 47 Parent window. Must not be @NULL.
7c913512 48 @param id
4cc4bfaf 49 Window identifier. The value wxID_ANY indicates a default value.
7c913512 50 @param pos
4cc4bfaf 51 Window position.
dc1b07fd 52 If ::wxDefaultPosition is specified then a default position is chosen.
7c913512 53 @param size
dc1b07fd
FM
54 Window size.
55 If ::wxDefaultSize is specified then the choice is sized appropriately.
7c913512 56 @param n
4cc4bfaf 57 Number of strings with which to initialise the choice control.
7c913512 58 @param choices
4cc4bfaf 59 An array of strings with which to initialise the choice control.
7c913512 60 @param style
4cc4bfaf 61 Window style. See wxChoice.
7c913512 62 @param validator
4cc4bfaf 63 Window validator.
7c913512 64 @param name
4cc4bfaf 65 Window name.
3c4f71cc 66
4cc4bfaf 67 @see Create(), wxValidator
bfac6166 68
1058f652
MB
69 @beginWxPerlOnly
70 Not supported by wxPerl.
71 @endWxPerlOnly
23324ae1 72 */
882678eb
FM
73 wxChoice( wxWindow *parent, wxWindowID id,
74 const wxPoint& pos = wxDefaultPosition,
75 const wxSize& size = wxDefaultSize,
76 int n = 0, const wxString choices[] = NULL,
77 long style = 0,
78 const wxValidator& validator = wxDefaultValidator,
79 const wxString& name = wxChoiceNameStr );
792255cc
VZ
80
81 /**
82 Constructor, creating and showing a choice.
83
84 @param parent
85 Parent window. Must not be @NULL.
86 @param id
87 Window identifier. The value wxID_ANY indicates a default value.
88 @param pos
89 Window position.
90 @param size
91 Window size. If wxDefaultSize is specified then the choice is sized
92 appropriately.
93 @param choices
94 An array of strings with which to initialise the choice control.
95 @param style
96 Window style. See wxChoice.
97 @param validator
98 Window validator.
99 @param name
100 Window name.
101
102 @see Create(), wxValidator
103
1058f652
MB
104 @beginWxPerlOnly
105 Use an array reference for the @a choices parameter.
106 @endWxPerlOnly
792255cc 107 */
882678eb
FM
108 wxChoice( wxWindow *parent, wxWindowID id,
109 const wxPoint& pos,
110 const wxSize& size,
111 const wxArrayString& choices,
112 long style = 0,
113 const wxValidator& validator = wxDefaultValidator,
114 const wxString& name = wxChoiceNameStr );
23324ae1
FM
115
116 /**
117 Destructor, destroying the choice item.
118 */
b7e94bd7 119 virtual ~wxChoice();
23324ae1
FM
120
121 //@{
122 /**
123 Creates the choice for two-step construction. See wxChoice().
124 */
882678eb
FM
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,
129 long style = 0,
130 const wxValidator& validator = wxDefaultValidator,
131 const wxString& name = wxChoiceNameStr );
132 bool Create( wxWindow *parent, wxWindowID id,
133 const wxPoint& pos,
134 const wxSize& size,
135 const wxArrayString& choices,
136 long style = 0,
137 const wxValidator& validator = wxDefaultValidator,
138 const wxString& name = wxChoiceNameStr );
23324ae1
FM
139 //@}
140
141 /**
142 Gets the number of columns in this choice item.
3c4f71cc 143
882678eb 144 @remarks This is implemented for GTK and Motif only and always
3f16e52c 145 returns 1 for the other platforms.
23324ae1 146 */
b7e94bd7 147 virtual int GetColumns() const;
23324ae1
FM
148
149 /**
bfac6166
BP
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.
156
1e24c2af
VS
157 @since 2.6.2.
158 In older versions, wxControlWithItems::GetSelection() itself
159 behaved like this.
23324ae1 160 */
b7e94bd7 161 virtual int GetCurrentSelection() const;
23324ae1
FM
162
163 /**
164 Sets the number of columns in this choice item.
3c4f71cc 165
7c913512 166 @param n
4cc4bfaf 167 Number of columns.
bfac6166 168
882678eb 169 @remarks This is implemented for GTK and Motif only and doesn’t do
3f16e52c 170 anything under other platforms.
23324ae1 171 */
b7e94bd7 172 virtual void SetColumns(int n = 1);
8ff9b17d
RD
173
174 virtual bool IsSorted() const;
175
176 virtual unsigned int GetCount() const ;
177 virtual int GetSelection() const ;
178 virtual void SetSelection(int n);
179
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);
23324ae1 183};
e54c96f1 184