wxRuby Documentation Home

# Wx::CheckBox

A checkbox is a labelled box which by default is either on (checkmark is
visible) or off (no checkmark). Optionally (when the CHK_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

Control

Window

EvtHandler

Object

## Window styles

`CHK_2STATE` | Create a 2-state checkbox. This is the default.
`CHK_3STATE` | Create a 3-state checkbox.Not implemented in MGL, OS2 and GTK built against GTK+ 1.2.
`CHK_ALLOW_3RD_STATE_FOR_USER` | By default a user can’t set a 3-state checkboxto 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.
`ALIGN_RIGHT` | Makes the text appear on the left of the checkbox.

See also window styles overview.

## Event handling

evt_checkbox(id) { | event | … } | Process a EVT_COMMAND_CHECKBOX_CLICKED event,when the checkbox is clicked.

## See also

RadioButton, CommandEvent

## Methods

- CheckBox.new
- CheckBox#create
- CheckBox#get_value
- CheckBox#get_3_state_value
- CheckBox#is_3_rd_state_allowed_for_user
- CheckBox#is_3_state
- CheckBox#is_checked
- CheckBox#set_value
- CheckBox#set_3_state_value

### CheckBox.new

CheckBox.new(%(arg-type)Window% parent, Integer id, String label, Point pos = DEFAULT_POSITION, Size size = DEFAULT_SIZE, Integer style = 0, Validator val, String 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 CheckBox.
- validator Window validator.
- name Window name.

#### See also

CheckBox#create, Validator

destructor()

Destructor, destroying the checkbox.

### CheckBox#create

Boolean create(%(arg-type)Window% parent, Integer id, String label, Point pos = DEFAULT_POSITION, Size size = DEFAULT_SIZE, Integer style = 0, Validator val, String name = “checkBox”)

Creates the checkbox for two-step construction. See CheckBox.new for details.

### CheckBox#get_value

Boolean get_value()

Gets the state of a 2-state checkbox.

#### Return value

Returns if it is checked, otherwise.

### CheckBox#get_3_state_value

CheckBoxState get_3_state_value()

Gets the state of a 3-state checkbox.

#### Return value

Returns CHK_UNCHECKED when the checkbox is unchecked, CHK_CHECKED
when it is checked and CHK_UNDETERMINED when it’s in the undetermined
state. Asserts when the function is used with a 2-state checkbox.

### CheckBox#is_3_rd_state_allowed_for_user

Boolean is_3_rd_state_allowed_for_user()

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

#### Return value

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

### CheckBox#is_3_state

Boolean is_3_state()

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

#### Return value

Returns if this checkbox is a 3-state checkbox, if it’s a 2-state checkbox.

### CheckBox#is_checked

Boolean is_checked()

This is just a maybe more readable synonym for
get_value: just as the latter, it returns
if the checkbox is checked and otherwise.

### CheckBox#set_value

set_value(%(arg-type)Boolean% state)

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

#### Parameters

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

### CheckBox#set_3_state_value

set_3_state_value(%(arg-type)CheckBoxState% state)

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

#### Parameters

- state Can be one of: CHK_UNCHECKED (Check is off), CHK_CHECKED
  (Check is on) or CHK_UNDETERMINED (Check is mixed). Asserts when the checkbox
  is a 2-state checkbox and setting the state to CHK_UNDETERMINED.

[This page automatically generated from the Textile source at 2023-06-09 00:45:35 +0000]