-
Notifications
You must be signed in to change notification settings - Fork 388
Expand file tree
/
Copy pathWCheckBox
More file actions
122 lines (110 loc) · 3.38 KB
/
WCheckBox
File metadata and controls
122 lines (110 loc) · 3.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
// This may look like C code, but it's really -*- C++ -*-
/*
* Copyright (C) 2008 Emweb bvba, Kessel-Lo, Belgium.
*
* See the LICENSE file for terms of use.
*/
#ifndef WCHECKBOX_H_
#define WCHECKBOX_H_
#include <Wt/WAbstractToggleButton>
namespace Wt {
/*! \class WCheckBox Wt/WCheckBox Wt/WCheckBox
* \brief 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:
* \if cpp
* \code
* 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);
* \endcode
* \elseif java
* \code
* WGroupBox box = new WGroupBox("In-flight options");
*
* WCheckBox w1 = new WCheckBox("Vegetarian diet", box);
* box.addWidget(new WBreak());
* WCheckBox w2 = new WCheckBox("WIFI access", box);
* box.addWidget(new WBreak());
* WCheckBox w3 = new WCheckBox("AC plug", box);
*
* w1.setChecked(false);
* w2.setChecked(true);
* w3.setChecked(true);
* \endcode
* \endif
*
* %WCheckBox is an \link WWidget::setInline(bool) inline \endlink widget.
*
* <h3>CSS</h3>
*
* This widget corresponds to the HTML <tt><input
* type="checkbox"></tt> tag. Depending on whether a text is
* included, it may be nested in a <tt><span></tt> tag which
* also includes a rendered WLabel. This widget does not provide
* styling, and can be styled using inline or external CSS as
* appropriate.
*
* \sa WAbstractToggleButton
*/
class WT_API WCheckBox : public WAbstractToggleButton
{
public:
/*! \brief Creates a checkbox with empty label.
*/
WCheckBox(WContainerWidget *parent = 0);
/*! \brief Creates a checkbox with given label.
*/
WCheckBox(const WString& text, WContainerWidget *parent = 0);
/*! \brief Makes a tristate checkbox.
*
* \note You should enable tristate functionality right after construction
* and this cannot be modified later.
*/
void setTristate(bool tristate = true);
/*! \brief Returns whether the checkbox is tristate.
*
* \sa setTristate()
*/
bool isTristate() const { return triState_; }
/*! \brief Sets the check state.
*
* Unless it is a tri-state checkbox, only Wt::Checked and Wt::Unchecked are
* valid states.
*/
void setCheckState(CheckState state);
/*! \brief Returns the check state.
*
* \sa setCheckState(), isChecked()
*/
CheckState checkState() const { return state_; }
protected:
virtual void updateInput(DomElement& input, bool all);
private:
bool triState_;
bool safariWorkaround_;
};
}
#endif // WCHECKBOX_H_