]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/checkbox.h
Add wxTimer::StartOnce().
[wxWidgets.git] / interface / wx / checkbox.h
CommitLineData
23324ae1
FM
1/////////////////////////////////////////////////////////////////////////////
2// Name: checkbox.h
e54c96f1 3// Purpose: interface of wxCheckBox
23324ae1
FM
4// Author: wxWidgets team
5// RCS-ID: $Id$
526954c5 6// Licence: wxWindows licence
23324ae1
FM
7/////////////////////////////////////////////////////////////////////////////
8
ba4f890e
RD
9/*
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'.
15 *
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
18 * flag is preferred).
19 */
20#define wxCHK_2STATE 0x4000
21#define wxCHK_3STATE 0x1000
22
23/*
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.
28 */
29#define wxCHK_ALLOW_3RD_STATE_FOR_USER 0x2000
30
bfac6166
BP
31/**
32 The possible states of a 3-state wxCheckBox (Compatible with the 2-state
33 wxCheckBox).
34*/
35enum wxCheckBoxState
36{
37 wxCHK_UNCHECKED,
38 wxCHK_CHECKED,
39 wxCHK_UNDETERMINED ///< 3-state checkbox only
40};
41
23324ae1
FM
42/**
43 @class wxCheckBox
7c913512 44
23324ae1 45 A checkbox is a labelled box which by default is either on (checkmark is
bfac6166
BP
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.
7c913512 49
23324ae1 50 @beginStyleTable
8c6791e4 51 @style{wxCHK_2STATE}
23324ae1 52 Create a 2-state checkbox. This is the default.
8c6791e4 53 @style{wxCHK_3STATE}
0e1f8ea4 54 Create a 3-state checkbox. Not implemented in wxOS2 and
23324ae1 55 wxGTK built against GTK+ 1.2.
8c6791e4 56 @style{wxCHK_ALLOW_3RD_STATE_FOR_USER}
23324ae1
FM
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.
8c6791e4 60 @style{wxALIGN_RIGHT}
23324ae1
FM
61 Makes the text appear on the left of the checkbox.
62 @endStyleTable
7c913512 63
3051a44a 64 @beginEventEmissionTable{wxCommandEvent}
8c6791e4 65 @event{EVT_CHECKBOX(id, func)}
ce7fe42e 66 Process a @c wxEVT_CHECKBOX event, when the checkbox
23324ae1
FM
67 is clicked.
68 @endEventTable
7c913512 69
23324ae1
FM
70 @library{wxcore}
71 @category{ctrl}
ce154616 72 @appearance{checkbox}
7c913512 73
e54c96f1 74 @see wxRadioButton, wxCommandEvent
23324ae1
FM
75*/
76class wxCheckBox : public wxControl
77{
78public:
bfac6166
BP
79 /**
80 Default constructor.
81
82 @see Create(), wxValidator
83 */
84 wxCheckBox();
85
23324ae1
FM
86 /**
87 Constructor, creating and showing a checkbox.
3c4f71cc 88
7c913512 89 @param parent
4cc4bfaf 90 Parent window. Must not be @NULL.
7c913512 91 @param id
4cc4bfaf 92 Checkbox identifier. The value wxID_ANY indicates a default value.
7c913512 93 @param label
4cc4bfaf 94 Text to be displayed next to the checkbox.
7c913512 95 @param pos
dc1b07fd
FM
96 Checkbox position.
97 If ::wxDefaultPosition is specified then a default position is chosen.
7c913512 98 @param size
dc1b07fd
FM
99 Checkbox size.
100 If ::wxDefaultSize is specified then a default size is chosen.
7c913512 101 @param style
4cc4bfaf 102 Window style. See wxCheckBox.
7c913512 103 @param validator
4cc4bfaf 104 Window validator.
7c913512 105 @param name
4cc4bfaf 106 Window name.
3c4f71cc 107
4cc4bfaf 108 @see Create(), wxValidator
23324ae1 109 */
7c913512
FM
110 wxCheckBox(wxWindow* parent, wxWindowID id,
111 const wxString& label,
112 const wxPoint& pos = wxDefaultPosition,
113 const wxSize& size = wxDefaultSize,
114 long style = 0,
792255cc 115 const wxValidator& validator = wxDefaultValidator,
9d9c1c24 116 const wxString& name = wxCheckBoxNameStr);
23324ae1
FM
117
118 /**
119 Destructor, destroying the checkbox.
120 */
9d9c1c24 121 virtual ~wxCheckBox();
23324ae1
FM
122
123 /**
124 Creates the checkbox for two-step construction. See wxCheckBox()
125 for details.
126 */
9d9c1c24 127 bool Create(wxWindow* parent, wxWindowID id, const wxString& label,
23324ae1 128 const wxPoint& pos = wxDefaultPosition,
9d9c1c24 129 const wxSize& size = wxDefaultSize, long style = 0,
792255cc 130 const wxValidator& validator = wxDefaultValidator,
ba4f890e 131 const wxString& name = wxCheckBoxNameStr);
23324ae1 132
23324ae1
FM
133 /**
134 Gets the state of a 2-state checkbox.
3c4f71cc 135
d29a9a8a 136 @return Returns @true if it is checked, @false otherwise.
23324ae1 137 */
9d9c1c24 138 virtual bool GetValue() const;
23324ae1 139
bfac6166
BP
140 /**
141 Gets the state of a 3-state checkbox. Asserts when the function is used
142 with a 2-state checkbox.
143 */
144 wxCheckBoxState Get3StateValue() const;
145
23324ae1
FM
146 /**
147 Returns whether or not the checkbox is a 3-state checkbox.
3c4f71cc 148
d29a9a8a
BP
149 @return @true if this checkbox is a 3-state checkbox, @false if it's
150 a 2-state checkbox.
23324ae1 151 */
328f5751 152 bool Is3State() const;
23324ae1
FM
153
154 /**
bfac6166
BP
155 Returns whether or not the user can set the checkbox to the third
156 state.
3c4f71cc 157
d29a9a8a
BP
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
160 2-state checkbox.
23324ae1 161 */
328f5751 162 bool Is3rdStateAllowedForUser() const;
23324ae1
FM
163
164 /**
bfac6166
BP
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
167 otherwise.
23324ae1 168 */
328f5751 169 bool IsChecked() const;
23324ae1
FM
170
171 /**
172 Sets the checkbox to the given state. This does not cause a
ce7fe42e 173 @c wxEVT_CHECKBOX event to get emitted.
3c4f71cc 174
7c913512 175 @param state
4cc4bfaf 176 If @true, the check is on, otherwise it is off.
23324ae1 177 */
9d9c1c24 178 virtual void SetValue(bool state);
bfac6166
BP
179
180 /**
181 Sets the checkbox to the given state. This does not cause a
ce7fe42e 182 @c wxEVT_CHECKBOX event to get emitted.
bfac6166
BP
183
184 Asserts when the checkbox is a 2-state checkbox and setting the state
185 to wxCHK_UNDETERMINED.
186 */
62a7da75 187 void Set3StateValue(wxCheckBoxState state);
23324ae1 188};
e54c96f1 189