Wt  4.11.0
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
Wt::WWebWidget Class Referenceabstract

A base class for widgets with an HTML counterpart. More...

#include <Wt/WWebWidget.h>

Inheritance diagram for Wt::WWebWidget:
[legend]

Public Member Functions

 WWebWidget ()
 Construct a WebWidget.
 
virtual std::vector< WWidget * > children () const override
 Returns child widgets.
 
SignalchildrenChanged ()
 Signal emitted when children have been added or removed.
 
virtual void setPositionScheme (PositionScheme scheme) override
 Sets the CSS position scheme.
 
virtual PositionScheme positionScheme () const override
 Returns the CSS position scheme.
 
virtual void setOffsets (const WLength &offset, WFlags< Side > sides=AllSides) override
 Sets CSS offsets for a non-statically positioned widget.
 
virtual WLength offset (Side s) const override
 Returns a CSS offset.
 
virtual void resize (const WLength &width, const WLength &height) override
 Resizes the widget.
 
virtual WLength width () const override
 Returns the width.
 
virtual WLength height () const override
 Returns the height.
 
virtual void setMinimumSize (const WLength &width, const WLength &height) override
 Sets a minimum size.
 
virtual WLength minimumWidth () const override
 Returns the minimum width.
 
virtual WLength minimumHeight () const override
 Returns the minimum height.
 
virtual void setMaximumSize (const WLength &width, const WLength &height) override
 Sets a maximum size.
 
virtual WLength maximumWidth () const override
 Returns the maximum width.
 
virtual WLength maximumHeight () const override
 Returns the maximum height.
 
virtual void setLineHeight (const WLength &height) override
 Sets the CSS line height for contained text.
 
virtual WLength lineHeight () const override
 Returns the CSS line height for contained text.
 
virtual void setFloatSide (Side s) override
 Specifies a CSS float side.
 
virtual Side floatSide () const override
 Returns the CSS float side.
 
virtual void setClearSides (WFlags< Side > sides) override
 Sets the sides that should be cleared of floats.
 
virtual WFlags< SideclearSides () const override
 Returns the sides that should remain empty.
 
virtual void setMargin (const WLength &margin, WFlags< Side > sides=AllSides) override
 Sets CSS margins around the widget.
 
virtual WLength margin (Side side) const override
 Returns a CSS margin set.
 
virtual void setHiddenKeepsGeometry (bool enabled) override
 Sets whether the widget keeps its geometry when hidden.
 
virtual bool hiddenKeepsGeometry () const override
 Returns whether the widget keeps its geometry when hidden.
 
virtual void setHidden (bool hidden, const WAnimation &animation=WAnimation()) override
 Hides or shows the widget.
 
virtual bool isHidden () const override
 Returns whether the widget is set hidden.
 
virtual bool isVisible () const override
 Returns whether the widget is visible.
 
virtual void setDisabled (bool disabled) override
 Sets whether the widget is disabled.
 
virtual bool isDisabled () const override
 Returns whether the widget is set disabled.
 
virtual bool isEnabled () const override
 Returns whether the widget is enabled.
 
virtual void setPopup (bool popup) override
 Lets the widget overlay over other sibling widgets.
 
virtual bool isPopup () const override
 Returns whether the widget is overlayed.
 
virtual void setInline (bool isInline) override
 Sets whether the widget is displayed inline or as a block.
 
virtual bool isInline () const override
 Returns whether the widget is displayed inline or as block.
 
virtual void setDecorationStyle (const WCssDecorationStyle &style) override
 Sets a CSS decoration style.
 
virtual WCssDecorationStyledecorationStyle () override
 Returns the decoration style of this widget.
 
virtual void setStyleClass (const WString &styleClass) override
 Sets (one or more) CSS style classes.
 
virtual WString styleClass () const override
 Returns the CSS style class.
 
virtual void addStyleClass (const WString &styleClass, bool force=false) override
 Adds a CSS style class.
 
virtual void removeStyleClass (const WString &styleClass, bool force=false) override
 Removes a CSS style class.
 
virtual bool hasStyleClass (const WString &styleClass) const override
 Returns whether the widget has a style class.
 
virtual void setVerticalAlignment (AlignmentFlag alignment, const WLength &length=WLength()) override
 Sets the vertical alignment.
 
virtual AlignmentFlag verticalAlignment () const override
 Returns the vertical alignment.
 
virtual WLength verticalAlignmentLength () const override
 Returns the fixed vertical alignment that was set.
 
virtual void setToolTip (const WString &text, TextFormat textFormat=TextFormat::Plain) override
 Sets a tooltip.
 
virtual void setDeferredToolTip (bool enable, TextFormat textFormat=TextFormat::Plain) override
 Enable deferred tooltip.
 
virtual WString toolTip () const override
 Returns the tooltip.
 
virtual void refresh () override
 Refresh the widget.
 
virtual void setAttributeValue (const std::string &name, const WString &value) override
 Sets an attribute value.
 
virtual WString attributeValue (const std::string &name) const override
 Returns an attribute value.
 
virtual void setJavaScriptMember (const std::string &name, const std::string &value) override
 Sets a JavaScript member.
 
virtual std::string javaScriptMember (const std::string &name) const override
 Returns the value of a JavaScript member.
 
virtual void callJavaScriptMember (const std::string &name, const std::string &args) override
 Calls a JavaScript member.
 
virtual void load () override
 Loads content just before the widget is used.
 
virtual bool loaded () const override
 Returns whether this widget has been loaded.
 
virtual void setId (const std::string &id) override
 Sets the CSS Id.
 
virtual WWidgetfind (const std::string &name) override
 Finds a descendent widget by name.
 
virtual WWidgetfindById (const std::string &id) override
 Finds a descendent widget by id.
 
