]> git.saurik.com Git - wxWidgets.git/blame - interface/choice.h
use a different method to prevent an early size_allocate,
[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
FM
13 A choice item is used to select one of a list of strings. Unlike a
14 listbox, only the selection is visible until the user pulls down the
15 menu of choices.
7c913512 16
23324ae1
FM
17 @beginStyleTable
18 @style{wxCB_SORT}:
19 Sorts the entries alphabetically.
20 @endStyleTable
7c913512 21
23324ae1 22 @beginEventTable
4cc4bfaf 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}
30 @appearance{choice.png}
7c913512 31
e54c96f1 32 @see wxListBox, wxComboBox, wxCommandEvent
23324ae1
FM
33*/
34class wxChoice : public wxControlWithItems
35{
36public:
37 //@{
38 /**
39 Constructor, creating and showing a choice.
40
7c913512 41 @param parent
4cc4bfaf 42 Parent window. Must not be @NULL.
7c913512 43 @param id
4cc4bfaf 44 Window identifier. The value wxID_ANY indicates a default value.
7c913512 45 @param pos
4cc4bfaf 46 Window position.
7c913512 47 @param size
4cc4bfaf
FM
48 Window size. If wxDefaultSize is specified then the choice is
49 sized
50 appropriately.
7c913512 51 @param n
4cc4bfaf 52 Number of strings with which to initialise the choice control.
7c913512 53 @param choices
4cc4bfaf 54 An array of strings with which to initialise the choice control.
7c913512 55 @param style
4cc4bfaf 56 Window style. See wxChoice.
7c913512 57 @param validator
4cc4bfaf 58 Window validator.
7c913512 59 @param name
4cc4bfaf 60 Window name.
23324ae1 61
4cc4bfaf 62 @see Create(), wxValidator
23324ae1
FM
63 */
64 wxChoice();
4cc4bfaf 65 wxChoice(wxWindow* parent, wxWindowID id,
7c913512
FM
66 const wxPoint& pos,
67 const wxSize& size, int n,
68 const wxString choices[],
69 long style = 0,
70 const wxValidator& validator = wxDefaultValidator,
71 const wxString& name = "choice");
4cc4bfaf 72 wxChoice(wxWindow* parent, wxWindowID id,
7c913512
FM
73 const wxPoint& pos,
74 const wxSize& size,
75 const wxArrayString& choices,
76 long style = 0,
77 const wxValidator& validator = wxDefaultValidator,
78 const wxString& name = "choice");
23324ae1
FM
79 //@}
80
81 /**
82 Destructor, destroying the choice item.
83 */
84 ~wxChoice();
85
86 //@{
87 /**
88 Creates the choice for two-step construction. See wxChoice().
89 */
4cc4bfaf 90 bool Create(wxWindow* parent, wxWindowID id, const wxPoint& pos,
23324ae1
FM
91 const wxSize& size, int n,
92 const wxString choices[],
93 long style = 0,
94 const wxValidator& validator = wxDefaultValidator,
95 const wxString& name = "choice");
4cc4bfaf 96 bool Create(wxWindow* parent, wxWindowID id,
7c913512
FM
97 const wxPoint& pos,
98 const wxSize& size,
99 const wxArrayString& choices,
100 long style = 0,
101 const wxValidator& validator = wxDefaultValidator,
102 const wxString& name = "choice");
23324ae1
FM
103 //@}
104
105 /**
106 Gets the number of columns in this choice item.
107
108 @remarks This is implemented for Motif only and always returns 1 for the
4cc4bfaf 109 other platforms.
23324ae1 110 */
328f5751 111 int GetColumns() const;
23324ae1
FM
112
113 /**
114 Unlike wxControlWithItems::GetSelection which only
115 returns the accepted selection value, i.e. the selection in the control once
116 the user closes the dropdown list, this function returns the current selection.
117 That is, while the dropdown list is shown, it returns the currently selected
118 item in it. When it is not shown, its result is the same as for the other
119 function.
e54c96f1
FM
120
121 @wxsince{2.6.2} (before this version
23324ae1
FM
122 wxControlWithItems::GetSelection itself behaved like
123 this).
124 */
328f5751 125 int GetCurrentSelection() const;
23324ae1
FM
126
127 /**
128 Sets the number of columns in this choice item.
129
7c913512 130 @param n
4cc4bfaf 131 Number of columns.
23324ae1
FM
132 */
133 void SetColumns(int n = 1);
134};
e54c96f1 135