Wt: Wt::WWidget Class Reference

Wt 4.10.4

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

The abstract base class for a user-interface component. More...

`#include <Wt/WWidget.h>`

Inheritance diagram for Wt::WWidget:
[legend]

## Public Member Functions
virtual | ~WWidget ()
| Destructor.
WWidget * | parent () const
| Returns the parent widget.
virtual std::vector< WWidget * > | children () const =0
| Returns child widgets.
virtual std::unique_ptr< WWidget > | removeWidget (WWidget *widget)
| Removes a child widget.
template<typename Widget >
std::unique_ptr< Widget > | removeWidget (Widget *widget)
| Removes a child widget.
std::unique_ptr< WWidget > | removeFromParent ()
| Removes the widget from its parent.
virtual void | setPositionScheme (PositionScheme scheme)=0
| Sets the CSS position scheme.
virtual PositionScheme | positionScheme () const =0
| Returns the CSS position scheme.
virtual void | setOffsets (const WLength &offset, WFlags< Side > sides=AllSides)=0
| Sets CSS offsets for a non-statically positioned widget.
virtual WLength | offset (Side side) const =0
| Returns a CSS offset.
virtual void | resize (const WLength &width, const WLength &height)
| Resizes the widget.
virtual WLength | width () const =0
| Returns the width.
void | setWidth (const WLength &width)
| Sets the width.
virtual WLength | height () const =0
| Returns the height.
void | setHeight (const WLength &height)
| Sets the height.
virtual void | setMinimumSize (const WLength &width, const WLength &height)=0
| Sets a minimum size.
virtual WLength | minimumWidth () const =0
| Returns the minimum width.
virtual WLength | minimumHeight () const =0
| Returns the minimum height.
virtual void | setMaximumSize (const WLength &width, const WLength &height)=0
| Sets a maximum size.
virtual WLength | maximumWidth () const =0
| Returns the maximum width.
virtual WLength | maximumHeight () const =0
| Returns the maximum height.
virtual void | positionAt (const WWidget *widget, Orientation orientation=Orientation::Vertical)
| Positions a widget next to another widget.
virtual void | setLineHeight (const WLength &height)=0
| Sets the CSS line height for contained text.
virtual WLength | lineHeight () const =0
| Returns the CSS line height for contained text.
virtual void | setFloatSide (Side s)=0
| Specifies a CSS float side.
virtual Side | floatSide () const =0
| Returns the CSS float side.
virtual void | setClearSides (WFlags< Side > sides)=0
| Sets the sides that should be cleared of floats.
virtual WFlags< Side > | clearSides () const =0
| Returns the sides that should remain empty.
virtual void | setMargin (const WLength &margin, WFlags< Side > sides=AllSides)=0
| Sets CSS margins around the widget.
virtual WLength | margin (Side side) const =0
| Returns a CSS margin set.
virtual void | setHiddenKeepsGeometry (bool enabled)=0
| Sets whether the widget keeps its geometry when hidden.
virtual bool | hiddenKeepsGeometry () const =0
| Returns whether the widget keeps its geometry when hidden.
virtual void | setHidden (bool hidden, const WAnimation &animation=WAnimation())=0
| Hides or shows the widget.
virtual bool | isHidden () const =0
| Returns whether the widget is set hidden.
virtual bool | isVisible () const =0
| Returns whether the widget is visible.
virtual void | setDisabled (bool disabled)=0
| Sets whether the widget is disabled.
virtual bool | isDisabled () const =0
| Returns whether the widget is set disabled.
virtual bool | isEnabled () const =0
| Returns whether the widget is enabled.
virtual void | setPopup (bool popup)=0
| Lets the widget overlay over other sibling widgets.
virtual bool | isPopup () const =0
| Returns whether the widget is overlayed.
virtual void | setInline (bool inlined)=0
| Sets whether the widget is displayed inline or as a block.
virtual bool | isInline () const =0
| Returns whether the widget is displayed inline or as block.
virtual void | setDecorationStyle (const WCssDecorationStyle &style)=0
| Sets a CSS decoration style.
virtual WCssDecorationStyle & | decorationStyle ()=0
| Returns the decoration style of this widget.
virtual void | setStyleClass (const WString &styleClass)=0
| Sets (one or more) CSS style classes.
virtual WString | styleClass () const =0
| Returns the CSS style class.
virtual void | addStyleClass (const WString &styleClass, bool force=false)=0
| Adds a CSS style class.
virtual void | removeStyleClass (const WString &styleClass, bool force=false)=0
| Removes a CSS style class.
virtual void | toggleStyleClass (const WString &styleClass, bool add, bool force=false)
| Toggles a CSS style class.
virtual bool | hasStyleClass (const WString &styleClass) const =0
| Returns whether the widget has a style class.
virtual void | setVerticalAlignment (AlignmentFlag alignment, const WLength &length=WLength::Auto)=0
| Sets the vertical alignment.
virtual AlignmentFlag | verticalAlignment () const =0
| Returns the vertical alignment.
virtual WLength | verticalAlignmentLength () const =0
| Returns the fixed vertical alignment that was set.
virtual void | setToolTip (const WString &text, TextFormat textFormat=TextFormat::Plain)=0
| Sets a tooltip.
virtual WString | toolTip () const =0
| Returns the tooltip.
virtual void | setDeferredToolTip (bool enable, TextFormat textFormat=TextFormat::Plain)=0
| Enable deferred tooltip.
virtual void | refresh ()
| Refresh the widget.
std::string | jsRef () const
| Returns a JavaScript expression to the corresponding DOM node.
virtual void | setAttributeValue (const std::string &name, const WString &value)=0
| Sets an attribute value.
virtual WString | attributeValue (const std::string &name) const =0
| Returns an attribute value.
virtual void | setJavaScriptMember (const std::string &name, const std::string &value)=0
| Sets a JavaScript member.
virtual std::string | javaScriptMember (const std::string &name) const =0
| Returns the value of a JavaScript member.
virtual void | callJavaScriptMember (const std::string &name, const std::string &args)=0
| Calls a JavaScript member.
virtual void | load ()=0
| Loads content just before the widget is used.
virtual bool | loaded () const =0
| Returns whether this widget has been loaded.
virtual void | setCanReceiveFocus (bool enabled)=0
| Sets whether the widget can receive focus.
virtual bool | canReceiveFocus () const =0
| Returns whether the widget can receive focus.
void | setFocus ()
| Sets focus.
virtual void | setFocus (bool focus)=0
| Sets focus.
virtual bool | setFirstFocus ()=0
| Set focus on the widget's first descendant.
virtual bool | hasFocus () const =0
| Returns whether the widget currently has the focus.
virtual void | setTabIndex (int index)=0
| Sets the tab index.
virtual int | tabIndex () const =0
| Returns the tab index.
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 | setId (const std::string &id)=0
| Sets the CSS Id.
virtual WWidget * | find (const std::string &name)=0
| Finds a descendent widget by name.
virtual WWidget * | findById (const std::string &id)=0
| Finds a descendent widget by id.
virtual void | htmlText (std::ostream &out)
| Streams the (X)HTML representation.
virtual void | setSelectable (bool selectable)=0
| Sets as selectable.
virtual void | doJavaScript (const std::string &js)=0
| Executes the given JavaScript statements when the widget is rendered or updated.
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.
virtual bool | scrollVisibilityEnabled () const =0
| Returns whether scroll visibility detection is enabled for this widget.
virtual void | setScrollVisibilityEnabled (bool enabled)=0
| Sets whether scroll visibility detection is enabled for this widget.
virtual int | scrollVisibilityMargin () const =0
| Returns the margin around the viewport within which the widget is considered visible.
virtual void | setScrollVisibilityMargin (int margin)=0
| Sets the margin around the viewport within which the widget is considered visible.
virtual Signal< bool > & | scrollVisibilityChanged ()=0
| Signal triggered when the scroll visibility of this widget changes.
virtual bool | isScrollVisible () const =0
| Returns whether this widget is currently considered scroll visible.
virtual void | setThemeStyleEnabled (bool enabled)=0
| Sets whether theme styling for a widget is enabled or disabled.
virtual bool | isThemeStyleEnabled () const =0
| Returns whether this widget is currently styled by the chosen theme.
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 >
Child * | addChild (std::unique_ptr< Child > child)
| Add a child WObject, returning a raw pointer.
std::unique_ptr< WObject > | removeChild (WObject *child)
| Remove a child WObject, so its lifetime is no longer determined by this WObject.
template<typename Child >
std::unique_ptr< Child > | removeChild (Child *child)
| Remove a child WObject, so its lifetime is no longer determined by this WObject.
virtual const std::string | id () const
| Returns the (unique) identifier for this object.
virtual 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.
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 WString | tr (const char *key)
| Short hand for WString::tr()
Static Public Member Functions inherited from Wt::WObject