virtual void setSelectable (bool selectable) override
 Sets as selectable.
 
virtual void doJavaScript (const std::string &javascript) override
 Executes the given JavaScript statements when the widget is rendered or updated.
 
virtual const std::string id () const override
 Returns the (unique) identifier for this object.
 
void setLoadLaterWhenInvisible (bool)
 Change the way the widget is loaded when invisible.
 
std::string htmlTagName () const
 returns the current html tag name
 
void setHtmlTagName (const std::string &tag)
 set the custom HTML tag name
 
virtual void setCanReceiveFocus (bool enabled) override
 Sets whether the widget can receive focus.
 
virtual bool canReceiveFocus () const override
 Returns whether the widget can receive focus.
 
virtual bool setFirstFocus () override
 Set focus on the widget's first descendant.
 
virtual void setFocus (bool focus) override
 Sets focus.
 
virtual bool hasFocus () const override
 Returns whether the widget currently has the focus.
 
virtual void setTabIndex (int index) override
 Sets the tab index.
 
virtual int tabIndex () const override
 Returns the tab index.
 
EventSignalblurred ()
 Signal emitted when the widget lost focus.
 
EventSignalfocussed ()
 Signal emitted when the widget recieved focus.
 
virtual bool scrollVisibilityEnabled () const final override
 Returns whether scroll visibility detection is enabled for this widget.
 
virtual void setScrollVisibilityEnabled (bool enabled) final override
 Sets whether scroll visibility detection is enabled for this widget.
 
virtual int scrollVisibilityMargin () const final override
 Returns the margin around the viewport within which the widget is considered visible.
 
virtual void setScrollVisibilityMargin (int margin) final override
 Sets the margin around the viewport within which the widget is considered visible.
 
virtual Signal< bool > & scrollVisibilityChanged () final override
 Signal triggered when the scroll visibility of this widget changes.
 
virtual bool isScrollVisible () const final override
 Returns whether this widget is currently considered scroll visible.
 
virtual void setThemeStyleEnabled (bool enabled) final override
 Sets whether theme styling for a widget is enabled or disabled.
 
virtual bool isThemeStyleEnabled () const final override
 Returns whether this widget is currently styled by the chosen theme.
 
virtual void setObjectName (const std::string &name) override
 Sets an object name.
 
void setFocus ()
 Sets focus.
 
virtual void setFocus (bool focus)=0
 Sets focus.
 
- Public Member Functions inherited from Wt::WWidget
virtual ~WWidget ()
 Destructor.
 
WWidgetparent () const
 Returns the parent widget.
 
virtual std::unique_ptr< WWidgetremoveWidget (WWidget *widget)
 Removes a child widget.
 
template<typename Widget >
std::unique_ptr< Widget > removeWidget (Widget *widget)
 Removes a child widget.
 
std::unique_ptr< WWidgetremoveFromParent ()
 Removes the widget from its parent.
 
void setWidth (const WLength &width)
 Sets the width.
 
void setHeight (const WLength &height)
 Sets the height.
 
virtual void positionAt (const WWidget *widget, Orientation orientation=Orientation::Vertical)
 Positions a widget next to another widget.
 
virtual void toggleStyleClass (const WString &styleClass, bool add, bool force=false)
 Toggles a CSS style class.
 
std::string jsRef () const
 Returns a JavaScript expression to the corresponding DOM node.
 
void setFocus ()
 Sets focus.
 
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.
 
bool isRendered () const
 Returns whether the widget is rendered.
 
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.
 
- Public Member Functions inherited from Wt::WObject
void addChild (std::unique_ptr< WObject > child)
 Add a child WObject whose lifetime is determined by this WObject.
 
template<typename Child >
ChildaddChild (std::unique_ptr< Child > child)
 Add a child WObject, returning a raw pointer.
 
std::unique_ptr< WObjectremoveChild (WObject *child)
 Remove a child WObject, so its lifetime is no longer determined by this WObject.
 
template<typename Child >
std::unique_ptr< ChildremoveChild (Child *child)
 Remove a child WObject, so its lifetime is no longer determined by this WObject.
 
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.
 
void isNotStateless ()
 Marks the current function as not stateless.
 
template<class T >
WStatelessSlot * implementJavaScript (void(T::*method)(), const std::string &jsCode)
 Provides a JavaScript implementation for a method.
 
- Public Member Functions inherited from Wt::Core::observable
 observable () noexcept
 Default constructor.
 
virtual ~observable ()
 Destructor.
 
template<typename... Args, typename C >
auto bindSafe (void(C::*method)(Args...)) noexcept
 Protects a method call against object destruction.
 
template<typename... Args, typename C >
auto bindSafe (void(C::*method)(Args...) const) const noexcept
 Protects a const method call against object destruction.
 
template<typename Function >
auto bindSafe (const Function &function) noexcept
 Protects a function against object destruction.
 

Static Public Member Functions

static std::string jsStringLiteral (const std::string &v, char delimiter='\'')
 Turn a CharEncoding::UTF8 encoded string into a JavaScript string literal.
 
- Static Public Member Functions inherited from Wt::WWidget
static WString tr (const char *key)
 Short hand for WString::tr()
 

Protected Member Functions

virtual void propagateSetEnabled (bool enabled) override
 Propagates that a widget was enabled or disabled through children.
 
virtual void enableAjax () override
 Progresses to an Ajax-enabled widget.
 
virtual WStatelessSlot * getStateless (Method method) override
 On-demand stateless slot implementation.
 
virtual void render (WFlags< RenderFlag > flags) override
 Renders the widget.
 
- Protected Member Functions inherited from Wt::WWidget
void setLayoutSizeAware (bool sizeAware)
 Sets the widget to be aware of its size set by a layout manager.
 
