#include <Wt/WWidget>
Public Slots | |
void | hide () |
Hide this WWidget. | |
void | show () |
Show this WWidget. | |
Public Member Functions | |
virtual | ~WWidget () |
Delete a widget. | |
WWidget * | parent () const |
Return the parent widget. | |
virtual void | setPositionScheme (PositionScheme scheme)=0 |
Set the widget position scheme. | |
virtual PositionScheme | positionScheme () const =0 |
Returns the widget position scheme. | |
virtual void | setOffsets (const WLength &offset, int sides=All)=0 |
Apply offsets to a widget. | |
void | setOffset (int sides, const WLength &offset) |
Apply offsets to a widget (deprecated). | |
virtual WLength | offset (Side side) const =0 |
Retrieve the offset of the widget. | |
virtual void | resize (const WLength &width, const WLength &height)=0 |
Resize 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 &)=0 |
Set 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 |
Set 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 |
Set the line height for contained text. | |
virtual WLength | lineHeight () const =0 |
Return 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 |
Return the float side. | |
virtual void | setClearSides (int sides)=0 |
Set the sides that should be cleared of floats. | |
virtual int | clearSides () const =0 |
Returns the sides that should remain empty. | |
virtual void | setMargin (const WLength &margin, int sides=All)=0 |
Set margins around the widget. | |
virtual WLength | margin (Side side) const =0 |
Returns the margin set for that side. | |
virtual void | setHidden (bool)=0 |
Set whether the widget must be hidden. | |
virtual bool | isHidden () const =0 |
Return whether this widget is set hidden. | |
virtual void | setPopup (bool)=0 |
Set whether this widget is overlayed on the parent widget. | |
virtual bool | isPopup () const =0 |
Returns whether this widget is overlayed. | |
virtual void | setInline (bool)=0 |
Set whether this widget is inline or stacked. | |
virtual bool | isInline () const =0 |
Returns whether this widget is inline or stacked. | |
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 (VerticalAlignment alignment, const WLength &length=WLength())=0 |
Set the vertical alignment of this (inline) widget. | |
virtual VerticalAlignment | 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 |
Set an attribute value. | |
virtual void | load ()=0 |
Load content just before the widget's content is rendered. | |
virtual bool | loaded () const =0 |
Return if this widget has been loaded. | |
virtual void | acceptDrops (const std::string &mimeType, const WString &hoverStyleClass=WString()) |
Set a mime type to be accepted for dropping. | |
virtual void | stopAcceptDrops (const std::string &mimeType) |
No longer accept a mime type for dropping. | |
virtual void | setId (const std::string &id)=0 |
Set the CSS Id. | |
virtual void | htmlText (std::ostream &out) |
Stream the (X)HTML representation. | |
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 const std::string | resourceMimeType () const |
Return the mimetype. |
The user-interface is organized in a tree structure, in which all nodes are widgets. When the parent widget is deleted, all children are deleted likewise. 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, 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] |
Return 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] |
Set 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, | |
int | sides = All | |||
) | [pure virtual] |
Apply 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.
void Wt::WWidget::setOffset | ( | int | sides, | |
const WLength & | offset | |||
) |
Apply offsets to a widget (deprecated).
Retrieve the offset of the widget.
This applies to CSS-based layout.
Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.
Resize 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::WPaintedWidget, Wt::WSlider, Wt::WTextEdit, Wt::WTreeView, and Wt::WWebWidget.
virtual WLength Wt::WWidget::width | ( | ) | const [pure virtual] |
Returns the widget width.
Return 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.
Return 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.
Set 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.
Return 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.
Return 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] |
Set 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.
Return 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.
Return the minmum height set for this widget with setMaximumSize().
Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.
virtual WLength Wt::WWidget::lineHeight | ( | ) | const [pure virtual] |
Return 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 None , Left or Right .
This applies to CSS-based layout.
Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.
virtual Side Wt::WWidget::floatSide | ( | ) | const [pure virtual] |
Return the float side.
Implemented in Wt::WCompositeWidget, and Wt::WWebWidget.
virtual void Wt::WWidget::setClearSides | ( | int | sides | ) | [pure virtual] |
Set 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 int 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, | |
int | sides = All | |||
) | [pure virtual] |
Set 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 | ) | [pure virtual] |
Set 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, and Wt::WWebWidget.
virtual bool Wt::WWidget::isHidden | ( | ) | const [pure virtual] |
Return 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 | ) | [pure virtual] |
Set whether this widget is overlayed on the parent widget.
This option only applies to widgets with a Absolute or Fixed positionScheme().
This applies to CSS-based layout.
A widget that isPopup() will be rendered on top of the parent widget.
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 | ) | [pure virtual] |
Set whether this widget is inline or stacked.
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 stacked vertically with sibling widgets. Depending on the widget type, the default value is inline (such as for example for WText, or WPushButton), or stacked (such as for example for WTable).
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 inline or stacked.
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 | ( | VerticalAlignment | alignment, | |
const WLength & | length = WLength() | |||
) | [pure virtual] |
Set 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 VerticalAlignment 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::WGroupBox, Wt::WPushButton, Wt::WText, 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] |
Set 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.
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::WTreeView, Wt::WViewWidget, and Wt::WWebWidget.
virtual bool Wt::WWidget::loaded | ( | ) | const [pure virtual] |
Return 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] |
Set 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] |
Set 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] |
Stream 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.
Reimplemented in Wt::WFileUpload.
void Wt::WWidget::hide | ( | ) | [slot] |
void Wt::WWidget::show | ( | ) | [slot] |
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.
const std::string Wt::WWidget::resourceMimeType | ( | ) | const [protected, virtual] |
Return the mimetype.
Implement this method to return the correct mime type for your resource, e.g. "text/html".
Implements Wt::WResource.