## Protected Member Functions
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 void | enableAjax ()=0
| Progresses to an Ajax-enabled widget.
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.
virtual void | propagateSetEnabled (bool enabled)=0
| Propagates that a widget was enabled or disabled through children.
void | scheduleRender (WFlags< RepaintFlag > flags=None)
| Schedules rerendering of the widget.
virtual void | render (WFlags< RenderFlag > flags)
| Renders the widget.
virtual WStatelessSlot * | getStateless (Method method) override
| On-demand stateless slot implementation.
Protected Member Functions inherited from Wt::WObject

## Additional Inherited Members
Public Types inherited from Wt::WObject
typedef void(WObject::*) | Method()
| Typedef for a WObject method without arguments.

## Detailed Description

The abstract base class for a user-interface component.

The user-interface is organized in a tree structure, in which each node is a widget. All widgets, except for the application's root widget and dialogs, have a parent which is usually a WContainerWidget.

This is an abstract base class. Implementations derive either from the abstract WWebWidget (for basic widgets with a direct HTML counter-part) or from the abstract WCompositeWidget (for anything else). To add a WWidget to a parent container add the widget to the parent using WContainerWidget::addWidget(). Alternatively, you may add the widget to a layout manager set for a WContainerWidget.

A widget provides methods to manage its decorative style base on CSS. It also provides access to CSS-based layout, which you may not use when the widget is not inserted into a layout manager.