virtual void layoutSizeChanged (int width, int height)
 Virtual method that indicates a size change.
 
 WWidget ()
 Creates a widget.
 
virtual void dropEvent (WDropEvent dropEvent)
 Handles a drop event.
 
virtual int boxPadding (Orientation orientation) const
 Returns the widget's built-in padding.
 
virtual int boxBorder (Orientation orientation) const
 Returns the widget's built-in border width.
 
void scheduleRender (WFlags< RepaintFlag > flags=None)
 Schedules rerendering of the widget.
 

Additional Inherited Members

- Public Types inherited from Wt::WObject
typedef void(WObject::* Method) ()
 Typedef for a WObject method without arguments.
 

Detailed Description

A base class for widgets with an HTML counterpart.

All descendants of WWebWidget implement a widget which corresponds almost one-on-one with an HTML element. These widgets provide most capabilities of these HTML elements, but rarely make no attempt to do anything more.

See also
WCompositeWidget

Member Function Documentation

◆ addStyleClass()

void Wt::WWebWidget::addStyleClass ( const WString styleClass,
bool  force = false 
)
overridevirtual

Adds a CSS style class.

When force = true, a JavaScript call will be used to add the style class to the DOM element (if JavaScript is available). This may be necessary when client-side JavaScript manipulates the same style class.

