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