## Constructor & Destructor Documentation

## ◆ ~WWidget()

virtual Wt::WWidget::~WWidget | ( |  | ) |
| virtual

Destructor.

Deletes a widget and all contained contents.

See also
  WWidget::removeWidget()

## Member Function Documentation

## ◆ acceptDrops()

virtual void Wt::WWidget::acceptDrops | ( | const std::string & | mimeType,
|  | const WString & | hoverStyleClass = WString() )
| virtual

Sets a mime type to be accepted for dropping.

You may specify a style class that is applied to the widget when the specified mimetype hovers on top of it.

See also
  dropEvent(), WInteractWidget::setDraggable(), stopAcceptDrops()

## ◆ addStyleClass()

virtual void Wt::WWidget::addStyleClass | ( | const WString & | styleClass,
|  | bool | force = false )
| pure virtual

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.

Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.

## ◆ animateHide()

void Wt::WWidget::animateHide | ( | const WAnimation & | animation | ) |

Hides the widget using an animation.

To hide the widget, the animation is replayed in reverse.

See also
  setHidden()

## ◆ animateShow()

void Wt::WWidget::animateShow | ( | const WAnimation & | animation | ) |

Shows the widget using an animation.

See also
  setHidden()

## ◆ attributeValue()

virtual WString Wt::WWidget::attributeValue | ( | const std::string & | name | ) | const
| pure virtual

Returns an attribute value.

See also
  setAttributeValue()

Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.

## ◆ boxBorder()

virtual int Wt::WWidget::boxBorder | ( | Orientation | orientation | ) | const
| protectedvirtual

Returns the widget's built-in border width.

This is used by the layout managers to correct for a built-in border which interferes with setting a widget's width (or height) to 100%.

A layout manager needs to set the width to 100% only for form widgets (WTextArea, WLineEdit, WComboBox, etc...). Therefore, only for those widgets this needs to return the border width (the default implementation returns 0).

For form widgets, the border width depends on the specific browser/platform combination, unless an explicit border is set for the widget.

When setting an explicit border for the widget using a style class, you will want to reimplement this method to return this border width, in case you want to set the widget inside a layout manager.

See also
  boxPadding()

Reimplemented in Wt::WCompositeWidget, Wt::WLineEdit, Wt::WTextArea, and Wt::WTextEdit.

## ◆ boxPadding()

virtual int Wt::WWidget::boxPadding | ( | Orientation | orientation | ) | const
| protectedvirtual

Returns the widget's built-in padding.

This is used by the layout managers to correct for a built-in padding which interferes with setting a widget's width (or height) to 100%.

A layout manager needs to set the width to 100% only for form widgets (WTextArea, WLineEdit, WComboBox, etc...). Therefore, only for those widgets this needs to return the padding (the default implementation returns 0).

For form widgets, the padding depends on the specific browser/platform combination, unless an explicit padding is set for the widget.

When setting an explicit padding for the widget using a style class, you will want to reimplement this method to return this padding in case you want to set the widget inside a layout manager.

See also
  boxBorder()

Reimplemented in Wt::WAbstractSpinBox, Wt::WCompositeWidget, Wt::WLineEdit, Wt::WTextArea, and Wt::WTextEdit.

## ◆ callJavaScriptMember()

virtual void Wt::WWidget::callJavaScriptMember | ( | const std::string & | name,
|  | const std::string & | args )
| pure virtual

Calls a JavaScript member.

This calls a JavaScript member.

See also
  setJavaScriptMember()

Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.

## ◆ canReceiveFocus()

virtual bool Wt::WWidget::canReceiveFocus | ( |  | ) | const
| pure virtual

Returns whether the widget can receive focus.

See also
  setCanReceiveFocus()

Implemented in Wt::WAnchor, Wt::WCompositeWidget, Wt::WFormWidget, and Wt::WWebWidget.

## ◆ children()

virtual std::vector< WWidget * > Wt::WWidget::children | ( |  | ) | const
| pure virtual

