#include <Wt/WWebWidget>
Public Member Functions | |
WWebWidget (WContainerWidget *parent=0) | |
Construct a WebWidget with a given parent. | |
virtual void | setPositionScheme (PositionScheme scheme) |
Set the widget position scheme. | |
virtual PositionScheme | positionScheme () const |
Returns the widget position scheme. | |
virtual void | setOffsets (const WLength &offset, WFlags< Side > sides=All) |
Apply offsets to a widget. | |
virtual WLength | offset (Side s) const |
Retrieve the offset of the widget. | |
virtual void | resize (const WLength &width, const WLength &height) |
Resize the widget. | |
virtual WLength | width () const |
Returns the widget width. | |
virtual WLength | height () const |
Returns the widget height. | |
virtual void | setMinimumSize (const WLength &width, const WLength &height) |
Set a minimum size. | |
virtual WLength | minimumWidth () const |
Returns the minimum width. | |
virtual WLength | minimumHeight () const |
Returns the minimum height. | |
virtual void | setMaximumSize (const WLength &width, const WLength &height) |
Set a maximum size. | |
virtual WLength | maximumWidth () const |
Returns the maximum width. | |
virtual WLength | maximumHeight () const |
Returns the maximum height. | |
virtual void | setLineHeight (const WLength &height) |
Set the line height for contained text. | |
virtual WLength | lineHeight () const |
Return the line height for contained text. | |
virtual void | setFloatSide (Side s) |
Specify a side to which the WWidget must float. | |
virtual Side | floatSide () const |
Return the float side. | |
virtual void | setClearSides (WFlags< Side > sides) |
Set the sides that should be cleared of floats. | |
virtual WFlags< Side > | clearSides () const |
Returns the sides that should remain empty. | |
virtual void | setMargin (const WLength &margin, WFlags< Side > sides=All) |
Set margins around the widget. | |
virtual WLength | margin (Side side) const |
Returns the margin set for that side. | |
virtual void | setHidden (bool) |
Set whether the widget must be hidden. | |
virtual bool | isHidden () const |
Return whether this widget is set hidden. | |
virtual void | setPopup (bool) |
Set whether this widget is overlayed on the parent widget. | |
virtual bool | isPopup () const |
Returns whether this widget is overlayed. | |
virtual void | setInline (bool) |
Set whether this widget is inline or stacked. | |
virtual bool | isInline () const |
Returns whether this widget is inline or stacked. | |
virtual WCssDecorationStyle & | decorationStyle () |
Returns the decoration style of this widget. | |
virtual void | setStyleClass (const WString &styleClass) |
Sets a style class. | |
virtual WString | styleClass () const |
Returns the style class. | |
virtual void | setVerticalAlignment (AlignmentFlag alignment, const WLength &length=WLength()) |
Set the vertical alignment of this (inline) widget. | |
virtual AlignmentFlag | verticalAlignment () const |
Returns the vertical alignment. | |
virtual WLength | verticalAlignmentLength () const |
Returns the fixed vertical alignment that was set. | |
virtual void | setToolTip (const WString &toolTip) |
Sets a tooltip. | |
virtual WString | toolTip () const |
Returns the tooltip text. | |
virtual void | refresh () |
Refresh the widget. | |
virtual void | setAttributeValue (const std::string &name, const WString &value) |
Set an attribute value. | |
virtual void | load () |
Load content just before the widget's content is rendered. | |
virtual bool | loaded () const |
Return if this widget has been loaded. | |
virtual void | setId (const std::string &id) |
Set the CSS Id. | |
void | setLoadLaterWhenInvisible (bool) |
Change the way the widget is loaded when invisible. | |
const std::vector< WWidget * > & | children () const |
Returns contained widgets. | |
Static Public Member Functions | |
static WString | escapeText (const WString &text, bool newlinesToo=false) |
Escape HTML control characters in the text, to display literally. | |
static std::string & | escapeText (std::string &text, bool newlinestoo=false) |
Escape HTML control characters in the text, to display literally. | |
static bool | removeScript (WString &text) |
Remove tags/attributes from text that are not passive. | |
static std::string | jsStringLiteral (const std::string &v, char delimiter= '\'') |
Turn a UTF8 encoded string into a JavaScript string literal. |
All descendants of WWebWidget implement a widget which corresponds almost one-on-one with an HTML element. These widgets provide most capabilities of these HTML elements, but rarely make no attempt to do anything more.
WWebWidget::WWebWidget | ( | WContainerWidget * | parent = 0 |
) |
void WWebWidget::setPositionScheme | ( | PositionScheme | scheme | ) | [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.
Implements Wt::WWidget.
PositionScheme WWebWidget::positionScheme | ( | ) | const [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.
Implements Wt::WWidget.
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.
Implements Wt::WWidget.
Reimplemented in Wt::Ext::TextEdit, Wt::WPaintedWidget, and Wt::WTextEdit.
WLength WWebWidget::width | ( | ) | const [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.
Implements Wt::WWidget.
WLength WWebWidget::height | ( | ) | const [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.
Implements Wt::WWidget.
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.
Implements Wt::WWidget.
WLength WWebWidget::minimumWidth | ( | ) | const [virtual] |
Returns the minimum width.
Return the minimum width set for this widget with setMinimumSize().
Implements Wt::WWidget.
WLength WWebWidget::minimumHeight | ( | ) | const [virtual] |
Returns the minimum height.
Return the minmum height set for this widget with setMinimumSize().
Implements Wt::WWidget.
Set a maximum size.
Specify a minimum size for this widget.
Implements Wt::WWidget.
WLength WWebWidget::maximumWidth | ( | ) | const [virtual] |
Returns the maximum width.
Return the maximum width set for this widget with setMaximumSize().
Implements Wt::WWidget.
WLength WWebWidget::maximumHeight | ( | ) | const [virtual] |
Returns the maximum height.
Return the minmum height set for this widget with setMaximumSize().
Implements Wt::WWidget.
WLength WWebWidget::lineHeight | ( | ) | const [virtual] |
void WWebWidget::setFloatSide | ( | Side | s | ) | [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.
Implements Wt::WWidget.
Side WWebWidget::floatSide | ( | ) | const [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.
Implements Wt::WWidget.
Returns the sides that should remain empty.
Implements Wt::WWidget.
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.
Implements Wt::WWidget.
Returns the margin set for that side.
This applies to CSS-based layout.
Implements Wt::WWidget.
void WWebWidget::setHidden | ( | bool | ) | [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.
Implements Wt::WWidget.
Reimplemented in Wt::Ext::Dialog, Wt::Ext::MessageBox, Wt::Ext::Widget, and Wt::WFormWidget.
bool WWebWidget::isHidden | ( | ) | const [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.
Implements Wt::WWidget.
void WWebWidget::setPopup | ( | bool | ) | [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.
Implements Wt::WWidget.
bool WWebWidget::isPopup | ( | ) | const [virtual] |
Returns whether this widget is overlayed.
This applies to CSS-based layout.
Implements Wt::WWidget.
void WWebWidget::setInline | ( | bool | ) | [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.
Implements Wt::WWidget.
bool WWebWidget::isInline | ( | ) | const [virtual] |
WCssDecorationStyle & WWebWidget::decorationStyle | ( | ) | [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).
Implements Wt::WWidget.
void WWebWidget::setStyleClass | ( | const WString & | styleClass | ) | [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.
Implements Wt::WWidget.
WString WWebWidget::styleClass | ( | ) | const [virtual] |
void WWebWidget::setVerticalAlignment | ( | AlignmentFlag | alignment, | |
const WLength & | length = WLength() | |||
) | [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.
Implements Wt::WWidget.
AlignmentFlag WWebWidget::verticalAlignment | ( | ) | const [virtual] |
Returns the vertical alignment.
This applies to CSS-based layout.
Implements Wt::WWidget.
WLength WWebWidget::verticalAlignmentLength | ( | ) | const [virtual] |
Returns the fixed vertical alignment that was set.
This applies to CSS-based layout.
Implements Wt::WWidget.
void WWebWidget::setToolTip | ( | const WString & | text | ) | [virtual] |
Sets a tooltip.
The tooltip is displayed when the cursor hovers over the widget.
Implements Wt::WWidget.
void WWebWidget::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.
Implements Wt::WWidget.
Reimplemented 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::WGroupBox, Wt::WPushButton, Wt::WText, and Wt::WViewWidget.
void WWebWidget::setAttributeValue | ( | const std::string & | name, | |
const WString & | value | |||
) | [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.
Implements Wt::WWidget.
void WWebWidget::load | ( | ) | [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.
Implements Wt::WWidget.
Reimplemented in Wt::WAbstractToggleButton, Wt::WTextEdit, and Wt::WViewWidget.
bool WWebWidget::loaded | ( | ) | const [virtual] |
void WWebWidget::setId | ( | const std::string & | id | ) | [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.
Implements Wt::WWidget.
void WWebWidget::setLoadLaterWhenInvisible | ( | bool | how | ) |
Change the way the widget is loaded when invisible.
By default, invisible widgets are loaded only after visible content. For tiny widgets this may lead to a performance loss, instead of the expected increase, because they require many more DOM manipulation to render, reducing the overall responsiveness of the application.
Therefore, this is disabled for some widgets like WImage, or empty WContainerWidgets.
Usually the default settings are fine, but you may want to change the behaviour.
bool WWebWidget::removeScript | ( | WString & | text | ) | [static] |
Remove tags/attributes from text that are not passive.
This removes tags and attributes from XHTML-formatted text that do not simply display something but may trigger scripting, and could have been injected by a malicious user for Cross-Site Scripting (XSS).
This method is used by the library to sanitize XHTML-formatted text set in WText, but it may also be useful outside the library to sanitize user content when direcly using JavaScript.
Modifies the text if needed. When the text is not proper XML, returns false.
std::string WWebWidget::jsStringLiteral | ( | const std::string & | v, | |
char | delimiter = '\'' | |||
) | [static] |
Turn a UTF8 encoded string into a JavaScript string literal.
The delimiter may be a single or double quote.
const std::vector< WWidget * > & WWebWidget::children | ( | ) | const |
Returns contained widgets.
Reimplemented from Wt::WObject.
Reimplemented in Wt::Ext::Splitter.