1 ///////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxCheckBox class interface
4 // Author: Vadim Zeitlin
8 // Copyright: (c) wxWidgets team
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_CHECKBOX_H_BASE_
13 #define _WX_CHECKBOX_H_BASE_
19 #include "wx/control.h"
23 * wxCheckBox style flags
24 * (Using wxCHK_* because wxCB_* is used by wxComboBox).
25 * Determine whether to use a 3-state or 2-state
26 * checkbox. 3-state enables to differentiate
27 * between 'unchecked', 'checked' and 'undetermined'.
29 #define wxCHK_2STATE 0x0000
30 #define wxCHK_3STATE 0x1000
33 * If this style is set the user can set the checkbox to the
34 * undetermined state. If not set the undetermined set can only
35 * be set programmatically.
36 * This style can only be used with 3 state checkboxes.
38 #define wxCHK_ALLOW_3RD_STATE_FOR_USER 0x2000
41 * The possible states of a 3-state checkbox (Compatible
42 * with the 2-state checkbox).
48 wxCHK_UNDETERMINED
/* 3-state checkbox only */
52 extern WXDLLIMPEXP_DATA_CORE(const char) wxCheckBoxNameStr
[];
54 // ----------------------------------------------------------------------------
55 // wxCheckBox: a control which shows a label and a box which may be checked
56 // ----------------------------------------------------------------------------
58 class WXDLLIMPEXP_CORE wxCheckBoxBase
: public wxControl
63 // set/get the checked status of the listbox
64 virtual void SetValue(bool value
) = 0;
65 virtual bool GetValue() const = 0;
67 bool IsChecked() const
69 wxASSERT_MSG( !Is3State(), wxT("Calling IsChecked() doesn't make sense for")
70 wxT(" a three state checkbox, Use Get3StateValue() instead") );
75 wxCheckBoxState
Get3StateValue() const
77 wxCheckBoxState state
= DoGet3StateValue();
79 if ( state
== wxCHK_UNDETERMINED
&& !Is3State() )
81 // Undetermined state with a 2-state checkbox??
82 wxFAIL_MSG( wxT("DoGet3StateValue() says the 2-state checkbox is ")
83 wxT("in an undetermined/third state") );
85 state
= wxCHK_UNCHECKED
;
91 void Set3StateValue(wxCheckBoxState state
)
93 if ( state
== wxCHK_UNDETERMINED
&& !Is3State() )
95 wxFAIL_MSG(wxT("Setting a 2-state checkbox to undetermined state"));
96 state
= wxCHK_UNCHECKED
;
99 DoSet3StateValue(state
);
102 bool Is3State() const { return HasFlag(wxCHK_3STATE
); }
104 bool Is3rdStateAllowedForUser() const
106 return HasFlag(wxCHK_ALLOW_3RD_STATE_FOR_USER
);
109 virtual bool HasTransparentBackground() { return true; }
111 // wxCheckBox-specific processing after processing the update event
112 virtual void DoUpdateWindowUI(wxUpdateUIEvent
& event
)
114 wxControl::DoUpdateWindowUI(event
);
116 if ( event
.GetSetChecked() )
117 SetValue(event
.GetChecked());
121 // choose the default border for this window
122 virtual wxBorder
GetDefaultBorder() const { return wxBORDER_NONE
; }
124 virtual void DoSet3StateValue(wxCheckBoxState
WXUNUSED(state
)) { wxFAIL
; }
126 virtual wxCheckBoxState
DoGet3StateValue() const
129 return wxCHK_UNCHECKED
;
133 wxDECLARE_NO_COPY_CLASS(wxCheckBoxBase
);
136 #if defined(__WXUNIVERSAL__)
137 #include "wx/univ/checkbox.h"
138 #elif defined(__WXMSW__)
139 #include "wx/msw/checkbox.h"
140 #elif defined(__WXMOTIF__)
141 #include "wx/motif/checkbox.h"
142 #elif defined(__WXGTK20__)
143 #include "wx/gtk/checkbox.h"
144 #elif defined(__WXGTK__)
145 #include "wx/gtk1/checkbox.h"
146 #elif defined(__WXMAC__)
147 #include "wx/osx/checkbox.h"
148 #elif defined(__WXCOCOA__)
149 #include "wx/cocoa/checkbox.h"
150 #elif defined(__WXPM__)
151 #include "wx/os2/checkbox.h"
152 #elif defined(__WXPALMOS__)
153 #include "wx/palmos/checkbox.h"
156 #endif // wxUSE_CHECKBOX
159 // _WX_CHECKBOX_H_BASE_