Returns child widgets.

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

Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.

## ◆ clearSides()

virtual WFlags< Side > Wt::WWidget::clearSides | ( |  | ) | const
| pure virtual

Returns the sides that should remain empty.

See also
  setClearSides(WFlags<Side>)

Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.

## ◆ decorationStyle()

virtual WCssDecorationStyle & Wt::WWidget::decorationStyle | ( |  | ) |
| pure virtual

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

Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.

## ◆ disable()

void Wt::WWidget::disable | ( |  | ) |

Disable thes widget.

This calls setDisabled(true).

## ◆ doJavaScript()

virtual void Wt::WWidget::doJavaScript | ( | const std::string & | js | ) |
| pure virtual

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

Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.

## ◆ dropEvent()

virtual void Wt::WWidget::dropEvent | ( | WDropEvent | dropEvent | ) |
| protectedvirtual

Handles a drop event.

Reimplement this method to handle a drop events for mime types you declared to accept using acceptDrops.

The default implementation simply completes the drag and drop operation as if nothing happened.

See also
  acceptDrops(), WInteractWidget::setDraggable()

Reimplemented in Wt::WAbstractItemView.

## ◆ enable()

void Wt::WWidget::enable | ( |  | ) |

Enables the widget.

This calls setDisabled(false).

## ◆ enableAjax()

virtual void Wt::WWidget::enableAjax | ( |  | ) |
| protectedpure 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()

Implemented in Wt::WAbstractItemView, Wt::WAbstractMedia, Wt::WAnchor, Wt::WCalendar, Wt::WCompositeWidget, Wt::WFileDropWidget, Wt::WFileUpload, Wt::WFormWidget, Wt::WMenuItem, Wt::WPaintedWidget, Wt::WPanel, Wt::WPushButton, Wt::WSlider, Wt::WTableView, Wt::WTemplate, Wt::WTreeView, and Wt::WWebWidget.

## ◆ find()

virtual WWidget * Wt::WWidget::find | ( | const std::string & | name | ) |
| pure virtual

Finds a descendent widget by name.

See also
  setObjectName()

Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.

## ◆ floatSide()

virtual Side Wt::WWidget::floatSide | ( |  | ) | const
| pure virtual

Returns the CSS float side.

See also
  setFloatSide(Side)

Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.

## ◆ getStateless()

virtual WStatelessSlot * Wt::WWidget::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::WObject.

Reimplemented in Wt::WAbstractToggleButton, and Wt::WWebWidget.

## ◆ height()

virtual WLength Wt::WWidget::height | ( |  | ) | const
| pure virtual

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

Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.

## ◆ hiddenKeepsGeometry()

virtual bool Wt::WWidget::hiddenKeepsGeometry | ( |  | ) | const
| pure virtual

Returns whether the widget keeps its geometry when hidden.

See also
  setHiddenKeepsGeometry()

Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.

## ◆ hide()

void Wt::WWidget::hide | ( |  | ) |

Hides the widget.

See also
  setHidden()

## ◆ htmlText()

virtual void Wt::WWidget::htmlText | ( | std::ostream & | out | ) |
| virtual

Streams the (X)HTML representation.

Streams the widget as CharEncoding::UTF8-encoded (HTML-compatible) XHTML.

This may be useful as a debugging tool for the web-savvy, or in other rare situations. Usually, you will not deal directly with HTML, and calling this method on a widget that is rendered may interfere with the library keeping track of changes to the widget.

## ◆ isDisabled()

virtual bool Wt::WWidget::isDisabled | ( |  | ) | const
| pure virtual

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

Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.

## ◆ isEnabled()

virtual bool Wt::WWidget::isEnabled | ( |  | ) | const
| pure virtual

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

Implemented in Wt::WCompositeWidget, Wt::WInteractWidget, and Wt::WWebWidget.

## ◆ isHidden()

virtual bool Wt::WWidget::isHidden | ( |  | ) | const
| pure virtual

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

Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.

## ◆ isInline()

virtual bool Wt::WWidget::isInline | ( |  | ) | const
| pure virtual

Returns whether the widget is displayed inline or as block.

See also
  setInline(bool)

Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.

## ◆ isPopup()

virtual bool Wt::WWidget::isPopup | ( |  | ) | const
| pure virtual

Returns whether the widget is overlayed.

This applies to CSS-based layout.

See also
  setPopup(bool)

Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.

## ◆ isRendered()

bool Wt::WWidget::isRendered | ( |  | ) | const

Returns whether the widget is rendered.

See also
  jsRef()

## ◆ isScrollVisible()

virtual bool Wt::WWidget::isScrollVisible | ( |  | ) | const
| pure virtual

Returns whether this widget is currently considered scroll visible.

isScrollVisible() is initially false.

