]> git.saurik.com Git - wxWidgets.git/blame - interface/checkbox.h
execute the usual cleanup code from EVT_END_SESSION handler under MSW, otherwise...
[wxWidgets.git] / interface / 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$
6// Licence: wxWindows license
7/////////////////////////////////////////////////////////////////////////////
8
bfac6166
BP
9/**
10 The possible states of a 3-state wxCheckBox (Compatible with the 2-state
11 wxCheckBox).
12*/
13enum wxCheckBoxState
14{
15 wxCHK_UNCHECKED,
16 wxCHK_CHECKED,
17 wxCHK_UNDETERMINED ///< 3-state checkbox only
18};
19
23324ae1
FM
20/**
21 @class wxCheckBox
22 @wxheader{checkbox.h}
7c913512 23
23324ae1 24 A checkbox is a labelled box which by default is either on (checkmark is
bfac6166
BP
25 visible) or off (no checkmark). Optionally (when the wxCHK_3STATE style
26 flag is set) it can have a third state, called the mixed or undetermined
27 state. Often this is used as a "Does Not Apply" state.
7c913512 28
23324ae1 29 @beginStyleTable
8c6791e4 30 @style{wxCHK_2STATE}
23324ae1 31 Create a 2-state checkbox. This is the default.
8c6791e4 32 @style{wxCHK_3STATE}
23324ae1
FM
33 Create a 3-state checkbox. Not implemented in wxMGL, wxOS2 and
34 wxGTK built against GTK+ 1.2.
8c6791e4 35 @style{wxCHK_ALLOW_3RD_STATE_FOR_USER}
23324ae1
FM
36 By default a user can't set a 3-state checkbox to the third state.
37 It can only be done from code. Using this flags allows the user to
38 set the checkbox to the third state by clicking.
8c6791e4 39 @style{wxALIGN_RIGHT}
23324ae1
FM
40 Makes the text appear on the left of the checkbox.
41 @endStyleTable
7c913512 42
1f1d2182 43 @beginEventTable{wxCommandEvent}
8c6791e4 44 @event{EVT_CHECKBOX(id, func)}
23324ae1
FM
45 Process a wxEVT_COMMAND_CHECKBOX_CLICKED event, when the checkbox
46 is clicked.
47 @endEventTable
7c913512 48
23324ae1
FM
49 @library{wxcore}
50 @category{ctrl}
bfac6166 51 <!-- @appearance{checkbox.png} -->
7c913512 52
e54c96f1 53 @see wxRadioButton, wxCommandEvent
23324ae1
FM
54*/
55class wxCheckBox : public wxControl
56{
57public:
bfac6166
BP
58 /**
59 Default constructor.
60
61 @see Create(), wxValidator
62 */
63 wxCheckBox();
64
23324ae1
FM
65 /**
66 Constructor, creating and showing a checkbox.
3c4f71cc 67
7c913512 68 @param parent
4cc4bfaf 69 Parent window. Must not be @NULL.
7c913512 70 @param id
4cc4bfaf 71 Checkbox identifier. The value wxID_ANY indicates a default value.
7c913512 72 @param label
4cc4bfaf 73 Text to be displayed next to the checkbox.
7c913512 74 @param pos
4cc4bfaf 75 Checkbox position. If wxDefaultPosition is specified then a default
bfac6166 76 position is chosen.
7c913512 77 @param size
bfac6166
BP
78 Checkbox size. If wxDefaultSize is specified then a default size is
79 chosen.
7c913512 80 @param style
4cc4bfaf 81 Window style. See wxCheckBox.
7c913512 82 @param validator
4cc4bfaf 83 Window validator.
7c913512 84 @param name
4cc4bfaf 85 Window name.
3c4f71cc 86
4cc4bfaf 87 @see Create(), wxValidator
23324ae1 88 */
7c913512
FM
89 wxCheckBox(wxWindow* parent, wxWindowID id,
90 const wxString& label,
91 const wxPoint& pos = wxDefaultPosition,
92 const wxSize& size = wxDefaultSize,
93 long style = 0,
1d497b99 94 const wxValidator& val = wxDefaultValidator,
7c913512 95 const wxString& name = "checkBox");
23324ae1
FM
96
97 /**
98 Destructor, destroying the checkbox.
99 */
100 ~wxCheckBox();
101
102 /**
103 Creates the checkbox for two-step construction. See wxCheckBox()
104 for details.
105 */
106 bool Create(wxWindow* parent, wxWindowID id,
107 const wxString& label,
108 const wxPoint& pos = wxDefaultPosition,
109 const wxSize& size = wxDefaultSize,
110 long style = 0,
1d497b99 111 const wxValidator& val = wxDefaultValidator,
23324ae1
FM
112 const wxString& name = "checkBox");
113
23324ae1
FM
114 /**
115 Gets the state of a 2-state checkbox.
3c4f71cc 116
23324ae1
FM
117 @returns Returns @true if it is checked, @false otherwise.
118 */
328f5751 119 bool GetValue() const;
23324ae1 120
bfac6166
BP
121 /**
122 Gets the state of a 3-state checkbox. Asserts when the function is used
123 with a 2-state checkbox.
124 */
125 wxCheckBoxState Get3StateValue() const;
126
23324ae1
FM
127 /**
128 Returns whether or not the checkbox is a 3-state checkbox.
3c4f71cc 129
bfac6166
BP
130 @returns Returns @true if this checkbox is a 3-state checkbox, @false
131 if it's a 2-state checkbox.
23324ae1 132 */
328f5751 133 bool Is3State() const;
23324ae1
FM
134
135 /**
bfac6166
BP
136 Returns whether or not the user can set the checkbox to the third
137 state.
3c4f71cc 138
23324ae1 139 @returns Returns @true if the user can set the third state of this
bfac6166
BP
140 checkbox, @false if it can only be set programmatically or if
141 it's a 2-state checkbox.
23324ae1 142 */
328f5751 143 bool Is3rdStateAllowedForUser() const;
23324ae1
FM
144
145 /**
bfac6166
BP
146 This is just a maybe more readable synonym for GetValue(): just as the
147 latter, it returns @true if the checkbox is checked and @false
148 otherwise.
23324ae1 149 */
328f5751 150 bool IsChecked() const;
23324ae1
FM
151
152 /**
153 Sets the checkbox to the given state. This does not cause a
154 wxEVT_COMMAND_CHECKBOX_CLICKED event to get emitted.
3c4f71cc 155
7c913512 156 @param state
4cc4bfaf 157 If @true, the check is on, otherwise it is off.
23324ae1
FM
158 */
159 void SetValue(bool state);
bfac6166
BP
160
161 /**
162 Sets the checkbox to the given state. This does not cause a
163 wxEVT_COMMAND_CHECKBOX_CLICKED event to get emitted.
164
165 Asserts when the checkbox is a 2-state checkbox and setting the state
166 to wxCHK_UNDETERMINED.
167 */
168 void Set3StateValue(const wxCheckBoxState state);
23324ae1 169};
e54c96f1 170