2008-03-08 08:52:38 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: checkbox.h
|
2008-03-10 11:24:38 -04:00
|
|
|
// Purpose: interface of wxCheckBox
|
2008-03-08 08:52:38 -05:00
|
|
|
// Author: wxWidgets team
|
2010-07-13 09:29:13 -04:00
|
|
|
// Licence: wxWindows licence
|
2008-03-08 08:52:38 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2011-09-18 00:38:01 -04:00
|
|
|
/*
|
|
|
|
* wxCheckBox style flags
|
|
|
|
* (Using wxCHK_* because wxCB_* is used by wxComboBox).
|
|
|
|
* Determine whether to use a 3-state or 2-state
|
|
|
|
* checkbox. 3-state enables to differentiate
|
|
|
|
* between 'unchecked', 'checked' and 'undetermined'.
|
|
|
|
*
|
|
|
|
* In addition to the styles here it is also possible to specify just 0 which
|
|
|
|
* is treated the same as wxCHK_2STATE for compatibility (but using explicit
|
|
|
|
* flag is preferred).
|
|
|
|
*/
|
|
|
|
#define wxCHK_2STATE 0x4000
|
|
|
|
#define wxCHK_3STATE 0x1000
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If this style is set the user can set the checkbox to the
|
|
|
|
* undetermined state. If not set the undetermined set can only
|
|
|
|
* be set programmatically.
|
|
|
|
* This style can only be used with 3 state checkboxes.
|
|
|
|
*/
|
|
|
|
#define wxCHK_ALLOW_3RD_STATE_FOR_USER 0x2000
|
|
|
|
|
2008-04-05 05:12:23 -04:00
|
|
|
/**
|
|
|
|
The possible states of a 3-state wxCheckBox (Compatible with the 2-state
|
|
|
|
wxCheckBox).
|
|
|
|
*/
|
|
|
|
enum wxCheckBoxState
|
|
|
|
{
|
|
|
|
wxCHK_UNCHECKED,
|
|
|
|
wxCHK_CHECKED,
|
|
|
|
wxCHK_UNDETERMINED ///< 3-state checkbox only
|
|
|
|
};
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
@class wxCheckBox
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
A checkbox is a labelled box which by default is either on (checkmark is
|
2008-04-05 05:12:23 -04:00
|
|
|
visible) or off (no checkmark). Optionally (when the wxCHK_3STATE style
|
|
|
|
flag is set) it can have a third state, called the mixed or undetermined
|
|
|
|
state. Often this is used as a "Does Not Apply" state.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@beginStyleTable
|
2008-04-06 10:43:04 -04:00
|
|
|
@style{wxCHK_2STATE}
|
2008-03-08 08:52:38 -05:00
|
|
|
Create a 2-state checkbox. This is the default.
|
2008-04-06 10:43:04 -04:00
|
|
|
@style{wxCHK_3STATE}
|
2014-05-15 19:56:58 -04:00
|
|
|
Create a 3-state checkbox. Not implemented in wxGTK1.
|
2008-04-06 10:43:04 -04:00
|
|
|
@style{wxCHK_ALLOW_3RD_STATE_FOR_USER}
|
2008-03-08 08:52:38 -05:00
|
|
|
By default a user can't set a 3-state checkbox to the third state.
|
|
|
|
It can only be done from code. Using this flags allows the user to
|
|
|
|
set the checkbox to the third state by clicking.
|
2008-04-06 10:43:04 -04:00
|
|
|
@style{wxALIGN_RIGHT}
|
2016-02-27 10:31:47 -05:00
|
|
|
Makes the text appear on the left of the checkbox.
|
2008-03-08 08:52:38 -05:00
|
|
|
@endStyleTable
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2009-02-18 12:58:51 -05:00
|
|
|
@beginEventEmissionTable{wxCommandEvent}
|
2008-04-06 10:43:04 -04:00
|
|
|
@event{EVT_CHECKBOX(id, func)}
|
2013-04-25 06:11:03 -04:00
|
|
|
Process a @c wxEVT_CHECKBOX event, when the checkbox
|
2008-03-08 08:52:38 -05:00
|
|
|
is clicked.
|
|
|
|
@endEventTable
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@library{wxcore}
|
|
|
|
@category{ctrl}
|
2012-11-03 14:32:50 -04:00
|
|
|
@appearance{checkbox}
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
@see wxRadioButton, wxCommandEvent
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
class wxCheckBox : public wxControl
|
|
|
|
{
|
|
|
|
public:
|
2008-04-05 05:12:23 -04:00
|
|
|
/**
|
|
|
|
Default constructor.
|
|
|
|
|
|
|
|
@see Create(), wxValidator
|
|
|
|
*/
|
|
|
|
wxCheckBox();
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
Constructor, creating and showing a checkbox.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param parent
|
2008-03-09 08:33:59 -04:00
|
|
|
Parent window. Must not be @NULL.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param id
|
2008-03-09 08:33:59 -04:00
|
|
|
Checkbox identifier. The value wxID_ANY indicates a default value.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param label
|
2008-03-09 08:33:59 -04:00
|
|
|
Text to be displayed next to the checkbox.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param pos
|
2009-04-21 07:21:36 -04:00
|
|
|
Checkbox position.
|
|
|
|
If ::wxDefaultPosition is specified then a default position is chosen.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param size
|
2009-04-21 07:21:36 -04:00
|
|
|
Checkbox size.
|
|
|
|
If ::wxDefaultSize is specified then a default size is chosen.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param style
|
2008-03-09 08:33:59 -04:00
|
|
|
Window style. See wxCheckBox.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param validator
|
2008-03-09 08:33:59 -04:00
|
|
|
Window validator.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param name
|
2008-03-09 08:33:59 -04:00
|
|
|
Window name.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
@see Create(), wxValidator
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-08 09:43:31 -05:00
|
|
|
wxCheckBox(wxWindow* parent, wxWindowID id,
|
|
|
|
const wxString& label,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
long style = 0,
|
2008-08-30 08:44:43 -04:00
|
|
|
const wxValidator& validator = wxDefaultValidator,
|
2008-09-21 19:48:04 -04:00
|
|
|
const wxString& name = wxCheckBoxNameStr);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Destructor, destroying the checkbox.
|
|
|
|
*/
|
2008-09-21 19:48:04 -04:00
|
|
|
virtual ~wxCheckBox();
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Creates the checkbox for two-step construction. See wxCheckBox()
|
|
|
|
for details.
|
|
|
|
*/
|
2008-09-21 19:48:04 -04:00
|
|
|
bool Create(wxWindow* parent, wxWindowID id, const wxString& label,
|
2008-03-08 08:52:38 -05:00
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
2008-09-21 19:48:04 -04:00
|
|
|
const wxSize& size = wxDefaultSize, long style = 0,
|
2008-08-30 08:44:43 -04:00
|
|
|
const wxValidator& validator = wxDefaultValidator,
|
2011-09-18 00:38:01 -04:00
|
|
|
const wxString& name = wxCheckBoxNameStr);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Gets the state of a 2-state checkbox.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-05-10 21:38:53 -04:00
|
|
|
@return Returns @true if it is checked, @false otherwise.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-09-21 19:48:04 -04:00
|
|
|
virtual bool GetValue() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
2008-04-05 05:12:23 -04:00
|
|
|
/**
|
|
|
|
Gets the state of a 3-state checkbox. Asserts when the function is used
|
|
|
|
with a 2-state checkbox.
|
|
|
|
*/
|
|
|
|
wxCheckBoxState Get3StateValue() const;
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
Returns whether or not the checkbox is a 3-state checkbox.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-05-10 21:38:53 -04:00
|
|
|
@return @true if this checkbox is a 3-state checkbox, @false if it's
|
|
|
|
a 2-state checkbox.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
bool Is3State() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-04-05 05:12:23 -04:00
|
|
|
Returns whether or not the user can set the checkbox to the third
|
|
|
|
state.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-05-10 21:38:53 -04:00
|
|
|
@return @true if the user can set the third state of this checkbox,
|
|
|
|
@false if it can only be set programmatically or if it's a
|
|
|
|
2-state checkbox.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
bool Is3rdStateAllowedForUser() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-04-05 05:12:23 -04:00
|
|
|
This is just a maybe more readable synonym for GetValue(): just as the
|
|
|
|
latter, it returns @true if the checkbox is checked and @false
|
|
|
|
otherwise.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
bool IsChecked() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the checkbox to the given state. This does not cause a
|
2013-04-25 06:11:03 -04:00
|
|
|
@c wxEVT_CHECKBOX event to get emitted.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param state
|
2008-03-09 08:33:59 -04:00
|
|
|
If @true, the check is on, otherwise it is off.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-09-21 19:48:04 -04:00
|
|
|
virtual void SetValue(bool state);
|
2008-04-05 05:12:23 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the checkbox to the given state. This does not cause a
|
2013-04-25 06:11:03 -04:00
|
|
|
@c wxEVT_CHECKBOX event to get emitted.
|
2008-04-05 05:12:23 -04:00
|
|
|
|
|
|
|
Asserts when the checkbox is a 2-state checkbox and setting the state
|
|
|
|
to wxCHK_UNDETERMINED.
|
|
|
|
*/
|
2008-09-22 14:21:32 -04:00
|
|
|
void Set3StateValue(wxCheckBoxState state);
|
2008-03-08 08:52:38 -05:00
|
|
|
};
|
2008-03-10 11:24:38 -04:00
|
|
|
|