A user control that represents a check box. More...
#include <Wt/WCheckBox>
Inherits Wt::WAbstractToggleButton.
Inherited by Wt::ItemCheckBox.
Public Member Functions | |
WCheckBox (WContainerWidget *parent=0) | |
Creates a checkbox with empty label. | |
WCheckBox (const WString &text, WContainerWidget *parent=0) | |
Creates a checkbox with given label. | |
void | setTristate (bool tristate=true) |
Makes a tristate checkbox. | |
bool | isTristate () const |
Returns whether the checkbox is tristate. | |
void | setCheckState (CheckState state) |
Sets the check state. | |
CheckState | checkState () |
Returns the check state. |
A user control that represents a check box.
By default, a checkbox can have two states: Wt::Checked or Wt::Unchecked, which can be inspected using isChecked(), and set using setChecked().
A checkbox may also provide a third state, Wt::PartiallyChecked, which is useful to indicate that it is neither checked or unchecked. Wt will use native browser support for this HTML5 extension when available (Safari and MS IE), and use an image-based workaround otherwise. You may enable support for the third state using setTristate(), and use setCheckState() and checkState() to read all three states.
A label is added as a sibling of the checkbox to the same parent.
Usage example:
Wt::WGroupBox *box = new Wt::WGroupBox("In-flight options"); Wt::WCheckBox *w1 = new Wt::WCheckBox("Vegetarian diet", box); box->addWidget(new WBreak()); Wt::WCheckBox *w2 = new Wt::WCheckBox("WIFI access", box); box->addWidget(new WBreak()); Wt::WCheckBox *w3 = new Wt::WCheckBox("AC plug", box); w1->setChecked(false); w2->setChecked(true); w3->setChecked(true);
WCheckBox is an inline widget.
This widget corresponds to the HTML <input type="checkbox">
tag. Depending on whether a text is included, it may be nested in a <span>
tag which also includes a rendered WLabel. This widget does not provide styling, and can be styled using inline or external CSS as appropriate.
CheckState Wt::WCheckBox::checkState | ( | ) | [inline] |
Returns the check state.
bool Wt::WCheckBox::isTristate | ( | ) | const [inline] |
Returns whether the checkbox is tristate.
void Wt::WCheckBox::setCheckState | ( | CheckState | state | ) |
Sets the check state.
Unless it is a tri-state checkbox, only Wt::Checked and Wt::Unchecked are valid states.
Reimplemented from Wt::WAbstractToggleButton.
void Wt::WCheckBox::setTristate | ( | bool | tristate = true |
) |
Makes a tristate checkbox.