The styleClass should be a single class (although multiple classes will work for the common case that the additional style classes are all not yet present on the element.

Implements Wt::WWidget.

◆ attributeValue()

WString Wt::WWebWidget::attributeValue ( const std::string &  name) const
overridevirtual

Returns an attribute value.

See also
setAttributeValue()

Implements Wt::WWidget.

◆ blurred()

EventSignal & Wt::WWebWidget::blurred ( )

Signal emitted when the widget lost focus.

This signals is only emitted for a widget that canReceiveFocus()

◆ callJavaScriptMember()

void Wt::WWebWidget::callJavaScriptMember ( const std::string &  name,
const std::string &  args 
)
overridevirtual

Calls a JavaScript member.

This calls a JavaScript member.

See also
setJavaScriptMember()

Implements Wt::WWidget.

◆ canReceiveFocus()

bool Wt::WWebWidget::canReceiveFocus ( ) const
overridevirtual

Returns whether the widget can receive focus.

See also
setCanReceiveFocus()

Implements Wt::WWidget.

Reimplemented in Wt::WAnchor, and Wt::WFormWidget.

◆ children()

std::vector< WWidget * > Wt::WWebWidget::children ( ) const
overridevirtual

Returns child widgets.

This returns widgets for which widget->parent() == this.

Implements Wt::WWidget.

◆ childrenChanged()

Signal & Wt::WWebWidget::childrenChanged ( )

Signal emitted when children have been added or removed.

See also
children()

◆ clearSides()

WFlags< Side > Wt::WWebWidget::clearSides ( ) const
overridevirtual

Returns the sides that should remain empty.

See also
setClearSides(WFlags<Side>)

Implements Wt::WWidget.

◆ decorationStyle()

WCssDecorationStyle & Wt::WWebWidget::decorationStyle ( )
overridevirtual

Returns the decoration style of this widget.

This groups all decorative aspects of the widget, which do not affect the widget layout (except for the border properties which may behave like extra margin around the widget).

When a decoration style has not been previously set, it returns a default decoration style object.

See also
setDecorationStyle()

Implements Wt::WWidget.

◆ doJavaScript()

void Wt::WWebWidget::doJavaScript ( const std::string &  js)
overridevirtual

Executes the given JavaScript statements when the widget is rendered or updated.

Calling WApplication::doJavaScript() with JavaScript code that refers to a widget using jsRef(), that is still to be rendered may cause JavaScript errors because the corresponding DOM node does not exist. This happens for example when a widget is created, but not yet inserted in the widget tree.

This method guarantees that the JavaScript code is only run when the corresponding DOM node (using jsRef()) resolves to a valid DOM object.

See also
jsRef()

Implements Wt::WWidget.

◆ enableAjax()

void Wt::WWebWidget::enableAjax ( )
overrideprotectedvirtual

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()

Implements Wt::WWidget.

Reimplemented in Wt::WAbstractMedia, Wt::WAnchor, Wt::WFileDropWidget, Wt::WFileUpload, Wt::WFormWidget, Wt::WMenuItem, Wt::WPaintedWidget, Wt::WPushButton, Wt::WSlider, and Wt::WTemplate.

◆ find()

WWidget * Wt::WWebWidget::find ( const std::string &  name)
overridevirtual

Finds a descendent widget by name.

See also
setObjectName()

Implements Wt::WWidget.

◆ floatSide()

Side Wt::WWebWidget::floatSide ( ) const
overridevirtual

Returns the CSS float side.

See also
setFloatSide(Side)

Implements Wt::WWidget.

◆ focussed()

EventSignal & Wt::WWebWidget::focussed ( )

Signal emitted when the widget recieved focus.

This signals is only emitted for a widget that canReceiveFocus()

◆ getStateless()

WStatelessSlot * Wt::WWebWidget::getStateless ( Method  method)
overrideprotectedvirtual

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.

◆ height()

WLength Wt::WWebWidget::height ( ) const
overridevirtual

Returns the height.

Returns the height set for this widget. This is not a calculated height, based on layout, but the height as specified previously with resize(const WLength& width, const WLength& height).

This applies to CSS-based layout.

See also
resize(const WLength&, const WLength&), width()

Implements Wt::WWidget.

◆ hiddenKeepsGeometry()

bool Wt::WWebWidget::hiddenKeepsGeometry ( ) const
overridevirtual

Returns whether the widget keeps its geometry when hidden.

See also
setHiddenKeepsGeometry()

Implements Wt::WWidget.

◆ htmlTagName()

std::string Wt::WWebWidget::htmlTagName ( ) const

returns the current html tag name

See also
setHtmlTagName()

◆ id()

const std::string Wt::WWebWidget::id ( ) const
overridevirtual

Returns the (unique) identifier for this object.

For a WWidget, this corresponds to the id of the DOM element that represents the widget. This is not entirely unique, since a composite widget shares the same id as its implementation.

By default, the id is auto-generated, unless a custom id is set for a widget using WWidget::setId().

See also
WWidget::jsRef()

Reimplemented from Wt::WObject.

◆ isDisabled()

bool Wt::WWebWidget::isDisabled ( ) const
overridevirtual

Returns whether the widget is set disabled.

A widget that is not set disabled may still be disabled when one of its ancestor widgets is set disabled. Use isEnabled() to find out whether a widget is enabled.

See also
setDisabled(), isEnabled()

Implements Wt::WWidget.

◆ isEnabled()

bool Wt::WWebWidget::isEnabled ( ) const
overridevirtual

Returns whether the widget is enabled.

A widget is enabled if it is not disabled, and none of its ancestors are disabled. This method returns whether the widget is rendered as enabled, while isDisabled() returns whether a widget has been explicitly disabled.

Note that a widget may be at the same time not enabled, and not disabled, in case one of its ancestors was disabled.

See also
isDisabled()

Implements Wt::WWidget.

Reimplemented in Wt::WInteractWidget.

◆ isHidden()

bool Wt::WWebWidget::isHidden ( ) const
overridevirtual

Returns whether the widget is set hidden.

A widget that is not hidden may still be not visible when one of its ancestor widgets is hidden. Use isVisible() to check the visibility of a widget.

See also
setHidden(), isVisible()

Implements Wt::WWidget.

◆ isInline()

bool Wt::WWebWidget::isInline ( ) const
overridevirtual

Returns whether the widget is displayed inline or as block.

See also
setInline(bool)

Implements Wt::WWidget.

◆ isPopup()

bool Wt::WWebWidget::isPopup ( ) const
overridevirtual

Returns whether the widget is overlayed.

This applies to CSS-based layout.

See also
setPopup(bool)

Implements Wt::WWidget.

◆ isScrollVisible()

bool Wt::WWebWidget::isScrollVisible ( ) const
finaloverridevirtual

Returns whether this widget is currently considered scroll visible.

isScrollVisible() is initially false.

See also
setScrollVisibilityEnabled()

Implements Wt::WWidget.

◆ isThemeStyleEnabled()

bool Wt::WWebWidget::isThemeStyleEnabled ( ) const
finaloverridevirtual

Returns whether this widget is currently styled by the chosen theme.

isThemeEnabled() is initially true.

See also
setThemeStyleEnabled()

Implements Wt::WWidget.

◆ isVisible()

bool Wt::WWebWidget::isVisible ( ) const
overridevirtual

Returns whether the widget is visible.

A widget is visible if it is not hidden, and none of its ancestors are hidden. This method returns the true visibility, while isHidden() returns whether a widget has been explicitly hidden.

Note that a widget may be at the same time not hidden, and not visible, in case one of its ancestors was hidden.

See also
isHidden()

Implements Wt::WWidget.

Reimplemented in Wt::WTableCell.

◆ javaScriptMember()

std::string Wt::WWebWidget::javaScriptMember ( const std::string &  name) const
overridevirtual

Returns the value of a JavaScript member.

See also
setJavaScriptMember()

Implements Wt::WWidget.

◆ jsStringLiteral()

std::string Wt::WWebWidget::jsStringLiteral ( const std::string &  v,
char  delimiter = '\'' 
)
static

Turn a CharEncoding::UTF8 encoded string into a JavaScript string literal.

The delimiter may be a single or double quote.

◆ lineHeight()

WLength Wt::WWebWidget::lineHeight ( ) const
overridevirtual

Returns the CSS line height for contained text.

sa setLineHeight()

Implements Wt::WWidget.

◆ load()

void Wt::WWebWidget::load ( )
overridevirtual

Loads content just before the widget is used.

This function is called when a widget is inserted in the widget hierarchy. Widgets that get inserted in the widget hierarchy will be rendered. Visible widgets are rendered immediately, and invisible widgets in the back-ground (or not for a plain HTML session). This method is called when the widget is directly or indirectly inserted into the widget tree.

The default implementation simply propagates the load signal to its children. You may want to override this method to delay loading of resource-intensive contents.

During the life-time of a widget, this method may be called multiple times, so you should make sure that you do a deferred initialization only once.

Implements Wt::WWidget.

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

◆ loaded()

bool Wt::WWebWidget::loaded ( ) const
overridevirtual

Returns whether this widget has been loaded.

See also
load()

Implements Wt::WWidget.

◆ margin()

WLength Wt::WWebWidget::margin ( Side  side) const
overridevirtual

Returns a CSS margin set.

This applies to CSS-based layout.

See also
setMargin()

Implements Wt::WWidget.

◆ maximumHeight()

WLength Wt::WWebWidget::maximumHeight ( ) const
overridevirtual

Returns the maximum height.

Returns the minmum height set for this widget with setMaximumSize().

See also
setMaximumSize(), maximumWidth()

Implements Wt::WWidget.

◆ maximumWidth()

WLength Wt::WWebWidget::maximumWidth ( ) const
overridevirtual

Returns the maximum width.

Returns the maximum width set for this widget with setMaximumSize().

See also
setMaximumSize(), maximumHeight()

Implements Wt::WWidget.

◆ minimumHeight()

WLength Wt::WWebWidget::minimumHeight ( ) const
overridevirtual

Returns the minimum height.

Returns the minmum height set for this widget with setMinimumSize().

See also
setMinimumSize(), minimumWidth()

Implements Wt::WWidget.

◆ minimumWidth()

WLength Wt::WWebWidget::minimumWidth ( ) const
overridevirtual

Returns the minimum width.

Returns the minimum width set for this widget with setMinimumSize().

See also
setMinimumSize(), minimumHeight()

Implements Wt::WWidget.

◆ offset()

WLength Wt::WWebWidget::offset ( Side  side) const
overridevirtual

Returns a CSS offset.

This applies to CSS-based layout.

See also
setOffsets(const WLength&, WFlags<Side>)

Implements Wt::WWidget.

◆ positionScheme()

PositionScheme Wt::WWebWidget::positionScheme ( ) const
overridevirtual

Returns the CSS position scheme.

This applies to CSS-based layout.

See also
Wt::PositionScheme, setPositionScheme(PositionScheme)

Implements Wt::WWidget.

◆ propagateSetEnabled()

void Wt::WWebWidget::propagateSetEnabled ( bool  enabled)
overrideprotectedvirtual

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.

Implements Wt::WWidget.

Reimplemented in Wt::WAnchor, Wt::WDateEdit, Wt::WFileUpload, Wt::WFormWidget, Wt::WInteractWidget, Wt::WLabel, Wt::WPushButton, Wt::WTextEdit, and Wt::WTimeEdit.

◆ refresh()

void Wt::WWebWidget::refresh ( )
overridevirtual

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::WWidget.

Reimplemented in Wt::WAbstractSpinBox, Wt::WAbstractToggleButton, Wt::WComboBox, Wt::WDateEdit, Wt::WDoubleSpinBox, Wt::WFormWidget, Wt::WGroupBox, Wt::WPushButton, Wt::WTemplate, Wt::WText, and Wt::WViewWidget.

◆ removeStyleClass()

void Wt::WWebWidget::removeStyleClass ( const WString styleClass,
bool  force = false 
)
overridevirtual

Removes a CSS style class.

When force = true, a JavaScript call will be used to remove the style class from the DOM element (if JavaScript is available). This may be necessary when client-side JavaScript manipulates the same style class.

The styleClass should be a single class

Implements Wt::WWidget.

◆ render()

void Wt::WWebWidget::render ( WFlags< RenderFlag flags)
overrideprotectedvirtual

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::WWidget.

Reimplemented in Wt::Auth::AuthWidget, Wt::Auth::RegistrationWidget, Wt::Chart::WAxisSliderWidget, Wt::Chart::WCartesianChart, Wt::WAbstractSpinBox, Wt::WDateEdit, Wt::WDoubleSpinBox, Wt::WEmailEdit, Wt::WFormWidget, Wt::WGLWidget, Wt::WImage, Wt::WLineEdit, Wt::WMenuItem, Wt::WPaintedWidget, Wt::WSlider, Wt::WStackedWidget, Wt::WText, Wt::WTimeEdit, and Wt::WViewWidget.

◆ resize()

void Wt::WWebWidget::resize ( const WLength width,
const WLength height 
)
overridevirtual

Resizes the widget.

Specifies a fixed size for this widget, setting CSS width and height properties. By default a widget has automatic width and height, which sets a size for the widget following CSS rules.

When the widget is not managed by a layout manager, the automatic (natural) size of a widget depends on whether they widget is a block or inline widget:

  • a block widget takes by default the width of the parent, and the height that it needs based on its contents
  • an inline widget takes the width and height that it needs based on its contents (possibly wrapping over multiple lines). The width and height of an inline widget cannot be changed (by the letter of CSS, although most browsers will react to it in varying ways).

When inserted in a layout manager, the size set will be used as a widget's preferred size, but the widget may be given a different size by the layout manager based on available space and stretch factors. The actual size given by a layout manager may be retrieved by making the widget "layout size aware", using setLayoutSizeAware(). If you have defined a "wtResize()" JavaScript method for the widget, then this method will also be called.

The default width and height of a widget is WLength::Auto.

See also
width(), height()

Reimplemented from Wt::WWidget.

Reimplemented in Wt::Chart::WCartesian3DChart, Wt::WFlashObject, Wt::WGLWidget, Wt::WPaintedWidget, Wt::WProgressBar, Wt::WSlider, Wt::WTextEdit, and Wt::WVideo.

◆ scrollVisibilityChanged()

Signal< bool > & Wt::WWebWidget::scrollVisibilityChanged ( )
finaloverridevirtual

Signal triggered when the scroll visibility of this widget changes.

The boolean parameter indicates whether the widget is currently scroll visible.

See also
setScrollVisibilityEnabled()

Implements Wt::WWidget.

◆ scrollVisibilityEnabled()

bool Wt::WWebWidget::scrollVisibilityEnabled ( ) const
finaloverridevirtual

Returns whether scroll visibility detection is enabled for this widget.

See also
setScrollVisibilityEnabled()

Implements Wt::WWidget.

◆ scrollVisibilityMargin()

int Wt::WWebWidget::scrollVisibilityMargin ( ) const
finaloverridevirtual

Returns the margin around the viewport within which the widget is considered visible.

See also
setScrollVisibilityMargin()

Implements Wt::WWidget.

◆ setAttributeValue()

void Wt::WWebWidget::setAttributeValue ( const std::string &  name,
const WString value 
)
overridevirtual

Sets an attribute value.

Sets the value for an HTML attribute.

This is only useful for HTML features that are not supported directly in Wt (and beware that browsers have non-consistent support for many more exotic HTML features).

See also
JSlot, doJavaScript()

Implements Wt::WWidget.

◆ setCanReceiveFocus()

void Wt::WWebWidget::setCanReceiveFocus ( bool  enabled)
overridevirtual

Sets whether the widget can receive focus.

By default, only form widgets (descendants of WFormWidget), anchors (WAnchor) and buttons (WPushButton) can receive focus.

Any other widget can be configured to receive focus however.

Implements Wt::WWidget.

◆ setClearSides()

void Wt::WWebWidget::setClearSides ( WFlags< Side sides)
overridevirtual

Sets the sides that should be cleared of floats.

This pushes the widget down until it is not surrounded by floats at the sides (which may be a combination of Wt::Side::Left and Wt::Side::Right).

This applies to CSS-based layout.

See also
setFloatSide()

Implements Wt::WWidget.

◆ setDecorationStyle()

void Wt::WWebWidget::setDecorationStyle ( const WCssDecorationStyle style)
overridevirtual

Sets a CSS decoration style.

This copies the style over its current decorationStyle()

Implements Wt::WWidget.

◆ setDeferredToolTip()

void Wt::WWebWidget::setDeferredToolTip ( bool  enable,
TextFormat  textFormat = TextFormat::Plain 
)
overridevirtual

Enable deferred tooltip.

You may override toolTip() to read data only when the user hovers over the widget.

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

Note: To change existing toolTip call setDeferredToolTip() again.

See also
toolTip

Implements Wt::WWidget.

◆ setDisabled()

void Wt::WWebWidget::setDisabled ( bool  disabled)
overridevirtual

Sets whether the widget is disabled.

Enables or disables the widget (including all its descendant widgets). setDisabled(false) will enable this widget and all descendant widgets that are not disabled. A widget is only enabled if it and all its ancestors in the widget tree are disabled.

Typically, a disabled form widget will not allow changing the value, and disabled widgets will not react to mouse click events.

Note
enable() and disable() are considered to be stateless slots by default. If you override setDisabled() and need to modify server state whenever it is called, you'll need to call WObject::isNotStateless().
See also
disable(), enable()

Implements Wt::WWidget.

Reimplemented in Wt::WMenuItem, and Wt::WSlider.

◆ setFirstFocus()

bool Wt::WWebWidget::setFirstFocus ( )
overridevirtual

Set focus on the widget's first descendant.

Set focus on the widget itself, or on a first descendant which can receive focus.

Returns whether focus could be set.

Implements Wt::WWidget.

Reimplemented in Wt::WAnchor, and Wt::WPushButton.

◆ setFloatSide()

void Wt::WWebWidget::setFloatSide ( Side  s)
overridevirtual

Specifies a CSS float side.

This only applies to widgets with a Wt::PositionScheme::Static positionScheme().

This lets the widget float to one of the sides of the parent widget, at the current line. A typical use is to position images within text. Valid values for Side Side::Left, or Side::Right.

This applies to CSS-based layout.

Implements Wt::WWidget.

◆ setFocus() [1/3]

void Wt::WWidget::setFocus ( )

Sets focus.

This only has an effect for a widget which can receive focus, and is equivalent to setFocus(true).

See also
setCanReceiveFocus()

◆ setFocus() [2/3]

void Wt::WWebWidget::setFocus ( bool  focus)
overridevirtual

Sets focus.

When using focus = false, you can undo a previous setFocus() call.

Implements Wt::WWidget.

◆ setFocus() [3/3]

virtual void Wt::WWidget::setFocus ( bool  focus)
virtual

Sets focus.

When using focus = false, you can undo a previous setFocus() call.

Implements Wt::WWidget.

◆ setHidden()

void Wt::WWebWidget::setHidden ( bool  hidden,
const WAnimation animation = WAnimation() 
)
overridevirtual

Hides or shows the widget.

Hides or show the widget (including all its descendant widgets). When setting hidden = false, this widget and all descendant widgets that are not hidden will be shown. A widget is only visible if it and all its ancestors in the widget tree are visible, which may be checked using isVisible().

Note
hide() and show() are considered to be stateless slots by default. If you override setHidden() and need to modify server state whenever it is called, you'll need to call WObject::isNotStateless().

Implements Wt::WWidget.

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

◆ setHiddenKeepsGeometry()

void Wt::WWebWidget::setHiddenKeepsGeometry ( bool  enabled)
overridevirtual

Sets whether the widget keeps its geometry when hidden.

Normally, a widget that is hidden will no longer occupy space, causing a reflow of sibling widgets. Using this method you may change this behavior to keep an (open) space when hidden.

Note
Currently you can only set this before initial rendering.
See also
setHidden()

Implements Wt::WWidget.

◆ setHtmlTagName()

void Wt::WWebWidget::setHtmlTagName ( const std::string &  tag)

set the custom HTML tag name

The custom tag will replace the actual tag. The tag is not tested to see if it is a valid one and a closing tag will always be added.

See also
htmlTagName()

◆ setId()

void Wt::WWebWidget::setId ( const std::string &  id)
overridevirtual

Sets the CSS Id.

Sets a custom Id. Note that the Id must be unique across the whole widget tree, can only be set right after construction and cannot be changed. This is mostly useful for in tests using a test plan that manipulates DOM elements by Id.

By default, auto-generated id's are used.

Note
An id must start with a letter ([A-Za-z]), followed by one or more letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods (".").
Warning
We recommend that you leave the id of a widget unchanged. Wt uses the id to identify widgets in the JavaScript it generates, and this can often leads to bugs. If you do change the id, only change the id right after widget construction. However, usually there's a more preferable alternative, like setting the object name (WObject::setObjectName), or adding style classes (WWidget::addStyleClass).
See also
WObject::id()

Implements Wt::WWidget.

◆ setInline()

void Wt::WWebWidget::setInline ( bool  inlined)
overridevirtual

Sets whether the widget is displayed inline or as a block.

This option changes whether this widget must be rendered in line with sibling widgets wrapping at the right edge of the parent container (like text), or whether this widget must be rendered as a rectangular block that stacks vertically with sibling widgets (unless a CSS float property is applied). Depending on the widget type, the default value is inline (such as for example for WText, or WPushButton), or block (such as for example for a WContainerWidget).

This applies to CSS-based layout.

Implements Wt::WWidget.

◆ setJavaScriptMember()

void Wt::WWebWidget::setJavaScriptMember ( const std::string &  name,
const std::string &  value 
)
overridevirtual

Sets a JavaScript member.

This binds a JavaScript member, which is set as a JavaScript property to the DOM object that implements this widget. The value may be any JavaScript expression, including a function.

Members that start with "wt" are reserved for internal use. You may define a member "wtResize(self, width, height)" method if your widget needs active layout management. If defined, this method will be used by layout managers and when doing resize() to set the size of the widget, instead of setting the CSS width and height properties.

Implements Wt::WWidget.

◆ setLoadLaterWhenInvisible()

void Wt::WWebWidget::setLoadLaterWhenInvisible ( bool  how)

Change the way the widget is loaded when invisible.

By default, invisible widgets are loaded only after visible content. For tiny widgets this may lead to a performance loss, instead of the expected increase, because they require many more DOM manipulations to render, reducing the overall responsiveness of the application.

Therefore, this is disabled for some widgets like WImage, or empty WContainerWidgets.

You may also want to disable deferred loading when JavaScript event handling expects the widget to be loaded.

Usually the default settings are fine, but you may want to change the behaviour.

See also
WApplication::setTwoPhaseRenderingThreshold()

◆ setMargin()

void Wt::WWebWidget::setMargin ( const WLength margin,
WFlags< Side sides = AllSides 
)
overridevirtual

Sets CSS margins around the widget.

Setting margin has the effect of adding a distance between the widget and surrounding widgets. The default margin (with an automatic length) is zero.

Use any combination of Wt::Side::Left, Wt::Side::Right, Wt::Side::Bottom, or Wt::Side::Top.

This applies to CSS-based layout.

See also
margin()

Implements Wt::WWidget.

◆ setMaximumSize()

void Wt::WWebWidget::setMaximumSize ( const WLength width,
const WLength height 
)
overridevirtual

Sets a maximum size.

Specifies a maximum size for this widget, setting CSS max-width and max-height properties.

The default the maximum width and height are WLength::Auto, indicating no maximum size. A LengthUnit::Percentage size should not be used, as this is (in virtually all cases) undefined behaviour.

When the widget is a container widget that contains a layout manager, then setting a maximum size will have the effect of letting the size of the container to reflect the preferred size of the contents (rather than constraining the size of the children based on the size of the container), up to the specified maximum size.

See also
resize(), setMinimumSize()

Implements Wt::WWidget.

◆ setMinimumSize()

void Wt::WWebWidget::setMinimumSize ( const WLength width,
const WLength height 
)
overridevirtual

Sets a minimum size.

Specifies a minimum size for this widget, setting CSS min-width and min-height properties.

The default minimum width and height is 0. The special value WLength::Auto indicates that the initial width is used as minimum size. A LengthUnit::Percentage size should not be used, as this is (in virtually all cases) undefined behaviour.

When the widget is inserted in a layout manager, then the minimum size will be taken into account.

See also
resize(), minimumWidth(), minimumHeight()

Implements Wt::WWidget.

◆ setObjectName()

void Wt::WWebWidget::setObjectName ( const std::string &  name)
overridevirtual

Sets an object name.

The object name can be used to easily identify a type of object in the DOM, and does not need to be unique. It will usually reflect the widget type or role.

If a WWidget has an object name, the object name is reflected in the data-object-name attribute. You can use this to find widgets in JavaScript (e.g. for automated testing) using:

document.querySelector('*[data-object-name="yourObjectNameHere"]')

The default object name is empty (no object name).

Reimplemented from Wt::WObject.

◆ setOffsets()

void Wt::WWebWidget::setOffsets ( const WLength offset,
WFlags< Side sides = AllSides 
)
overridevirtual

Sets CSS offsets for a non-statically positioned widget.

The argument sides may be a combination of Wt::Side::Left, Wt::Side::Right, Wt::Side::Top, and Wt::Side::Bottom.

This applies only to widgets that have a position scheme that is Wt::PositionScheme::Relative, Wt::PositionScheme::Absolute, or Wt::PositionScheme::Fixed, and has a slightly different meaning for these three cases.

For a relatively positioned widget, an offset applies relative to the position the widget would have when layed-out using a static position scheme. The widget may be shifted to the left or right by specifying an offset for the left or right) side. The widget may be shifted vertically, by specifying an offset for the top or bottom side.