See also
  setScrollVisibilityEnabled()

Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.

## ◆ isThemeStyleEnabled()

virtual bool Wt::WWidget::isThemeStyleEnabled | ( |  | ) | const
| pure virtual

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

isThemeEnabled() is initially true.

See also
  setThemeStyleEnabled()

Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.

## ◆ isVisible()

virtual bool Wt::WWidget::isVisible | ( |  | ) | const
| pure virtual

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

Implemented in Wt::WCompositeWidget, Wt::WTableCell, and Wt::WWebWidget.

## ◆ javaScriptMember()

virtual std::string Wt::WWidget::javaScriptMember | ( | const std::string & | name | ) | const
| pure virtual

Returns the value of a JavaScript member.

See also
  setJavaScriptMember()

Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.

## ◆ jsRef()

std::string Wt::WWidget::jsRef | ( |  | ) | const

Returns a JavaScript expression to the corresponding DOM node.

You may want to use this in conjunction with JSlot or doJavaScript() in custom JavaScript code.

See also
  isRendered()

## ◆ layoutSizeAware()

bool Wt::WWidget::layoutSizeAware | ( |  | ) | const

Returns whether the widget is layout size aware.

See also
  setLayoutSizeAware()

## ◆ layoutSizeChanged()

virtual void Wt::WWidget::layoutSizeChanged | ( | int | width,
|  | int | height )
| protectedvirtual

Virtual method that indicates a size change.

This method propagates the client-side width and height of the widget when the widget is contained by a layout manager and setLayoutSizeAware(true) was called.

See also
  setLayoutSizeAware()

Reimplemented in Wt::WGLWidget, Wt::WPaintedWidget, and Wt::WSlider.

## ◆ lineHeight()

virtual WLength Wt::WWidget::lineHeight | ( |  | ) | const
| pure virtual

Returns the CSS line height for contained text.

sa setLineHeight()

Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.

## ◆ load()

virtual void Wt::WWidget::load | ( |  | ) |
| pure virtual

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.

Implemented in Wt::WCalendar, Wt::WCompositeWidget, Wt::WDateEdit, Wt::WInteractWidget, Wt::WMenu, Wt::WTimeEdit, Wt::WViewWidget, and Wt::WWebWidget.

## ◆ loaded()

virtual bool Wt::WWidget::loaded | ( |  | ) | const
| pure virtual

Returns whether this widget has been loaded.

See also
  load()

Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.

## ◆ margin()

virtual WLength Wt::WWidget::margin | ( | Side | side | ) | const
| pure virtual

Returns a CSS margin set.

This applies to CSS-based layout.

See also
  setMargin()

Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.

## ◆ maximumHeight()

virtual WLength Wt::WWidget::maximumHeight | ( |  | ) | const
| pure virtual

Returns the maximum height.

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

See also
  setMaximumSize(), maximumWidth()

Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.

## ◆ maximumWidth()

virtual WLength Wt::WWidget::maximumWidth | ( |  | ) | const
| pure virtual

Returns the maximum width.

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

See also
  setMaximumSize(), maximumHeight()

Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.

## ◆ minimumHeight()

virtual WLength Wt::WWidget::minimumHeight | ( |  | ) | const
| pure virtual

Returns the minimum height.

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

See also
  setMinimumSize(), minimumWidth()

Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.

## ◆ minimumWidth()

virtual WLength Wt::WWidget::minimumWidth | ( |  | ) | const
| pure virtual

Returns the minimum width.

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

See also
  setMinimumSize(), minimumHeight()

Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.

## ◆ offset()

virtual WLength Wt::WWidget::offset | ( | Side | side | ) | const
| pure virtual

Returns a CSS offset.

This applies to CSS-based layout.

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

Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.

## ◆ positionAt()

virtual void Wt::WWidget::positionAt | ( | const WWidget * | widget,
|  | Orientation | orientation = Orientation::Vertical )
| virtual

Positions a widget next to another widget.

Positions this absolutely positioned widget next to another `widget`. Both widgets must be visible (including all their ancestors). The current widget is shown automatically if needed.

When `orientation` = Wt::Orientation::Vertical, the widget is displayed below the other widget (or above in case there is not enough room below). It is aligned so that the left edges align (or the right edges if there is not enough room to the right).

Conversely, when `orientation` = Wt::Orientation::Horizontal, the widget is displayed to the right of the other widget (or to the left in case there is not enough room to the right). It is aligned so that the top edges align (or the bottom edges if there is not enough room below).

Note
  This only works if JavaScript is available.

Reimplemented in Wt::WDialog.

## ◆ positionScheme()

virtual PositionScheme Wt::WWidget::positionScheme | ( |  | ) | const
| pure virtual

Returns the CSS position scheme.

This applies to CSS-based layout.

