#include <Wt/WWidget>
Public Member Functions | |
virtual | ~WWidget () |
Delete a widget. | |
WWidget * | parent () const |
Returns the parent widget. | |
virtual void | setPositionScheme (PositionScheme scheme)=0 |
Sets the widget position scheme. | |
virtual PositionScheme | positionScheme () const =0 |
Returns the widget position scheme. | |
virtual void | setOffsets (const WLength &offset, WFlags< Side > sides=All)=0 |
Applies offsets to a widget. | |
virtual WLength | offset (Side side) const =0 |
Retrieves the offset of the widget. | |
virtual void | resize (const WLength &width, const WLength &height)=0 |
Resizes the widget. | |
virtual WLength | width () const =0 |
Returns the widget width. | |
virtual WLength | height () const =0 |
Returns the widget 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 | setLineHeight (const WLength &height)=0 |
Sets the line height for contained text. | |
virtual WLength | lineHeight () const =0 |
Returns the line height for contained text. | |
virtual void | setFloatSide (Side s)=0 |
Specify a side to which the WWidget must float. | |
virtual Side | floatSide () const =0 |
Returns the 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=All)=0 |
Sets margins around the widget. | |
virtual WLength | margin (Side side) const =0 |
Returns the margin set for that side. | |
virtual void | setHidden (bool hidden)=0 |
Sets whether the widget must be hidden. | |
virtual bool | isHidden () const =0 |
Returns whether this widget is set hidden. | |
virtual void | setPopup (bool popup)=0 |
Let the widget overlay other sibling widgets. | |
virtual bool | isPopup () const =0 |
Returns whether this widget is overlayed. | |
virtual void | setInline (bool inlined)=0 |
Sets whether this widget is displayed inline or as a block. | |
virtual bool | isInline () const =0 |
Returns whether this widget is displayed inline or as block. | |
virtual WCssDecorationStyle & | decorationStyle ()=0 |
Returns the decoration style of this widget. | |
virtual void | setStyleClass (const WString &styleClass)=0 |
Sets a style class. | |
virtual WString | styleClass () const =0 |
Returns the style class. | |
virtual void | setVerticalAlignment (AlignmentFlag alignment, const WLength &length=WLength::Auto)=0 |
Sets the vertical alignment of this (inline) widget. | |
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)=0 |
Sets a tooltip. | |
virtual WString | toolTip () const =0 |
Returns the tooltip text. | |
virtual void | refresh ()=0 |
Refresh the widget. | |
std::string | jsRef () const |
A JavaScript expression that returns 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 | load ()=0 |
Load content just before the widget's content is rendered. | |
virtual bool | loaded () const =0 |
Returns if this widget has been loaded. | |
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 void | htmlText (std::ostream &out) |
Streams the (X)HTML representation. | |
virtual void | setSelectable (bool selectable)=0 |
Sets as selectable. | |
void | hide () |
Hide this WWidget. | |
void | show () |
Show this WWidget. | |
Static Public Member Functions | |
static WString | tr (const char *key) |
Short hand for WString::tr(). | |
Protected Member Functions | |
WWidget (WContainerWidget *parent=0) | |
Create a widget with a given parent. | |
virtual void | dropEvent (WDropEvent dropEvent) |
Handle a drop event. | |
virtual void | enableAjax ()=0 |
Progress 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. |
The user-interface is organized in a tree structure, in which all nodes are widgets. When a widget is deleted, it is also visually removed from the user-interface and all children are deleted recursively. All widgets, except for the application's root widget have a parent, which is usually a WContainerWidget.
WWidget is abstract and cannot be instantiated. Implementations either from WWebWidget (for basic widgets with a direct HTML counter-part) or WCompositeWidget (for anything else). To add a WWebWidget to a parent WContainerWidget, either specify the parent in the constructor (which is conventionally the last constructor argument), or add the widget to the parent using WContainerWidget::addWidget(WWidget *).
A widget provides methods to manage its decorative style. It also provides access to CSS-based layout. Alternatively, you may use layout managers (see WContainerWidget::setLayout()) to manage layout of widgets, in which case you should not use methods that are marked as being involved in CSS-based layout only.
Wt::WWidget::~WWidget | ( | ) | [virtual] |
Delete a widget.
Deletes a widget and all children (recursively). If the widget is contained in another widget, it is removed first.
Wt::WWidget::WWidget | ( | WContainerWidget * | parent = 0 |
) | [protected] |
Create a widget with a given parent.
If a parent container is specified, the widget is added to the container, using WContainerWidget::addWidget().
WWidget* Wt::WWidget::parent | ( | ) | const [inline] |
Returns the parent widget.
With few exceptions, the parent is a WContainerWidget, and has been set implicitly when adding the widget to a container using WContainerWidget::addWidget() or by passing a container as a parent to the constructor.
Reimplemented from Wt::WObject.
virtual void Wt::WWidget::setPositionScheme | ( | PositionScheme | scheme | ) | [pure virtual] |
Sets the widget position scheme.
Establishes how the widget must be layed-out relative to its siblings. The default position scheme is Static.
This applies to CSS-based layout.
Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.
virtual PositionScheme Wt::WWidget::positionScheme | ( | ) | const [pure virtual] |
Returns the widget position scheme.
This applies to CSS-based layout.
Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.
virtual void Wt::WWidget::setOffsets | ( | const WLength & | offset, | |
WFlags< Side > | sides = All | |||
) | [pure virtual] |
Applies offsets to a widget.
The argument sides may be a logical concatenation of Left, Right, Top, and Bottom.
This applies only to widgets that have a position scheme that is Relative, Absolute, or 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 to the Left or Right). The widget may be shifted vertically, by specifying an offset for the Top or Bottom.
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.
Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.
Retrieves the offset of the widget.
This applies to CSS-based layout.
Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.
Resizes the widget.
Specify a new size for this widget, by specifying width and height. By default a widget has automatic width and height, see WLength::isAuto().
This applies to CSS-based layout.
Implemented in Wt::Ext::TextEdit, Wt::WCompositeWidget, Wt::WDialog, Wt::WFlashObject, Wt::WPaintedWidget, Wt::WSlider, Wt::WTextEdit, Wt::WTreeView, and Wt::WWebWidget.
virtual WLength Wt::WWidget::width | ( | ) | const [pure virtual] |
Returns the widget 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.
Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.
virtual WLength Wt::WWidget::height | ( | ) | const [pure virtual] |
Returns the widget 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.
Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.
virtual void Wt::WWidget::setMinimumSize | ( | const WLength & | width, | |
const WLength & | height | |||
) | [pure virtual] |
Sets a minimum size.
Specify a minimum size for this widget. When the widget is managed using a layout manager, these sizes are also taken into account.
Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.
virtual WLength Wt::WWidget::minimumWidth | ( | ) | const [pure virtual] |
Returns the minimum width.
Returns the minimum width set for this widget with setMinimumSize().
Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.
virtual WLength Wt::WWidget::minimumHeight | ( | ) | const [pure virtual] |
Returns the minimum height.
Returns the minmum height set for this widget with setMinimumSize().
Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.
virtual void Wt::WWidget::setMaximumSize | ( | const WLength & | width, | |
const WLength & | height | |||
) | [pure virtual] |
Sets a maximum size.
Specify a minimum size for this widget.
Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.
virtual WLength Wt::WWidget::maximumWidth | ( | ) | const [pure virtual] |
Returns the maximum width.
Returns the maximum width set for this widget with setMaximumSize().
Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.
virtual WLength Wt::WWidget::maximumHeight | ( | ) | const [pure virtual] |
Returns the maximum height.
Returns the minmum height set for this widget with setMaximumSize().
Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.
virtual WLength Wt::WWidget::lineHeight | ( | ) | const [pure virtual] |
Returns the line height for contained text.
Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.
virtual void Wt::WWidget::setFloatSide | ( | Side | s | ) | [pure virtual] |
Specify a side to which the WWidget must float.
This only applies to widgets with a Static positionScheme().
It specifies if the widget must be positioned on 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 or
This applies to CSS-based layout.
Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.
virtual Side Wt::WWidget::floatSide | ( | ) | const [pure virtual] |
Returns the float side.
Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.
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 logical OR of Left and Right.
This applies to CSS-based layout.
Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.
virtual WFlags<Side> Wt::WWidget::clearSides | ( | ) | const [pure virtual] |
Returns the sides that should remain empty.
Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.
virtual void Wt::WWidget::setMargin | ( | const WLength & | margin, | |
WFlags< Side > | sides = All | |||
) | [pure virtual] |
Sets 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 Left , Right , Bottom , or Top .
This applies to CSS-based layout.
Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.
Returns the margin set for that side.
This applies to CSS-based layout.
Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.
virtual void Wt::WWidget::setHidden | ( | bool | hidden | ) | [pure virtual] |
Sets whether the widget must be hidden.
Hide or show the widget (including all its descendant widgets). setHidden(false) will show this widget and all child widgets that are not hidden.
Implemented in Wt::Ext::Dialog, Wt::Ext::MessageBox, Wt::Ext::Widget, Wt::WCompositeWidget, Wt::WDialog, Wt::WFormWidget, Wt::WPopupMenu, and Wt::WWebWidget.
virtual bool Wt::WWidget::isHidden | ( | ) | const [pure virtual] |
Returns whether this widget is set hidden.
A widget that is not hidden may still be not visible when one of its ancestor widgets are hidden.
Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.
virtual void Wt::WWidget::setPopup | ( | bool | popup | ) | [pure virtual] |
Let the widget overlay 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 Absolute or Fixed positionScheme().
This applies to CSS-based layout.
Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.
virtual bool Wt::WWidget::isPopup | ( | ) | const [pure virtual] |
Returns whether this widget is overlayed.
This applies to CSS-based layout.
Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.
virtual void Wt::WWidget::setInline | ( | bool | inlined | ) | [pure virtual] |
Sets whether this 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.
virtual bool Wt::WWidget::isInline | ( | ) | const [pure virtual] |
Returns whether this widget is displayed inline or as block.
Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.
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).
Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.
virtual void Wt::WWidget::setStyleClass | ( | const WString & | styleClass | ) | [pure virtual] |
Sets a style class.
The 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.
Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.
virtual WString Wt::WWidget::styleClass | ( | ) | const [pure virtual] |
Returns the style class.
Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.
virtual void Wt::WWidget::setVerticalAlignment | ( | AlignmentFlag | alignment, | |
const WLength & | length = WLength::Auto | |||
) | [pure virtual] |
Sets the vertical alignment of this (inline) widget.
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.
virtual AlignmentFlag Wt::WWidget::verticalAlignment | ( | ) | const [pure virtual] |
Returns the vertical alignment.
This applies to CSS-based layout.
Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.
virtual WLength Wt::WWidget::verticalAlignmentLength | ( | ) | const [pure virtual] |
Returns the fixed vertical alignment that was set.
This applies to CSS-based layout.
Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.
virtual void Wt::WWidget::setToolTip | ( | const WString & | text | ) | [pure virtual] |
Sets a tooltip.
The tooltip is displayed when the cursor hovers over the widget.
Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.
virtual void Wt::WWidget::refresh | ( | ) | [pure 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.
Implemented in Wt::Ext::AbstractButton, Wt::Ext::ComboBox, Wt::Ext::FormField, Wt::Ext::MessageBox, Wt::Ext::Panel, Wt::Ext::TableView, Wt::Ext::TabWidget, Wt::WComboBox, Wt::WCompositeWidget, Wt::WGoogleMap, Wt::WGroupBox, Wt::WPushButton, Wt::WText, Wt::WTreeView, Wt::WViewWidget, and Wt::WWebWidget.
std::string Wt::WWidget::jsRef | ( | ) | const |
A JavaScript expression that returns the corresponding DOM node.
You may want to use this in conjunction with JSlot or WApplication::doJavaScript() in custom JavaScript code.
virtual void Wt::WWidget::setAttributeValue | ( | const std::string & | name, | |
const WString & | value | |||
) | [pure virtual] |
Sets an attribute value.
Associate an extra attribute with this widget, with the given value. This is only useful when processing dom nodes associated with widgets in custom JavaScript code.
Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.
virtual WString Wt::WWidget::attributeValue | ( | const std::string & | name | ) | const [pure virtual] |
Returns an attribute value.
Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.
WString Wt::WWidget::tr | ( | const char * | key | ) | [static] |
Short hand for WString::tr().
Create a message with the given key.
virtual void Wt::WWidget::load | ( | ) | [pure virtual] |
Load content just before the widget's content is rendered.
As soon as a widget is inserted into the widget hierarchy, it is rendered. Visible widgets are rendered immediately, and invisible widgets in the back-ground. 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 load resource-intensive content only when the widget is loaded into the browser.
Implemented in Wt::WCompositeWidget, Wt::WPopupMenuItem, Wt::WTextEdit, Wt::WTreeView, Wt::WViewWidget, and Wt::WWebWidget.
virtual bool Wt::WWidget::loaded | ( | ) | const [pure virtual] |
Returns if this widget has been loaded.
Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.
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.
void Wt::WWidget::stopAcceptDrops | ( | const std::string & | mimeType | ) | [virtual] |
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.
Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.
void Wt::WWidget::htmlText | ( | std::ostream & | out | ) | [virtual] |
Streams the (X)HTML representation.
Streams the widget as 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.
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::WTreeNode, and Wt::WWebWidget.
void Wt::WWidget::hide | ( | ) |
void Wt::WWidget::show | ( | ) |
void Wt::WWidget::dropEvent | ( | WDropEvent | dropEvent | ) | [protected, virtual] |
Handle 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.
virtual void Wt::WWidget::enableAjax | ( | ) | [protected, pure virtual] |
Progress 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.
Implemented in Wt::WAnchor, Wt::WCompositeWidget, Wt::WFileUpload, Wt::WMenu, Wt::WPaintedWidget, Wt::WTreeView, and Wt::WWebWidget.
int Wt::WWidget::boxPadding | ( | Orientation | orientation | ) | const [protected, virtual] |
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.
Reimplemented in Wt::WCompositeWidget, Wt::WLineEdit, Wt::WTextArea, and Wt::WTextEdit.
int Wt::WWidget::boxBorder | ( | Orientation | orientation | ) | const [protected, virtual] |
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.
Reimplemented in Wt::WCompositeWidget, Wt::WLineEdit, Wt::WTextArea, and Wt::WTextEdit.