wxCheckBox

A checkbox is a labelled box which by default is either on (checkmark is 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.

Derived from

wxControl
wxWindow
wxEvtHandler
wxObject

Include files

<wx/checkbox.h>

Window styles

wxCHK_2STATE Create a 2-state checkbox. This is the default.
wxCHK_3STATE Create a 3-state checkbox. Not implemented in wxMGL, wxOS2 and wxGTK built against GTK+ 1.2.
wxCHK_ALLOW_3RD_STATE_FOR_USER 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.
wxALIGN_RIGHT Makes the text appear on the left of the checkbox.

See also window styles overview.

Event handling

EVT_CHECKBOX(id, func) Process a wxEVT_COMMAND_CHECKBOX_CLICKED event, when the checkbox is clicked.

See also

wxRadioButton, wxCommandEvent



wxCheckBox::wxCheckBox



wxCheckBox(void)

Default constructor.



wxCheckBox(wxWindow* parent, wxWindowID id, const wxString& label, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0, const wxValidator& val, const wxString& name = ``checkBox")

Constructor, creating and showing a checkbox.

Parameters

parent
Parent window. Must not be NULL.

id
Checkbox identifier. A value of -1 indicates a default value.

label
Text to be displayed next to the checkbox.

pos
Checkbox position. If the position (-1, -1) is specified then a default position is chosen.

size
Checkbox size. If the default size (-1, -1) is specified then a default size is chosen.

style
Window style. See wxCheckBox.

validator
Window validator.

name
Window name.

See also

wxCheckBox::Create, wxValidator



wxCheckBox::~wxCheckBox



~wxCheckBox(void)

Destructor, destroying the checkbox.



wxCheckBox::Create



bool Create(wxWindow* parent, wxWindowID id, const wxString& label, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0, const wxValidator& val, const wxString& name = ``checkBox")

Creates the checkbox for two-step construction. See wxCheckBox::wxCheckBox for details.



wxCheckBox::GetValue

bool GetValue(void) const

Gets the state of a 2-state checkbox.

Return value

Returns TRUEif it is checked, FALSEotherwise.



wxCheckBox::Get3StateValue

wxCheckBoxState Get3StateValue(void) const

Gets the state of a 3-state checkbox.

Return value

Returns wxCHK_UNCHECKED when the checkbox is unchecked, wxCHK_CHECKED when it is checked and wxCHK_UNDETERMINED when it's in the undetermined state. Asserts when the function is used with a 2-state checkbox.



wxCheckBox::Is3rdStateAllowedForUser

bool Is3rdStateAllowedForUser(void) const

Returns whether or not the user can set the checkbox to the third state.

Return value

Returns TRUEif the user can set the third state of this checkbox, FALSEif it can only be set programmatically or if it's a 2-state checkbox.



wxCheckBox::Is3State

bool Is3State(void) const

Returns whether or not the checkbox is a 3-state checkbox.

Return value

Returns TRUEif this checkbox is a 3-state checkbox, FALSEif it's a 2-state checkbox.



wxCheckBox::IsChecked

bool IsChecked(void) const

This is just a maybe more readable synonym for GetValue: just as the latter, it returns TRUEif the checkbox is checked and FALSEotherwise.



wxCheckBox::SetValue



void SetValue(bool state)

Sets the checkbox to the given state. This does not cause a wxEVT_COMMAND_CHECKBOX_CLICKED event to get emitted.

Parameters

state
If TRUE, the check is on, otherwise it is off.



wxCheckBox::Set3StateValue



void Set3StateValue(const wxCheckBoxState state)

Sets the checkbox to the given state. This does not cause a wxEVT_COMMAND_CHECKBOX_CLICKED event to get emitted.

Parameters

state
Can be one of: wxCHK_UNCHECKED (Check is off), wxCHK_CHECKED (Check is on) or wxCHK_UNDETERMINED (Check is mixed). Asserts when the checkbox is a 2-state checkbox and setting the state to wxCHK_UNDETERMINED.
ymasuda 平成17年11月19日