]>
git.saurik.com Git - wxWidgets.git/blob - interface/wx/checkbox.h
60d8135c026c24eb776218f828b7d6741c4e58a3
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxCheckBox
4 // Author: wxWidgets team
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
10 * wxCheckBox style flags
11 * (Using wxCHK_* because wxCB_* is used by wxComboBox).
12 * Determine whether to use a 3-state or 2-state
13 * checkbox. 3-state enables to differentiate
14 * between 'unchecked', 'checked' and 'undetermined'.
16 * In addition to the styles here it is also possible to specify just 0 which
17 * is treated the same as wxCHK_2STATE for compatibility (but using explicit
20 #define wxCHK_2STATE 0x4000
21 #define wxCHK_3STATE 0x1000
24 * If this style is set the user can set the checkbox to the
25 * undetermined state. If not set the undetermined set can only
26 * be set programmatically.
27 * This style can only be used with 3 state checkboxes.
29 #define wxCHK_ALLOW_3RD_STATE_FOR_USER 0x2000
32 The possible states of a 3-state wxCheckBox (Compatible with the 2-state
39 wxCHK_UNDETERMINED
///< 3-state checkbox only
45 A checkbox is a labelled box which by default is either on (checkmark is
46 visible) or off (no checkmark). Optionally (when the wxCHK_3STATE style
47 flag is set) it can have a third state, called the mixed or undetermined
48 state. Often this is used as a "Does Not Apply" state.
52 Create a 2-state checkbox. This is the default.
54 Create a 3-state checkbox. Not implemented in wxOS2 and
55 wxGTK built against GTK+ 1.2.
56 @style{wxCHK_ALLOW_3RD_STATE_FOR_USER}
57 By default a user can't set a 3-state checkbox to the third state.
58 It can only be done from code. Using this flags allows the user to
59 set the checkbox to the third state by clicking.
61 Makes the text appear on the left of the checkbox.
64 @beginEventEmissionTable{wxCommandEvent}
65 @event{EVT_CHECKBOX(id, func)}
66 Process a @c wxEVT_COMMAND_CHECKBOX_CLICKED event, when the checkbox
74 @see wxRadioButton, wxCommandEvent
76 class wxCheckBox
: public wxControl
82 @see Create(), wxValidator
87 Constructor, creating and showing a checkbox.
90 Parent window. Must not be @NULL.
92 Checkbox identifier. The value wxID_ANY indicates a default value.
94 Text to be displayed next to the checkbox.
97 If ::wxDefaultPosition is specified then a default position is chosen.
100 If ::wxDefaultSize is specified then a default size is chosen.
102 Window style. See wxCheckBox.
108 @see Create(), wxValidator
110 wxCheckBox(wxWindow
* parent
, wxWindowID id
,
111 const wxString
& label
,
112 const wxPoint
& pos
= wxDefaultPosition
,
113 const wxSize
& size
= wxDefaultSize
,
115 const wxValidator
& validator
= wxDefaultValidator
,
116 const wxString
& name
= wxCheckBoxNameStr
);
119 Destructor, destroying the checkbox.
121 virtual ~wxCheckBox();
124 Creates the checkbox for two-step construction. See wxCheckBox()
127 bool Create(wxWindow
* parent
, wxWindowID id
, const wxString
& label
,
128 const wxPoint
& pos
= wxDefaultPosition
,
129 const wxSize
& size
= wxDefaultSize
, long style
= 0,
130 const wxValidator
& validator
= wxDefaultValidator
,
131 const wxString
& name
= wxCheckBoxNameStr
);
134 Gets the state of a 2-state checkbox.
136 @return Returns @true if it is checked, @false otherwise.
138 virtual bool GetValue() const;
141 Gets the state of a 3-state checkbox. Asserts when the function is used
142 with a 2-state checkbox.
144 wxCheckBoxState
Get3StateValue() const;
147 Returns whether or not the checkbox is a 3-state checkbox.
149 @return @true if this checkbox is a 3-state checkbox, @false if it's
152 bool Is3State() const;
155 Returns whether or not the user can set the checkbox to the third
158 @return @true if the user can set the third state of this checkbox,
159 @false if it can only be set programmatically or if it's a
162 bool Is3rdStateAllowedForUser() const;
165 This is just a maybe more readable synonym for GetValue(): just as the
166 latter, it returns @true if the checkbox is checked and @false
169 bool IsChecked() const;
172 Sets the checkbox to the given state. This does not cause a
173 @c wxEVT_COMMAND_CHECKBOX_CLICKED event to get emitted.
176 If @true, the check is on, otherwise it is off.
178 virtual void SetValue(bool state
);
181 Sets the checkbox to the given state. This does not cause a
182 @c wxEVT_COMMAND_CHECKBOX_CLICKED event to get emitted.
184 Asserts when the checkbox is a 2-state checkbox and setting the state
185 to wxCHK_UNDETERMINED.
187 void Set3StateValue(wxCheckBoxState state
);