For an absolutely positioned widget, an offset specifies a distance of the corresponding side of the widget with respect to the corresponding side of the reference parent widget. Thus, setting all offsets to 0 result in a widget that spans the entire reference widget. The reference parent widget is the first ancestor widget that is a table cell, or a widget with a relative, absolute or fixed position scheme.

For an fixed positioned widget, an offset specifies a distance of the corresponding side of the widget with respect to the browser window, regardless of scrolling. Thus, setting all offsets to 0 result in a widget that spans the entire browser window.

This applies to CSS-based layout.

See also
offset(Side) const

Implements Wt::WWidget.

◆ setPopup()

void Wt::WWebWidget::setPopup ( bool  popup)
overridevirtual

Lets the widget overlay over other sibling widgets.

A widget that isPopup() will be rendered on top of any other sibling widget contained within the same parent (including other popup widgets previously added to the container).

This will only have an effect when the widgetis either Wt::PositionScheme::Absolute or Wt::PositionScheme::Fixed positionScheme().

This applies to CSS-based layout, and configures the z-index property.

Implements Wt::WWidget.

Reimplemented in Wt::WInteractWidget.

◆ setPositionScheme()

void Wt::WWebWidget::setPositionScheme ( PositionScheme  scheme)
overridevirtual

Sets the CSS position scheme.

