/usr/include/Wt/WAbstractToggleButton is in libwt-dev 3.3.4+dfsg-6ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 | // 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 WABSTRACTTOGGLEBUTTON_H_
#define WABSTRACTTOGGLEBUTTON_H_
#include <Wt/WFormWidget>
#include <Wt/WText>
namespace Wt {
class WLabel;
/*! \brief An abstract base class for radio buttons and check boxes.
*
* A toggle button provides a button with a boolean state (checked or
* unchecked), and a text label.
*
* To act on a change of the state, either connect a slot to the changed()
* signal, or connect a slot to the checked() or unChecked() signals.
*
* The current state (checked or unchecked) may be inspected using the
* isChecked() method.
*/
class WT_API WAbstractToggleButton : public WFormWidget
{
protected:
/*! \brief Creates an unchecked toggle button without label.
*/
WAbstractToggleButton(WContainerWidget *parent = 0);
/*! \brief Creates an unchecked toggle button with given text label.
*
* The text label is rendered to the right side of the button.
*/
WAbstractToggleButton(const WString& text, WContainerWidget *parent = 0);
public:
/*! \brief Destructor.
*/
virtual ~WAbstractToggleButton();
/*! \brief Sets the label text.
*
* The label is rendered to the right of the button.
*/
void setText(const WString& text);
/*! \brief Returns the label text.
*
* \sa setText()
*/
const WString text() const { return text_.text; }
/*! \brief Returns the button state.
*
* \sa setChecked()
*/
bool isChecked() const { return state_ == Checked; }
/*! \brief Sets the button state.
*
* This method does not emit one of the checked() or unChecked()
* signals.
*
* \sa setChecked(), setUnChecked()
*/
void setChecked(bool checked);
/*! \brief Checks the button.
*
* Does not emit the checked() signal.
*
* \sa setChecked(bool)
*/
virtual void setChecked();
/*! \brief Unchecks the button.
*
* Does not emit the unChecked() signal.
*
* \sa setChecked(bool)
*/
virtual void setUnChecked();
/*! \brief Returns the current value.
*
* Returns "yes" when checked, "maybe" when partially checked, and
* "no" when unchecked.
*/
virtual WT_USTRING valueText() const;
/*! \brief Sets the current value.
*
* This interprets text values of "yes", "maybe" or "no".
*/
virtual void setValueText(const WT_USTRING& text);
/*! \brief %Signal emitted when the button gets checked.
*
* This signal is emitted when the user checks the button.
*
* You can use the changed() signal to react to any change of the
* button state.
*/
EventSignal<>& checked();
/*! \brief %Signal emitted when the button gets un-checked.
*
* This signal is emitted when the user unchecks the button.
*
* You can use the changed() signal to react to any change of the
* button state.
*/
EventSignal<>& unChecked();
virtual void refresh();
/*! \brief Configures word wrapping.
*
* When \p wordWrap is \c true, the widget may break lines, creating a
* multi-line text. When \p wordWrap is \c false, the text will displayed
* on a single line, unless the text contains end-of-lines (for
* Wt::PlainText) or <br /> tags or other block-level tags
* (for Wt::XHTMLText).
*
* The default value is \c false.
*
* \sa wordWrap()
*/
void setWordWrap(bool wordWrap);
/*! \brief Returns whether word wrapping is on.
*
* \sa setWordWrap()
*/
bool wordWrap() const;
protected:
CheckState state_;
virtual void updateInput(DomElement& input, bool all) = 0;
virtual void updateDom(DomElement& element, bool all);
virtual void getFormObjects(FormObjectsMap& formObjects);
virtual void setFormData(const FormData& formData);
virtual void propagateRenderOk(bool deep);
virtual DomElementType domElementType() const;
virtual bool supportsIndeterminate(const WEnvironment& env) const;
virtual std::string formName() const;
virtual WStatelessSlot *getStateless(Method method);
private:
static const char *CHECKED_SIGNAL;
static const char *UNCHECKED_SIGNAL;
static const char *UNDETERMINATE_CLICK_SIGNAL;
WText::RichText text_;
static const int BIT_NAKED = 0;
static const int BIT_STATE_CHANGED = 1;
static const int BIT_TEXT_CHANGED = 2;
static const int BIT_WORD_WRAP_CHANGED = 3;
static const int BIT_WORD_WRAP = 4;
std::bitset<5> flags_;
CheckState prevState_;
void undoSetChecked();
void undoSetUnChecked();
void setCheckState(CheckState state);
friend class WCheckBox;
friend class WRadioButton;
friend class WButtonGroup;
};
}
#endif // WABSTRACTTOGGLEBUTTON_H_
|