See also
  Wt::PositionScheme, setPositionScheme(PositionScheme)

Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.

## ◆ propagateSetEnabled()

virtual void Wt::WWidget::propagateSetEnabled | ( | bool | enabled | ) |
| protectedpure 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.

Implemented in Wt::WAnchor, Wt::WCompositeWidget, Wt::WDateEdit, Wt::WFileUpload, Wt::WFormWidget, Wt::WInteractWidget, Wt::WLabel, Wt::WPushButton, Wt::WTextEdit, Wt::WTimeEdit, and Wt::WWebWidget.

## ◆ refresh()

virtual void Wt::WWidget::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 in Wt::WAbstractSpinBox, Wt::WAbstractToggleButton, Wt::WComboBox, Wt::WCompositeWidget, Wt::WDateEdit, Wt::WDoubleSpinBox, Wt::WFormWidget, Wt::WGroupBox, Wt::WMediaPlayer, Wt::WPushButton, Wt::WTemplate, Wt::WText, Wt::WViewWidget, and Wt::WWebWidget.

## ◆ removeFromParent()

std::unique_ptr< WWidget > Wt::WWidget::removeFromParent | ( |  | ) |

Removes the widget from its parent.

This is equivalent to parent()->removeWidget(this);

## ◆ removeStyleClass()

virtual void Wt::WWidget::removeStyleClass | ( | const WString & | styleClass,
|  | bool | force = false )
| pure virtual

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

Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.

## ◆ removeWidget()

template<typename Widget >

std::unique_ptr< Widget > Wt::WWidget::removeWidget | ( | Widget * | widget | ) |

Removes a child widget.

This is an overload that automatically casts the returned value to a unique_ptr<Widget> for convenience

This is implemented as:

return std::unique_ptr<Widget>(static_cast<Widget*>(removeWidget(static_cast<WWidget*>(widget)).release()));
Wt::WWidget
The abstract base class for a user-interface component.
Definition WWidget.h:66
Wt::WWidget::removeWidget
virtual std::unique_ptr< WWidget > removeWidget(WWidget *widget)
Removes a child widget.

## ◆ render()

virtual void Wt::WWidget::render | ( | WFlags< RenderFlag > | flags | ) |
| protectedvirtual

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 in Wt::Auth::AuthWidget, Wt::Auth::RegistrationWidget, Wt::Chart::WAxisSliderWidget, Wt::Chart::WCartesianChart, Wt::WAbstractSpinBox, Wt::WCalendar, Wt::WCompositeWidget, Wt::WDateEdit, Wt::WDatePicker, Wt::WDialog, Wt::WDoubleSpinBox, Wt::WEmailEdit, Wt::WFormWidget, Wt::WGLWidget, Wt::WGoogleMap, Wt::WImage, Wt::WInPlaceEdit, Wt::WLeafletMap, Wt::WLineEdit, Wt::WMediaPlayer, Wt::WMenu, Wt::WMenuItem, Wt::WPaintedWidget, Wt::WPopupMenu, Wt::WPopupWidget, Wt::WSlider, Wt::WStackedWidget, Wt::WSuggestionPopup, Wt::WTableView, Wt::WText, Wt::WTimeEdit, Wt::WTreeTable, Wt::WTreeView, Wt::WViewWidget, Wt::WVirtualImage, and Wt::WWebWidget.

## ◆ resize()

virtual void Wt::WWidget::resize | ( | const WLength & | width,
|  | const WLength & | height )
| virtual

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 in Wt::Chart::WCartesian3DChart, Wt::WCompositeWidget, Wt::WFlashObject, Wt::WGLWidget, Wt::WPaintedWidget, Wt::WProgressBar, Wt::WSlider, Wt::WTableView, Wt::WTextEdit, Wt::WTreeView, Wt::WVideo, and Wt::WWebWidget.

## ◆ scheduleRender()

void Wt::WWidget::scheduleRender | ( | WFlags< RepaintFlag > | flags = None | ) |
| protected

Schedules rerendering of the widget.

This schedules a rendering phase after all events have been processed. This method is used internally whenever a property of a widget has been changed. But you may want to use this if you are deferring actual changes to a widget in response to an event, and instead postpone this until all events have been received.

See also
  render()

## ◆ scrollVisibilityChanged()

virtual Signal< bool > & Wt::WWidget::scrollVisibilityChanged | ( |  | ) |
| pure virtual

Signal triggered when the scroll visibility of this widget changes.

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

See also
  setScrollVisibilityEnabled()

Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.

## ◆ scrollVisibilityEnabled()

virtual bool Wt::WWidget::scrollVisibilityEnabled | ( |  | ) | const
| pure virtual

Returns whether scroll visibility detection is enabled for this widget.

See also
  setScrollVisibilityEnabled()

Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.

## ◆ scrollVisibilityMargin()