Establishes how the widget must be layed-out relative to its siblings. The default position scheme is PositionScheme::Static.

This applies to CSS-based layout.

See also
Wt::PositionScheme, positionScheme()

Implements Wt::WWidget.

◆ setScrollVisibilityEnabled()

void Wt::WWebWidget::setScrollVisibilityEnabled ( bool  enabled)
finaloverridevirtual

Sets whether scroll visibility detection is enabled for this widget.

Disabled by default. When enabled, the client keeps track of whether this widget is currently visible inside of the browser window. A widget is "scroll visible" if it is currently visible according to isVisible(), and its position is inside of the browser window, with an extra margin determined by scrollVisibilityMargin().

If scroll visibility changes, the scrollVisibilityChanged() signal is fired, and isScrollVisible() is updated.

This feature can be useful to implement infinite scroll, where a sentinel widget placed at the bottom of the page causes more content to be loaded when it becomes visible, see the scrollvisibility example.

This feature can also be used to lazy load widgets when they become visible.

Note
If the widget is "scroll visible" when scroll visibility detection is first enabled, the scrollVisibilityChanged() signal will be emitted. If it is outside of the browser's viewport when first enabled, the scrollVisibilityChanged() signal will not be emitted.
If scroll visibility is enabled, disabled, and then enabled again, isScrollVisible() may not be correctly updated, and scrollVisibilityChanged() may not be correctly emitted, because then Wt can't properly keep track of the state that the widget is in on the client side. This feature is not intended to be toggled on and off, but rather enabled once and disabled once after that.

