Wt  3.3.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator
Public Member Functions | Protected Member Functions
Wt::WFormWidget Class Reference

An abstract widget that corresponds to an HTML form element. More...

#include <Wt/WFormWidget>

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

List of all members.

Public Member Functions

 WFormWidget (WContainerWidget *parent=0)
 Creates a WFormWidget with an optional parent.
 ~WFormWidget ()
 Destructor.
WLabellabel () 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.
virtual WValidatorvalidator () const
 Returns the validator.
virtual WValidator::State validate ()
 Validates the field.
void setEnabled (bool enabled)
 Sets whether the widget is enabled.
virtual 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 placeholder text (deprecated).
const WStringemptyText () const
 Returns the placeholder text (deprecated).
virtual void setPlaceholderText (const WString &placeholder)
 Sets the placeholder text.
const WStringplaceholderText () const
 Returns the placeholder text.
EventSignalchanged ()
 Signal emitted when the value was changed.
EventSignalselected ()
 Signal emitted when ??
Signal< WValidator::Result > & validated ()
 Signal emitted when the widget is being validated.
virtual void refresh ()
 Refresh the widget.
virtual void setToolTip (const WString &text, TextFormat textFormat=PlainText)
 Sets a tooltip.
virtual bool canReceiveFocus () const
 Returns whether the widget can receive focus.
virtual int tabIndex () const
 Returns the tab index.

Protected Member Functions

virtual void enableAjax ()
 Progresses to an Ajax-enabled widget.
virtual void render (WFlags< RenderFlag > flags)
 Renders the widget.
virtual void propagateSetEnabled (bool enabled)
 Propagates that a widget was enabled or disabled through children.

Detailed Description

An abstract widget that corresponds to an HTML form element.

A WFormWidget may receive focus (see canReceiveFocus()), 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.


Constructor & Destructor Documentation

Destructor.

If a label was associated with the widget, its buddy is reset to 0.


Member Function Documentation

bool Wt::WFormWidget::canReceiveFocus ( ) const [virtual]

Returns whether the widget can receive focus.

See also:
setCanReceiveFocus()

Reimplemented from Wt::WWebWidget.

Signal emitted when the value was changed.

For a keyboard input, the signal is only emitted when the focus is lost

Returns the placeholder text (deprecated).

Deprecated:
use placeholderText() instead.
void Wt::WFormWidget::enableAjax ( ) [protected, virtual]

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.

See also:
WApplication::enableAjax()

Reimplemented from Wt::WWebWidget.

Reimplemented in Wt::WPushButton.

Returns whether the form element is read-only.

See also:
setReadOnly()

Returns the label associated with this widget.

Returns the label (if there is one) that acts as a proxy for this widget.

See also:
WLabel::setBuddy(WFormWidget *)

Returns the placeholder text.

See also:
setPlaceholderText()
void Wt::WFormWidget::propagateSetEnabled ( bool  enabled) [protected, virtual]

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.

Reimplemented in Wt::WPushButton, Wt::WTextEdit, Wt::WDateEdit, and Wt::WTimeEdit.

void Wt::WFormWidget::refresh ( ) [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.

Note:
This does *not* rerender the widget! Calling refresh() usually does not have any effect (unless you've reimplemented refresh() to attach to it an effect).

Reimplemented from Wt::WWebWidget.

Reimplemented in Wt::WPushButton, Wt::WComboBox, Wt::WAbstractToggleButton, Wt::WDoubleSpinBox, and Wt::WAbstractSpinBox.

void Wt::WFormWidget::render ( WFlags< RenderFlag flags) [protected, virtual]

Renders the widget.

This function renders the widget (or an update for the widget), after this has been scheduled using scheduleRender().

The default implementation will render the widget by serializing changes to JavaScript and HTML. You may want to reimplement this widget if you have been postponing some of the layout / rendering implementation until the latest moment possible. In that case you should make sure you call the base implementation however.

Reimplemented from Wt::WWebWidget.

Reimplemented in Wt::WLineEdit, Wt::WSlider, Wt::WDateEdit, Wt::WDoubleSpinBox, Wt::WAbstractSpinBox, and Wt::WTimeEdit.

void Wt::WFormWidget::setEmptyText ( const WString emptyText)

Sets the placeholder text (deprecated).

Deprecated:
use setPlaceholderText() instead
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::setHidden ( bool  hidden,
const WAnimation animation = WAnimation() 
) [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.

Reimplemented in Wt::WDateEdit, and Wt::WTimeEdit.

void Wt::WFormWidget::setPlaceholderText ( const WString placeholder) [virtual]

Sets the placeholder text.

This sets the text that is shown when the field is empty.

Reimplemented in Wt::WTextEdit.

void Wt::WFormWidget::setReadOnly ( bool  readOnly) [virtual]

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.

See also:
setEnabled()

Reimplemented in Wt::WTextEdit.

void Wt::WFormWidget::setToolTip ( const WString text,
TextFormat  textFormat = PlainText 
) [virtual]

Sets a tooltip.

The tooltip is displayed when the cursor hovers over the widget.

When textFormat is XHTMLText, the tooltip may contain any valid XHTML snippet. The tooltip will then be rendered using JavaScript.

Note: This will set deferred tooltip to false.

See also:
setDeferredTooltip()

Reimplemented from Wt::WWebWidget.

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.

See also:
validate()
virtual void Wt::WFormWidget::setValueText ( const WString value) [pure virtual]

Sets the value text.

This sets the current value from a string value.

Implemented in Wt::WPushButton, Wt::WSlider, Wt::WLineEdit, Wt::WComboBox, Wt::WTextArea, and Wt::WAbstractToggleButton.

int Wt::WFormWidget::tabIndex ( ) const [virtual]

Returns the tab index.

See also:
setTabIndex()

Reimplemented from Wt::WWebWidget.

Validates the field.

See also:
validated()

Reimplemented in Wt::WLineEdit, and Wt::WAbstractSpinBox.

Signal emitted when the widget is being validated.

This signal may be useful to react to a changed validation state.

See also:
validate()
virtual WString Wt::WFormWidget::valueText ( ) const [pure virtual]

Returns the current value.

This returns the current value as a string.

Implemented in Wt::WPushButton, Wt::WSlider, Wt::WLineEdit, Wt::WComboBox, Wt::WTextArea, and Wt::WAbstractToggleButton.

 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