virtual int Wt::WWidget::scrollVisibilityMargin | ( |  | ) | const
| pure virtual

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

See also
  setScrollVisibilityMargin()

Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.

## ◆ setAttributeValue()

virtual void Wt::WWidget::setAttributeValue | ( | const std::string & | name,
|  | const WString & | value )
| pure virtual

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

Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.

## ◆ setCanReceiveFocus()

virtual void Wt::WWidget::setCanReceiveFocus | ( | bool | enabled | ) |
| pure virtual

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.

Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.

## ◆ setClearSides()

virtual void Wt::WWidget::setClearSides | ( | WFlags< Side > | sides | ) |
| pure virtual

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

Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.

## ◆ setDecorationStyle()

virtual void Wt::WWidget::setDecorationStyle | ( | const WCssDecorationStyle & | style | ) |
| pure virtual

Sets a CSS decoration style.

This copies the style over its current decorationStyle()

Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.

## ◆ setDeferredToolTip()

virtual void Wt::WWidget::setDeferredToolTip | ( | bool | enable,
|  | TextFormat | textFormat = TextFormat::Plain )
| pure virtual

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

Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.

## ◆ setDisabled()

virtual void Wt::WWidget::setDisabled | ( | bool | disabled | ) |
| pure virtual

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

Implemented in Wt::WCompositeWidget, Wt::WDatePicker, Wt::WMenuItem, Wt::WSlider, Wt::WTreeTable, and Wt::WWebWidget.

## ◆ setFirstFocus()

virtual bool Wt::WWidget::setFirstFocus | ( |  | ) |
| pure virtual

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.

Implemented in Wt::WAnchor, Wt::WCompositeWidget, Wt::WPushButton, and Wt::WWebWidget.

## ◆ setFloatSide()

virtual void Wt::WWidget::setFloatSide | ( | Side | s | ) |
| pure virtual

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.

Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.

## ◆ setFocus() [1/2]

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/2]

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

Sets focus.

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

Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.

## ◆ setHeight()

void Wt::WWidget::setHeight | ( | const WLength & | height | ) |

Sets the height.

This is a convenience method to change only the height of a widget, and is implemented as:

resize(width(), height)
Wt::WWidget::width
virtual WLength width() const =0
Returns the width.
Wt::WWidget::resize
virtual void resize(const WLength &width, const WLength &height)
Resizes the widget.
Wt::WWidget::height
virtual WLength height() const =0
Returns the height.

This applies to CSS-based layout.

See also
  resize(), setWidth()

## ◆ setHidden()

virtual void Wt::WWidget::setHidden | ( | bool | hidden,
|  | const WAnimation & | animation = WAnimation() )
| pure virtual

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

Implemented in Wt::WCompositeWidget, Wt::WDateEdit, Wt::WDatePicker, Wt::WDialog, Wt::WFormWidget, Wt::WMenuItem, Wt::WMessageBox, Wt::WPopupMenu, Wt::WPopupWidget, Wt::WTableView, Wt::WTimeEdit, and Wt::WWebWidget.

## ◆ setHiddenKeepsGeometry()

virtual void Wt::WWidget::setHiddenKeepsGeometry | ( | bool | enabled | ) |
| pure virtual

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

Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.

## ◆ setId()

virtual void Wt::WWidget::setId | ( | const std::string & | id | ) |
| pure virtual

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

Implemented in Wt::WCompositeWidget, Wt::WTreeView, and Wt::WWebWidget.

## ◆ setInline()

virtual void Wt::WWidget::setInline | ( | bool | inlined | ) |
| pure virtual

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.

Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.

## ◆ setJavaScriptMember()

virtual void Wt::WWidget::setJavaScriptMember | ( | const std::string & | name,
|  | const std::string & | value )
| pure virtual

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.

Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.

## ◆ setLayoutSizeAware()

void Wt::WWidget::setLayoutSizeAware | ( | bool | sizeAware | ) |
| protected

Sets the widget to be aware of its size set by a layout manager.

When the widget is inserted in a layout manager, it will be resized to fit within the constraints imposed by the layout manager. By default, this done client-side only by setting the CSS height (and if needed, width) properties of the DOM element corresponding to the widget.

A widget may define a JavaScript method, `"wtResize(self, width, height)"`, to actively manage its client-side width and height, if it wants to react to these client-side size hints in a custom way (see setJavaScriptMember()).

By setting `sizeAware` to true, the widget will propagate the width and height provided by the layout manager to the virtual layoutSizeChanged() method, so that you may for example change the size of contained children in a particular way (doing a custom, manual, layout).

See also
  layoutSizeChanged()

## ◆ setMargin()

virtual void Wt::WWidget::setMargin | ( | const WLength & | margin,
|  | WFlags< Side > | sides = AllSides )
| pure virtual

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

Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.

