]> git.saurik.com Git - wxWidgets.git/blame - interface/choice.h
added wxString::Clone() and made wxString(wxCStrData) ctor make deep copy too
[wxWidgets.git] / interface / choice.h
CommitLineData
23324ae1
FM
1/////////////////////////////////////////////////////////////////////////////
2// Name: choice.h
e54c96f1 3// Purpose: interface of wxChoice
23324ae1
FM
4// Author: wxWidgets team
5// RCS-ID: $Id$
6// Licence: wxWindows license
7/////////////////////////////////////////////////////////////////////////////
8
9/**
10 @class wxChoice
11 @wxheader{choice.h}
7c913512 12
23324ae1 13 A choice item is used to select one of a list of strings. Unlike a
bfac6166 14 wxListBox, only the selection is visible until the user pulls down the
23324ae1 15 menu of choices.
7c913512 16
23324ae1 17 @beginStyleTable
8c6791e4 18 @style{wxCB_SORT}
23324ae1
FM
19 Sorts the entries alphabetically.
20 @endStyleTable
7c913512 21
1f1d2182 22 @beginEventTable{wxCommandEvent}
8c6791e4 23 @event{EVT_CHOICE(id, func)}
23324ae1
FM
24 Process a wxEVT_COMMAND_CHOICE_SELECTED event, when an item on the
25 list is selected.
26 @endEventTable
7c913512 27
23324ae1
FM
28 @library{wxcore}
29 @category{ctrl}
bfac6166 30 <!-- @appearance{choice.png} -->
7c913512 31
e54c96f1 32 @see wxListBox, wxComboBox, wxCommandEvent
23324ae1
FM
33*/
34class wxChoice : public wxControlWithItems
35{
36public:
bfac6166
BP
37 /**
38 Default constructor.
39
40 @see Create(), wxValidator
41 */
42 wxChoice();
43
23324ae1
FM
44 //@{
45 /**
46 Constructor, creating and showing a choice.
3c4f71cc 47
7c913512 48 @param parent
4cc4bfaf 49 Parent window. Must not be @NULL.
7c913512 50 @param id
4cc4bfaf 51 Window identifier. The value wxID_ANY indicates a default value.
7c913512 52 @param pos
4cc4bfaf 53 Window position.
7c913512 54 @param size
bfac6166 55 Window size. If wxDefaultSize is specified then the choice is sized
4cc4bfaf 56 appropriately.
7c913512 57 @param n
4cc4bfaf 58 Number of strings with which to initialise the choice control.
7c913512 59 @param choices
4cc4bfaf 60 An array of strings with which to initialise the choice control.
7c913512 61 @param style
4cc4bfaf 62 Window style. See wxChoice.
7c913512 63 @param validator
4cc4bfaf 64 Window validator.
7c913512 65 @param name
4cc4bfaf 66 Window name.
3c4f71cc 67
4cc4bfaf 68 @see Create(), wxValidator
bfac6166
BP
69
70 @beginWxPythonOnly
71
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.
74
75 @endWxPythonOnly
23324ae1 76 */
4cc4bfaf 77 wxChoice(wxWindow* parent, wxWindowID id,
7c913512
FM
78 const wxPoint& pos,
79 const wxSize& size, int n,
80 const wxString choices[],
81 long style = 0,
82 const wxValidator& validator = wxDefaultValidator,
83 const wxString& name = "choice");
4cc4bfaf 84 wxChoice(wxWindow* parent, wxWindowID id,
7c913512
FM
85 const wxPoint& pos,
86 const wxSize& size,
87 const wxArrayString& choices,
88 long style = 0,
89 const wxValidator& validator = wxDefaultValidator,
90 const wxString& name = "choice");
23324ae1
FM
91 //@}
92
93 /**
94 Destructor, destroying the choice item.
95 */
96 ~wxChoice();
97
98 //@{
99 /**
100 Creates the choice for two-step construction. See wxChoice().
101 */
4cc4bfaf 102 bool Create(wxWindow* parent, wxWindowID id, const wxPoint& pos,
23324ae1
FM
103 const wxSize& size, int n,
104 const wxString choices[],
105 long style = 0,
106 const wxValidator& validator = wxDefaultValidator,
107 const wxString& name = "choice");
4cc4bfaf 108 bool Create(wxWindow* parent, wxWindowID id,
7c913512
FM
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 = "choice");
23324ae1
FM
115 //@}
116
117 /**
118 Gets the number of columns in this choice item.
3c4f71cc 119
bfac6166
BP
120 @remarks This is implemented for Motif only and always returns 1 for
121 the other platforms.
23324ae1 122 */
328f5751 123 int GetColumns() const;
23324ae1
FM
124
125 /**
bfac6166
BP
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.
132
1e24c2af
VS
133 @since 2.6.2.
134 In older versions, wxControlWithItems::GetSelection() itself
135 behaved like this.
23324ae1 136 */
328f5751 137 int GetCurrentSelection() const;
23324ae1
FM
138
139 /**
140 Sets the number of columns in this choice item.
3c4f71cc 141
7c913512 142 @param n
4cc4bfaf 143 Number of columns.
bfac6166
BP
144
145 @remarks This is implemented for Motif only and doesn’t do anything
146 under other platforms.
23324ae1
FM
147 */
148 void SetColumns(int n = 1);
149};
e54c96f1 150