Implements Wt::WWidget.

◆ setScrollVisibilityMargin()

void Wt::WWebWidget::setScrollVisibilityMargin ( int  margin)
finaloverridevirtual

Sets the margin around the viewport within which the widget is considered visible.

This causes the widget to be considered "scroll visible" before it is within the viewport. Setting this margin could be useful to trigger the loading of content before it is in view.

Implements Wt::WWidget.

◆ setSelectable()

void Wt::WWebWidget::setSelectable ( bool  selectable)
overridevirtual

Sets as selectable.

When a widget is made unselectable, a selection of text (or images) will not be visible (but may still be possible).

By default, the widget inherits this property from its parent, and this property propagates to all children. The top level container (WApplication::root()) selectable by default.

Implements Wt::WWidget.

Reimplemented in Wt::WMenuItem.

◆ setStyleClass()

void Wt::WWebWidget::setStyleClass ( const WString styleClass)
overridevirtual

Sets (one or more) CSS style classes.

You may set one or more space separated style classes. CSS style class works in conjunction with style sheet, and provides a flexible way to provide many widgets the same markup.

Setting an empty string removes the style class(es).

See also
WApplication::styleSheet()

Implements Wt::WWidget.

◆ setTabIndex()

void Wt::WWebWidget::setTabIndex ( int  index)
overridevirtual

