Wt
3.2.1
|
An abstract widget that corresponds to an HTML form element. More...
#include <Wt/WFormWidget>
Public Member Functions | |
WFormWidget (WContainerWidget *parent=0) | |
Creates a WFormWidget with an optional parent. | |
~WFormWidget () | |
Destructor. | |
WLabel * | label () const |
Returns the label associated with this widget. | |
virtual void | setHidden (bool hidden, const WAnimation &animation=WAnimation()) |
Sets the hidden state of this widget. | |
virtual WString | valueText () const =0 |
Returns the current value. | |
virtual void | setValueText (const WString &value)=0 |
Sets the value text. | |
void | setValidator (WValidator *validator) |
Sets a validator for this field. | |
WValidator * | validator () const |
Returns the validator. | |
virtual WValidator::State | validate () |
Validates the field. | |
void | setEnabled (bool enabled) |
Sets whether the widget is enabled. | |
void | setFocus () |
Gives focus. | |
void | setFocus (bool focus) |
Changes focus. | |
bool | hasFocus () const |
Returns whether this widget has focus. | |
virtual void | setTabIndex (int index) |
Sets the tab index. | |
virtual int | tabIndex () const |
Returns the tab index. | |
void | setReadOnly (bool readOnly) |
Sets the element read-only. | |
bool | isReadOnly () const |
Returns whether the form element is read-only. | |
void | setEmptyText (const WString &emptyText) |
Sets the empty text to be shown when the field is empty. | |
const WString & | emptyText () |
Returns the empty text to be shown when the field is empty. | |
EventSignal & | changed () |
Signal emitted when the value was changed. | |
EventSignal & | selected () |
Signal emitted when ?? | |
EventSignal & | blurred () |
Signal emitted when the widget lost focus. | |
EventSignal & | focussed () |
Signal emitted when the widget recieved focus. | |
virtual void | refresh () |
Refresh the widget. | |
![]() | |
WInteractWidget (WContainerWidget *parent=0) | |
Create an InteractWidget with optional parent. | |
EventSignal< WKeyEvent > & | keyWentDown () |
Event signal emitted when a keyboard key is pushed down. | |
EventSignal< WKeyEvent > & | keyPressed () |
Event signal emitted when a "character" was entered. | |
EventSignal< WKeyEvent > & | keyWentUp () |
Event signal emitted when a keyboard key is released. | |
EventSignal & | enterPressed () |
Event signal emitted when enter was pressed. | |
EventSignal & | escapePressed () |
Event signal emitted when escape was pressed. | |
EventSignal< WMouseEvent > & | clicked () |
Event signal emitted when a mouse key was clicked on this widget. | |
EventSignal< WMouseEvent > & | doubleClicked () |
Event signal emitted when a mouse key was double clicked on this widget. | |
EventSignal< WMouseEvent > & | mouseWentDown () |
Event signal emitted when a mouse key was pushed down on this widget. | |
EventSignal< WMouseEvent > & | mouseWentUp () |
Event signal emitted when a mouse key was released on this widget. | |
EventSignal< WMouseEvent > & | mouseWentOut () |
Event signal emitted when the mouse went out of this widget. | |
EventSignal< WMouseEvent > & | mouseWentOver () |
Event signal emitted when the mouse entered this widget. | |
EventSignal< WMouseEvent > & | mouseMoved () |
Event signal emitted when the mouse moved over this widget. | |
EventSignal< WMouseEvent > & | mouseDragged () |
Event signal emitted when the mouse is dragged over this widget. | |
EventSignal< WMouseEvent > & | mouseWheel () |
Event signal emitted when the mouse scroll wheel was used. | |
EventSignal< WTouchEvent > & | touchStarted () |
Event signal emitted when a finger is placed on the screen. | |
EventSignal< WTouchEvent > & | touchEnded () |
Event signal emitted when a finger is removed from the screen. | |
EventSignal< WTouchEvent > & | touchMoved () |
Event signal emitted when a finger, which is already placed on the screen, is moved across the screen. | |
EventSignal< WGestureEvent > & | gestureStarted () |
Event signal emitted when a gesture is started. | |
EventSignal< WGestureEvent > & | gestureChanged () |
Event signal emitted when a gesture is changed. | |
EventSignal< WGestureEvent > & | gestureEnded () |
Event signal emitted when a gesture is ended. | |
void | setDraggable (const std::string &mimeType, WWidget *dragWidget=0, bool isDragWidgetOnly=false, WObject *sourceWidget=0) |
Configure dragging for drag and drop. | |
virtual void | load () |
Loads content just before the widget is used. | |
virtual bool | isEnabled () const |
Returns whether the widget is enabled. | |
![]() | |
WWebWidget (WContainerWidget *parent=0) | |
Construct a WebWidget with a given parent. | |
virtual void | setPositionScheme (PositionScheme scheme) |
Sets the CSS position scheme. | |
virtual PositionScheme | positionScheme () const |
Returns the CSS position scheme. | |
virtual void | setOffsets (const WLength &offset, WFlags< Side > sides=All) |
Sets CSS offsets for a non-statically positioned widget. | |
virtual WLength | offset (Side s) const |
Returns a CSS offset. | |
virtual void | resize (const WLength &width, const WLength &height) |
Resizes the widget. | |
virtual WLength | width () const |
Returns the width. | |
virtual WLength | height () const |
Returns the height. | |
virtual void | setMinimumSize (const WLength &width, const WLength &height) |
Sets a minimum size. | |
virtual WLength | minimumWidth () const |
Returns the minimum width. | |
virtual WLength | minimumHeight () const |
Returns the minimum height. | |
virtual void | setMaximumSize (const WLength &width, const WLength &height) |
Sets a maximum size. | |
virtual WLength | maximumWidth () const |
Returns the maximum width. | |
virtual WLength | maximumHeight () const |
Returns the maximum height. | |
virtual void | setLineHeight (const WLength &height) |
Sets the CSS line height for contained text. | |
virtual WLength | lineHeight () const |
Returns the CSS line height for contained text. | |
virtual void | setFloatSide (Side s) |
Specifies a CSS float side. | |
virtual Side | floatSide () const |
Returns the CSS float side. | |
virtual void | setClearSides (WFlags< Side > sides) |
Sets the sides that should be cleared of floats. | |
virtual WFlags< Side > | clearSides () const |
Returns the sides that should remain empty. | |
virtual void | setMargin (const WLength &margin, WFlags< Side > sides=All) |
Sets CSS margins around the widget. | |
virtual WLength | margin (Side side) const |
Returns a CSS margin set. | |
virtual void | setHiddenKeepsGeometry (bool enabled) |
Sets whether the widget keeps its geometry when hidden. | |
virtual bool | hiddenKeepsGeometry () const |
Returns whether the widget keeps its geometry when hidden. | |
virtual bool | isHidden () const |
Returns whether the widget is set hidden. | |
virtual bool | isVisible () const |
Returns whether the widget is visible. | |
virtual void | setDisabled (bool disabled) |
Sets whether the widget is disabled. | |
virtual bool | isDisabled () const |
Returns whether the widget is set disabled. | |
virtual void | setPopup (bool popup) |
Lets the widget overlay over other sibling widgets. | |
virtual bool | isPopup () const |
Returns whether the widget is overlayed. | |
virtual void | setInline (bool isInline) |
Sets whether the widget is displayed inline or as a block. | |
virtual bool | isInline () const |
Returns whether the widget is displayed inline or as block. | |
virtual void | setDecorationStyle (const WCssDecorationStyle &style) |
Sets a CSS decoration style. | |
virtual WCssDecorationStyle & | decorationStyle () |
Returns the decoration style of this widget. | |
virtual void | setStyleClass (const WString &styleClass) |
Sets (one or more) CSS style classes. | |
virtual WString | styleClass () const |
Returns the CSS style class. | |
virtual void | addStyleClass (const WString &styleClass, bool force=false) |
Adds a CSS style class. | |
virtual void | removeStyleClass (const WString &styleClass, bool force=false) |
Removes a CSS style class. | |
virtual void | setVerticalAlignment (AlignmentFlag alignment, const WLength &length=WLength()) |
Sets the vertical alignment. | |
virtual AlignmentFlag | verticalAlignment () const |
Returns the vertical alignment. | |
virtual WLength | verticalAlignmentLength () const |
Returns the fixed vertical alignment that was set. | |
virtual void | setToolTip (const WString &text, TextFormat textFormat=PlainText) |
Sets a tooltip. | |
virtual WString | toolTip () const |
Returns the tooltip. | |
virtual void | setAttributeValue (const std::string &name, const WString &value) |
Sets an attribute value. | |
virtual WString | attributeValue (const std::string &name) const |
Returns an attribute value. | |
virtual void | setJavaScriptMember (const std::string &name, const std::string &value) |
Sets a JavaScript member. | |
virtual std::string | javaScriptMember (const std::string &name) const |
Returns the value of a JavaScript member. | |
virtual void | callJavaScriptMember (const std::string &name, const std::string &args) |
Calls a JavaScript member. | |
virtual bool | loaded () const |
Returns whether this widget has been loaded. | |
virtual void | setId (const std::string &id) |
Sets the CSS Id. | |
virtual WWidget * | find (const std::string &name) |
Finds a descendent widget by name. | |
virtual void | setSelectable (bool selectable) |
Sets as selectable. | |
virtual void | doJavaScript (const std::string &javascript) |
Executes the given JavaScript statements when the widget is rendered or updated. | |
virtual const std::string | id () const |
Returns the (unique) identifier for this object. | |
void | setLoadLaterWhenInvisible (bool) |
Change the way the widget is loaded when invisible. | |
const std::vector< WWidget * > & | children () const |
Returns contained widgets. | |
Signal & | childrenChanged () |
Signal emitted when children have been added or removed. | |
bool | isRendered () const |
Returns whether the widget is rendered. | |
![]() | |
virtual | ~WWidget () |
Destructor. | |
WWidget * | parent () const |
Returns the parent widget. | |
void | setWidth (const WLength &width) |
Sets the width. | |
void | setHeight (const WLength &height) |
Sets the height. | |
virtual void | positionAt (const WWidget *widget, Orientation orientation=Vertical) |
Positions a widget next to another widget. | |
std::string | jsRef () const |
Returns a JavaScript expression to the corresponding DOM node. | |
virtual void | acceptDrops (const std::string &mimeType, const WString &hoverStyleClass=WString()) |
Sets a mime type to be accepted for dropping. | |
virtual void | stopAcceptDrops (const std::string &mimeType) |
Indicates that a mime type is no longer accepted for dropping. | |
virtual void | htmlText (std::ostream &out) |
Streams the (X)HTML representation. | |
void | hide () |
Hides the widget. | |
void | animateHide (const WAnimation &animation) |
Hides the widget using an animation. | |
void | show () |
Shows the widget. | |
void | animateShow (const WAnimation &animation) |
Shows the widget using an animation. | |
void | enable () |
Enables the widget. | |
void | disable () |
Disable thes widget. | |
bool | layoutSizeAware () const |
Returns whether the widget is layout size aware. | |
![]() | |
WObject (WObject *parent=0) | |
Create a WObject with a given parent object. | |
virtual | ~WObject () |
Destructor. | |
void | setObjectName (const std::string &name) |
Sets an object name. | |
virtual std::string | objectName () const |
Returns the object name. | |
void | resetLearnedSlots () |
Resets learned stateless slot implementations. | |
template<class T > | |
void | resetLearnedSlot (void(T::*method)()) |
Resets a learned stateless slot implementation. | |
template<class T > | |
WStatelessSlot * | implementStateless (void(T::*method)()) |
Declares a slot to be stateless and learn client-side behaviour on first invocation. | |
template<class T > | |
WStatelessSlot * | implementStateless (void(T::*method)(), void(T::*undoMethod)()) |
Declares a slot to be stateless and learn client-side behaviour in advance. | |
template<class T > | |
WStatelessSlot * | implementJavaScript (void(T::*method)(), const std::string &jsCode) |
Provides a JavaScript implementation for a method. | |
void | addChild (WObject *child) |
Adds a child object. |
Protected Member Functions | |
virtual void | enableAjax () |
Progresses to an Ajax-enabled widget. | |
virtual WStatelessSlot * | getStateless (Method method) |
On-demand stateless slot implementation. | |
virtual void | propagateSetEnabled (bool enabled) |
Propagates that a widget was enabled or disabled through children. |
An abstract widget that corresponds to an HTML form element.
A WFormWidget may receive focus, can be disabled, and can have a label that acts as proxy for getting focus. It provides signals which reflect changes to its value, or changes to its focus.
Form widgets also have built-in support for validation, using setValidator(WValidator *). If the validator provide client-side validation, then an invalid validation state is reflected using the style class "Wt-invalid"
. All validators provided by Wt implement client-side validation.
On the server-side, use validate() method to validate the content using a validator previously set.
Wt::WFormWidget::~WFormWidget | ( | ) |
Destructor.
If a label was associated with the widget, its buddy is reset to 0
.
const WString& Wt::WFormWidget::emptyText | ( | ) |
Returns the empty text to be shown when the field is empty.
|
protectedvirtual |
Progresses to an Ajax-enabled widget.
This method is called when the progressive bootstrap method is used, and support for AJAX has been detected. The default behavior will upgrade the widget's event handling to use AJAX instead of full page reloads, and propagate the call to its children.
You may want to reimplement this method if you want to make changes to widget when AJAX is enabled. You should always call the base implementation.
Reimplemented from Wt::WWebWidget.
|
protectedvirtual |
On-demand stateless slot implementation.
This method returns a stateless slot implementation for the given method
. To avoid the cost of declaring methods to be stateless when they are not used, you may reimplement this method to provide a stateless implementation for a method only when the method is involved in a slot connection.
Use implementStateless() to provide a stateless implementation of the given method
, or return the base class implementation otherwise.
Reimplemented from Wt::WWidget.
Reimplemented in Wt::WAbstractToggleButton.
bool Wt::WFormWidget::isReadOnly | ( | ) | const |
Returns whether the form element is read-only.
WLabel* Wt::WFormWidget::label | ( | ) | const |
Returns the label associated with this widget.
Returns the label (if there is one) that acts as a proxy for this widget.
|
protectedvirtual |
Propagates that a widget was enabled or disabled through children.
When enabling or disabling a widget, you usually also want to disable contained children. This method is called by setDisabled() to propagate its state to all children.
You may want to reimplement this method if they wish to render differently when a widget is disabled. The default implementation will propagate the signal to all children.
Reimplemented from Wt::WInteractWidget.
|
virtual |
Refresh the widget.
The refresh method is invoked when the locale is changed using WApplication::setLocale() or when the user hit the refresh button.
The widget must actualize its contents in response.
Reimplemented from Wt::WWebWidget.
Reimplemented in Wt::WComboBox, and Wt::WPushButton.
void Wt::WFormWidget::setEmptyText | ( | const WString & | emptyText | ) |
Sets the empty text to be shown when the field is empty.
void Wt::WFormWidget::setEnabled | ( | bool | enabled | ) |
Sets whether the widget is enabled.
A widget that is disabled cannot receive focus or user interaction.
This is the opposite of setDisabled().
void Wt::WFormWidget::setFocus | ( | ) |
Gives focus.
Giving focus to an input element only works when JavaScript is enabled.
void Wt::WFormWidget::setFocus | ( | bool | focus | ) |
Changes focus.
When using focus
= false
, you can undo a previous setFocus() call.
|
virtual |
Sets the hidden state of this widget.
If the widget has a label, it is hidden and shown together with this widget.
Reimplemented from Wt::WWebWidget.
void Wt::WFormWidget::setReadOnly | ( | bool | readOnly | ) |
Sets the element read-only.
A read-only form element cannot be edited, but the contents can still be selected.
By default, a form element area is not read-only.
|
virtual |
Sets the tab index.
For widgets that receive focus, focus is passed on to the next widget in the tabbing chain based on their tab index. When the user navigates through form widgets using the keyboard, widgets receive focus starting from the element with the lowest tab index to elements with the highest tab index.
A tab index only applies to widgets than can receive focus (which are WFormWidget, WAnchor, WPushButton), but setting a tab index on any other type of widget will propagate to its contained form widgets.
Widgets with a same tab index will receive focus in the same order as they are inserted in the widget tree.
The default tab index is 0.
Reimplemented from Wt::WWebWidget.
void Wt::WFormWidget::setValidator | ( | WValidator * | validator | ) |
Sets a validator for this field.
The validator is used to validate the current input.
If the validator has no parent yet, then ownership is transferred to the form field, and thus the validator will be deleted together with the form field.
The default value is 0
.
|
pure virtual |
Sets the value text.
This sets the current value from a string value.
Implemented in Wt::WSlider, Wt::WComboBox, Wt::WLineEdit, Wt::WPushButton, Wt::WTextArea, and Wt::WAbstractToggleButton.
|
virtual |
|
virtual |
Validates the field.
|
pure virtual |
Returns the current value.
This returns the current value as a string.
Implemented in Wt::WSlider, Wt::WComboBox, Wt::WLineEdit, Wt::WPushButton, Wt::WTextArea, and Wt::WAbstractToggleButton.