Wt  3.3.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator
Public Member Functions
Wt::WCheckBox Class Reference

A user control that represents a check box. More...

#include <Wt/WCheckBox>

Inheritance diagram for Wt::WCheckBox:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 WCheckBox (WContainerWidget *parent=0)
 Creates a checkbox without label.
 WCheckBox (const WString &text, WContainerWidget *parent=0)
 Creates a checkbox with given label.
void setTristate (bool tristate=true)
 Makes a tristate checkbox.
void setPartialStateSelectable (bool b)
 enable or disable cycling throught partial state
bool isPartialStateSelectable ()
 return partial state cycling
bool isTristate () const
 Returns whether the checkbox is tristate.
void setCheckState (CheckState state)
 Sets the check state.
CheckState checkState () const
 Returns the check state.

Detailed Description

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 nor 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. Once a tri-state checkbox is clicked, it cycles through the states Wt::Checked and Wt::Unchecked.

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.

CSS

This widget is rendered using an HTML <input type="checkbox"> tag. When a label is specified, the input element is nested in a <label>.

This widget does not provide styling, and can be styled using inline or external CSS as appropriate.

See also:
WAbstractToggleButton

Constructor & Destructor Documentation

Creates a checkbox without label.

A checkbox created by this constructor will not contain a placeholder for a label, and therefore it is not possible to assign a label to it later through setText().


Member Function Documentation

Returns the check state.

See also:
setCheckState(), isChecked()

return partial state cycling

See also:
setPartialStateSelectable();
bool Wt::WCheckBox::isTristate ( ) const

Returns whether the checkbox is tristate.

See also:
setTristate()

Sets the check state.

Unless it is a tri-state checkbox, only Wt::Checked and Wt::Unchecked are valid states.

Reimplemented from Wt::WAbstractToggleButton.

enable or disable cycling throught partial state

See also:
isPartialStateSelectable()
void Wt::WCheckBox::setTristate ( bool  tristate = true)

Makes a tristate checkbox.

Note:
You should enable tristate functionality right after construction and this cannot be modified later.
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator

Generated on Tue Mar 22 2016 for the C++ Web Toolkit (Wt) by doxygen 1.7.6.1