Sets the tab index.

For widgets that receive focus (canReceiveFocus()), 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.

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 (for a widget that can receive focus).

See also
setTabOrder()

Implements Wt::WWidget.

◆ setThemeStyleEnabled()

void Wt::WWebWidget::setThemeStyleEnabled ( bool  enabled)
finaloverridevirtual

Sets whether theme styling for a widget is enabled or disabled.

By default all widgets are styled according to the chosen theme. Disabling the theme style could be useful to completely customize the style of the widget outside of the theme.

Note
This should be changed after the construction but before the rendering of the widget.

Implements Wt::WWidget.

◆ setToolTip()

void Wt::WWebWidget::setToolTip ( const WString text,
TextFormat  textFormat = TextFormat::Plain 
)
overridevirtual

Sets a tooltip.

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

When textFormat is TextFormat::XHTML, 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()

Implements Wt::WWidget.

Reimplemented in Wt::WFormWidget.

◆ setVerticalAlignment()

void Wt::WWebWidget::setVerticalAlignment ( AlignmentFlag  alignment,
const WLength length = WLength() 
)
overridevirtual

Sets the vertical alignment.

This only applies to inline widgets, and determines how to position itself on the current line, with respect to sibling inline widgets.

This applies to CSS-based layout.

Implements Wt::WWidget.

◆ styleClass()

WString Wt::WWebWidget::styleClass ( ) const
overridevirtual

Returns the CSS style class.

See also
setStyleClass()

Implements Wt::WWidget.

◆ tabIndex()

int Wt::WWebWidget::tabIndex ( ) const
overridevirtual

Returns the tab index.

See also
setTabIndex()

Implements Wt::WWidget.

Reimplemented in Wt::WAnchor, and Wt::WFormWidget.

◆ verticalAlignment()

AlignmentFlag Wt::WWebWidget::verticalAlignment ( ) const
overridevirtual

Returns the vertical alignment.

This applies to CSS-based layout.

See also
setVerticalAlignment()

Implements Wt::WWidget.

◆ verticalAlignmentLength()

WLength Wt::WWebWidget::verticalAlignmentLength ( ) const
overridevirtual

Returns the fixed vertical alignment that was set.

This applies to CSS-based layout.

See also
setVerticalAlignment()

Implements Wt::WWidget.

◆ width()

WLength Wt::WWebWidget::width ( ) const
overridevirtual

Returns the width.

Returns the width set for this widget. This is not a calculated width, based on layout, but the width as specified with resize(const WLength&, const WLength&).

This applies to CSS-based layout.

See also
resize(const WLength&, const WLength&), height()

Implements Wt::WWidget.