]>
git.saurik.com Git - wxWidgets.git/blob - interface/wx/checkbox.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxCheckBox
4 // Author: wxWidgets team
5 // Licence: wxWindows licence
6 /////////////////////////////////////////////////////////////////////////////
9 * wxCheckBox style flags
10 * (Using wxCHK_* because wxCB_* is used by wxComboBox).
11 * Determine whether to use a 3-state or 2-state
12 * checkbox. 3-state enables to differentiate
13 * between 'unchecked', 'checked' and 'undetermined'.
15 * In addition to the styles here it is also possible to specify just 0 which
16 * is treated the same as wxCHK_2STATE for compatibility (but using explicit
19 #define wxCHK_2STATE 0x4000
20 #define wxCHK_3STATE 0x1000
23 * If this style is set the user can set the checkbox to the
24 * undetermined state. If not set the undetermined set can only
25 * be set programmatically.
26 * This style can only be used with 3 state checkboxes.
28 #define wxCHK_ALLOW_3RD_STATE_FOR_USER 0x2000
31 The possible states of a 3-state wxCheckBox (Compatible with the 2-state
38 wxCHK_UNDETERMINED
///< 3-state checkbox only
44 A checkbox is a labelled box which by default is either on (checkmark is
45 visible) or off (no checkmark). Optionally (when the wxCHK_3STATE style
46 flag is set) it can have a third state, called the mixed or undetermined
47 state. Often this is used as a "Does Not Apply" state.
51 Create a 2-state checkbox. This is the default.
53 Create a 3-state checkbox. Not implemented in wxOS2 and
54 wxGTK built against GTK+ 1.2.
55 @style{wxCHK_ALLOW_3RD_STATE_FOR_USER}
56 By default a user can't set a 3-state checkbox to the third state.
57 It can only be done from code. Using this flags allows the user to
58 set the checkbox to the third state by clicking.
60 Makes the text appear on the left of the checkbox.
63 @beginEventEmissionTable{wxCommandEvent}
64 @event{EVT_CHECKBOX(id, func)}
65 Process a @c wxEVT_CHECKBOX event, when the checkbox
73 @see wxRadioButton, wxCommandEvent
75 class wxCheckBox
: public wxControl
81 @see Create(), wxValidator
86 Constructor, creating and showing a checkbox.
89 Parent window. Must not be @NULL.
91 Checkbox identifier. The value wxID_ANY indicates a default value.
93 Text to be displayed next to the checkbox.
96 If ::wxDefaultPosition is specified then a default position is chosen.
99 If ::wxDefaultSize is specified then a default size is chosen.
101 Window style. See wxCheckBox.
107 @see Create(), wxValidator
109 wxCheckBox(wxWindow
* parent
, wxWindowID id
,
110 const wxString
& label
,
111 const wxPoint
& pos
= wxDefaultPosition
,
112 const wxSize
& size
= wxDefaultSize
,
114 const wxValidator
& validator
= wxDefaultValidator
,
115 const wxString
& name
= wxCheckBoxNameStr
);
118 Destructor, destroying the checkbox.
120 virtual ~wxCheckBox();
123 Creates the checkbox for two-step construction. See wxCheckBox()
126 bool Create(wxWindow
* parent
, wxWindowID id
, const wxString
& label
,
127 const wxPoint
& pos
= wxDefaultPosition
,
128 const wxSize
& size
= wxDefaultSize
, long style
= 0,
129 const wxValidator
& validator
= wxDefaultValidator
,
130 const wxString
& name
= wxCheckBoxNameStr
);
133 Gets the state of a 2-state checkbox.
135 @return Returns @true if it is checked, @false otherwise.
137 virtual bool GetValue() const;
140 Gets the state of a 3-state checkbox. Asserts when the function is used
141 with a 2-state checkbox.
143 wxCheckBoxState
Get3StateValue() const;
146 Returns whether or not the checkbox is a 3-state checkbox.
148 @return @true if this checkbox is a 3-state checkbox, @false if it's
151 bool Is3State() const;
154 Returns whether or not the user can set the checkbox to the third
157 @return @true if the user can set the third state of this checkbox,
158 @false if it can only be set programmatically or if it's a
161 bool Is3rdStateAllowedForUser() const;
164 This is just a maybe more readable synonym for GetValue(): just as the
165 latter, it returns @true if the checkbox is checked and @false
168 bool IsChecked() const;
171 Sets the checkbox to the given state. This does not cause a
172 @c wxEVT_CHECKBOX event to get emitted.
175 If @true, the check is on, otherwise it is off.
177 virtual void SetValue(bool state
);
180 Sets the checkbox to the given state. This does not cause a
181 @c wxEVT_CHECKBOX event to get emitted.
183 Asserts when the checkbox is a 2-state checkbox and setting the state
184 to wxCHK_UNDETERMINED.
186 void Set3StateValue(wxCheckBoxState state
);