## ◆ setMaximumSize()

virtual void Wt::WWidget::setMaximumSize | ( | const WLength & | width,
|  | const WLength & | height )
| pure virtual

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

Implemented in Wt::WCompositeWidget, Wt::WDialog, Wt::WPopupMenu, and Wt::WWebWidget.

## ◆ setMinimumSize()

virtual void Wt::WWidget::setMinimumSize | ( | const WLength & | width,
|  | const WLength & | height )
| pure virtual

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

Implemented in Wt::WCompositeWidget, Wt::WDialog, Wt::WPopupMenu, and Wt::WWebWidget.

## ◆ setOffsets()

virtual void Wt::WWidget::setOffsets | ( | const WLength & | offset,
|  | WFlags< Side > | sides = AllSides )
| pure virtual

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

Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.

## ◆ setPopup()

virtual void Wt::WWidget::setPopup | ( | bool | popup | ) |
| pure virtual

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.

Implemented in Wt::WCompositeWidget, Wt::WInteractWidget, and Wt::WWebWidget.

## ◆ setPositionScheme()

virtual void Wt::WWidget::setPositionScheme | ( | PositionScheme | scheme | ) |
| pure virtual

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

Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.

## ◆ setScrollVisibilityEnabled()

virtual void Wt::WWidget::setScrollVisibilityEnabled | ( | bool | enabled | ) |
| pure virtual

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.

Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.

## ◆ setScrollVisibilityMargin()

virtual void Wt::WWidget::setScrollVisibilityMargin | ( | int | margin | ) |
| pure virtual

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.

Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.

## ◆ setSelectable()

virtual void Wt::WWidget::setSelectable | ( | bool | selectable | ) |
| pure virtual

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.

Implemented in Wt::WCompositeWidget, Wt::WMenuItem, Wt::WTreeNode, and Wt::WWebWidget.

## ◆ setStyleClass()

virtual void Wt::WWidget::setStyleClass | ( | const WString & | styleClass | ) |
| pure virtual

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

Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.

## ◆ setTabIndex()

virtual void Wt::WWidget::setTabIndex | ( | int | index | ) |
| pure virtual

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

Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.

## ◆ setThemeStyleEnabled()

virtual void Wt::WWidget::setThemeStyleEnabled | ( | bool | enabled | ) |
| pure virtual

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.

Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.

## ◆ setToolTip()

virtual void Wt::WWidget::setToolTip | ( | const WString & | text,
|  | TextFormat | textFormat = TextFormat::Plain )
| pure virtual

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

Implemented in Wt::WCompositeWidget, Wt::WFormWidget, and Wt::WWebWidget.

## ◆ setVerticalAlignment()

virtual void Wt::WWidget::setVerticalAlignment | ( | AlignmentFlag | alignment,
|  | const WLength & | length = WLength::Auto )
| pure virtual

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.

Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.

## ◆ setWidth()

void Wt::WWidget::setWidth | ( | const WLength & | width | ) |

Sets the width.

This is a convenience method to change only the width of a widget, and is implemented as:

resize(width, height())

See also
  resize(), setHeight()

## ◆ show()

void Wt::WWidget::show | ( |  | ) |

Shows the widget.

See also
  setHidden()

## ◆ stopAcceptDrops()

virtual void Wt::WWidget::stopAcceptDrops | ( | const std::string & | mimeType | ) |
| virtual

Indicates that a mime type is no longer accepted for dropping.

See also
  acceptDrops()

## ◆ styleClass()

virtual WString Wt::WWidget::styleClass | ( |  | ) | const
| pure virtual

Returns the CSS style class.

See also
  setStyleClass()

Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.

## ◆ tabIndex()

virtual int Wt::WWidget::tabIndex | ( |  | ) | const
| pure virtual

Returns the tab index.

See also
  setTabIndex()

Implemented in Wt::WAnchor, Wt::WCompositeWidget, Wt::WFormWidget, and Wt::WWebWidget.

## ◆ tr()

static WString Wt::WWidget::tr | ( | const char * | key | ) |
| static

Short hand for WString::tr()

Creates a localized string with the given key.

## ◆ verticalAlignment()

virtual AlignmentFlag Wt::WWidget::verticalAlignment | ( |  | ) | const
| pure virtual

Returns the vertical alignment.

This applies to CSS-based layout.

See also
  setVerticalAlignment()

Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.

## ◆ verticalAlignmentLength()

virtual WLength Wt::WWidget::verticalAlignmentLength | ( |  | ) | const
| pure virtual

Returns the fixed vertical alignment that was set.

This applies to CSS-based layout.

See also
  setVerticalAlignment()

Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.

## ◆ width()

virtual WLength Wt::WWidget::width | ( |  | ) | const
| pure virtual

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

Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.