/usr/include/Wt/WInPlaceEdit is in libwt-dev 3.3.0-1build1.
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 | // 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 WINPLACE_EDIT_H_
#define WINPLACE_EDIT_H_
#include <Wt/WCompositeWidget>
namespace Wt {
class WText;
class WLineEdit;
class WPushButton;
/*! \class WInPlaceEdit Wt/WInPlaceEdit Wt/WInPlaceEdit
* \brief A widget that provides in-place-editable text.
*
* The %WInPlaceEdit provides a text that may be edited in place by
* the user by clicking on it. When clicked, the text turns into a
* line edit, with optionally a save and cancel button (see
* setButtonsEnabled()).
*
* When the user saves the edit, the valueChanged() signal is emitted.
*
* Usage example:
* \if cpp
* \code
* Wt::WContainerWidget *w = new Wt::WContainerWidget();
* new Wt::WText("Name: ", w);
* Wt::WInPlaceEdit *edit = new Wt::WInPlaceEdit("Bob Smith", w);
* edit->setStyleClass("inplace");
* \endcode
* \elseif java
* \code
* WContainerWidget w = new WContainerWidget();
* new WText("Name: ", w);
* WInPlaceEdit edit = new WInPlaceEdit("Bob Smith", w);
* edit.setStyleClass("inplace");
* \endcode
* \endif
*
* This code will produce an edit that looks like:
* \image html WInPlaceEdit-1.png "WInPlaceEdit text mode"
* When the text is clicked, the edit will expand to become:
* \image html WInPlaceEdit-2.png "WInPlaceEdit edit mode"
*
* <h3>CSS</h3>
*
* A WInPlaceEdit widget renders as a <tt><span></tt> containing
* a WText, a WLineEdit and optional buttons (WPushButton). All these
* widgets may be styled as such. It does not provide style information.
*
* In particular, you may want to provide a visual indication that the text
* is editable e.g. using a hover effect:
*
* CSS stylesheet:
* \code
* .inplace span:hover {
* background-color: gray;
* }
* \endcode
*/
class WT_API WInPlaceEdit : public WCompositeWidget
{
public:
/*! \brief Creates an in-place edit with the given text.
*/
WInPlaceEdit(const WString& text, WContainerWidget *parent = 0);
/*! \brief Returns the current value.
*
* \sa setText()
*/
const WString& text() const;
/*! \brief Sets the current value.
*
* \sa text()
*/
void setText(const WString& text);
/*! \brief Sets the empty text to be shown when the field is empty
* and not being edited.
*
* \sa emptyText()
*/
void setEmptyText(const WString& emptyText);
/*! \brief Returns the empty text to be shown when the field is empty
* and not being edited.
*
* \sa setEmptyText()
*/
const WString& emptyText();
/*! \brief Returns the line edit.
*
* You may use this for example to set a validator on the line edit.
*/
WLineEdit *lineEdit() const { return edit_; }
/*! \brief Returns the WText widget that renders the current string.
*
* You may use this for example to set the text format of the displayed
* string.
*/
WText *textWidget() const { return text_; }
/*! \brief Returns the save button.
*
* This method returns \c 0 if the buttons were disabled.
*
* \sa cancelButton(), setButtonsEnabled()
*/
WPushButton *saveButton() const { return save_; }
/*! \brief Returns the cancel button.
*
* This method returns \c 0 if the buttons were disabled.
*
* \sa saveButton(), setButtonsEnabled()
*/
WPushButton *cancelButton() const { return cancel_; }
/*! \brief %Signal emitted when the value has been changed.
*
* The signal argument provides the new value.
*/
Signal<WString>& valueChanged() { return valueChanged_; }
/*! \brief Displays the Save and 'Cancel' button during editing
*
* By default, the Save and Cancel buttons are shown. Call this
* function with \p enabled = \c false to only show a line edit.
*
* In this mode, the enter key or any event that causes focus to be
* lost saves the value while the escape key cancels the editing.
*/
void setButtonsEnabled(bool enabled = true);
private:
void save();
void cancel();
private:
Signal<WString> valueChanged_;
WContainerWidget *impl_, *editing_;
WText *text_;
WString emptyText_;
WLineEdit *edit_;
WPushButton *save_;
WPushButton *cancel_;
boost::signals::connection c1_;
boost::signals::connection c2_;
bool empty_;
};
}
#endif // WINPLACE_EDIT_H_
|