Wt::WWidget Class Reference

A WWidget is the abstract base class for any Wt widget. More...

#include <WWidget>

Inheritance diagram for Wt::WWidget:

Inheritance graph
[legend]

List of all members.

Public Types

enum  PositionScheme { Static, Relative, Absolute, Fixed }
 Layout mechanism for this widget. More...
enum  Side {
  None = 0x0, Top = 0x1, Bottom = 0x2, Left = 0x4,
  Right = 0x8, CenterX = 0x10, CenterY = 0x20, CenterXY = (0x10 | 0x20),
  Verticals = (0x4 | 0x8), Horizontals = (0x1 | 0x8), All = (Top | Bottom | Left | Right)
}
 Enumeration that designates a relative location. More...
enum  VerticalAlignment {
  AlignBaseline = 0x0, AlignSub = 0x10, AlignSuper = 0x20, AlignTop = 0x30,
  AlignTextTop = 0x40, AlignMiddle = 0x50, AlignBottom = 0x60, AlignTextBottom = 0x70,
  AlignLength = 0x80
}
 Vertical alignment of this widget. More...
enum  HorizontalAlignment { AlignLeft = 0x1, AlignRight = 0x2, AlignCenter = 0x3, AlignJustify = 0x4 }
 The horizontal alignment of child widgets. More...

Public Slots

void hide ()
 Hide this WWidget.
void show ()
 Show this WWidget.

Public Member Functions

 WWidget (WContainerWidget *parent=0)
 Construct a widget with a given parent.
virtual ~WWidget ()
 Delete a widget.
WWidgetparent () const
 Return the parent widget.
virtual void setPositionScheme (PositionScheme scheme)=0
 Set the widget position scheme.
virtual PositionScheme positionScheme () const =0
 Get the widget position scheme.
virtual void setOffsets (WLength offset, int sides=All)=0
 Apply offsets to a widget.
virtual WLength offset (Side side) const =0
 Retrieve the offset of the widget.
virtual void resize (WLength width, WLength height)=0
 Resize the widget.
virtual WLength width () const =0
 Get the widget width.
virtual WLength height () const =0
 Get the widget height.
virtual void setMinimumSize (WLength width, WLength height)=0
 Set a minimum size.
virtual WLength minimumWidth () const =0
 Get the minimum width.
virtual WLength minimumHeight () const =0
 Get the minimum height.
virtual void setMaximumSize (WLength width, WLength height)=0
 Set a maximum size.
virtual WLength maximumWidth () const =0
 Get the maximum width.
virtual WLength maximumHeight () const =0
 Get the maximum height.
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 remain empty.
virtual int clearSides () const =0
 Get the sides that should remain empty.
virtual void setMargin (WLength margin, int sides=All)=0
 Set margins around the widget.
virtual WLength margin (Side side) const =0
 Get 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 WWidget 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
 Access the decoration style of this widget.
virtual void setStyleClass (const WString &styleClass)=0
 Specify that a particular style class must be applied to this WWidget.
virtual WString styleClass () const =0
 Returns the style class for this WWidget.
virtual void setVerticalAlignment (VerticalAlignment alignment, WLength length=WLength())=0
 Set the vertical alignment of this (inline) WWidget.
virtual VerticalAlignment verticalAlignment () const =0
 Get the vertical alignment of this WWidget.
virtual WLength verticalAlignmentLength () const =0
 Get the a fixed vertical alignment with respect to the baseline of this WWidget.
virtual void setToolTip (const WString &text)=0
 Set the tooltip for the widget.
virtual WString toolTip () const =0
 Get 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.

Static Public Member Functions

static WString tr (const char *key)
 Short hand for WString::tr().

Protected Member Functions

virtual void dropEvent (WDropEvent dropEvent)
 Handle a drop event.
virtual const std::string resourceMimeType () const
 Return the mimetype.


Detailed Description

A WWidget is the abstract base class for any Wt widget.

The user-interface is organized in a tree structure, in which all nodes are WWidgets. When the parent widget is deleted, all children are deleted likewise. All WWidgets, 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 WWidget provides methods to manage its decorative style, and its layout with respect to the parent widget.


Member Enumeration Documentation

enum Wt::WWidget::PositionScheme

Layout mechanism for this widget.

The layout mechanism for the WWidget.

See also:
setPositionScheme(PositionScheme scheme)
Enumerator:
Static  Static position scheme.

The widget is layed-out with other Static and Relative sibling widgets, one after another.

Inline widgets are layed out in horizontal lines (like text), wrapping around at the end of the line to continue on the next line. Stacked widgets are stacked vertically.

Static widgets may also float to the left or right border, using setFloatSide().

Relative  Relative position scheme.

The widget is first layed out according to Static layout rules, but after layout, the widget may be offset relative to where it would be in a static layout, using setOffsets().

Another common use of a Relative position scheme (even with no specified offsets) is to provide a new reference coordinate system for Absolutely positioned widgets.

Absolute  Absolute position scheme.

The widget is positioned at an absolute position with respect to the nearest ancestor widget that is either:

Fixed  Fixed position scheme.

The widget is positioned at fixed position with respect to the browser's view-pane.

enum Wt::WWidget::Side

Enumeration that designates a relative location.

Values of CenterX, CenterY, and CenterXY are only valid for WCssDecorationStyle::setBackgroundImage()

See also:
setOffsets(WLength x, int sides), setFloatSide(Side s), setClearSides(int sides)

WCssDecorationStyle::setBackgroundImage()

Enumerator:
None  No side.
Top  Top side.
Bottom  Bottom side.
Left  Left side.
Right  Right side.
CenterX  Center horiziontally.
CenterY  Center vertically.
CenterXY  (CenterX | CenterY)
Verticals  (Left | Right)
Horizontals  (Top | Bottom)
All  All sides.

enum Wt::WWidget::VerticalAlignment

Vertical alignment of this widget.

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

See also:
setVerticalAlignment(VerticalAlignment, WLength)

WTableCell::setContentAlignment()

Enumerator:
AlignBaseline  Align at baseline.
AlignSub  Align below the baseline.
AlignSuper  Align above the baseline.
AlignTop  Align top of widget.
AlignTextTop  Align text top ?
AlignMiddle  Align middle of widget.
AlignBottom  Align bottom of widget.
AlignTextBottom  Align text bottom ?
AlignLength  Specific length offset ?

enum Wt::WWidget::HorizontalAlignment

The horizontal alignment of child widgets.

See also:
WContainerWidget::setContentAlignment()
Enumerator:
AlignLeft  Align children to the left.
AlignRight  Align children to the right.
AlignCenter  Align children to the center.
AlignJustify  Justify children left and right.


Constructor & Destructor Documentation

Wt::WWidget::WWidget ( WContainerWidget parent = 0  ) 

Construct a widget with a given parent.

Constructs a WWidget. If a parent WObject is specified it will add this object to the parent's list and gets deleted when the parent is deleted. If this widget is a WWebWidget and the parent is a WContainerWidget, it will visually add this widget to its children.

Wt::WWidget::~WWidget (  )  [virtual]

Delete a widget.

Deletes a WWidget, and all child widgets. If necessary, the WWidget is removed from its parent.


Member Function Documentation

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.

See also:
PositionScheme, positionScheme()

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

virtual PositionScheme Wt::WWidget::positionScheme (  )  const [pure virtual]

Get the widget position scheme.

See also:
PositionScheme, setPositionScheme(PositionScheme)

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

virtual void Wt::WWidget::setOffsets ( WLength  offset,
int  sides = All 
) [pure virtual]

Apply offsets to a widget.

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 absolutely 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.

Note: this method replaces the now deprecated setOffset(Side side, WLength offset) method.

See also:
offset(Side) const

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

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

Retrieve the offset of the widget.

See also:
setOffsets(WLength, int)

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

virtual void Wt::WWidget::resize ( WLength  width,
WLength  height 
) [pure virtual]

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

See also:
width(), height()

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

virtual WLength Wt::WWidget::width (  )  const [pure virtual]

Get 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(WLength width, WLength height).

See also:
resize(WLength width, WLength height), height()

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

virtual WLength Wt::WWidget::height (  )  const [pure virtual]

Get 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(WLength width, WLength height).

See also:
resize(WLength width, WLength height), width()

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

virtual void Wt::WWidget::setMinimumSize ( WLength  width,
WLength  height 
) [pure virtual]

Set a minimum size.

Specify a minimum size for this widget.

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

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

virtual WLength Wt::WWidget::minimumWidth (  )  const [pure virtual]

Get the minimum width.

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

See also:
setMinimumSize(), minimumHeight()

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

virtual WLength Wt::WWidget::minimumHeight (  )  const [pure virtual]

Get the minimum height.

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

See also:
setMinimumSize(), minimumWidth()

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

virtual void Wt::WWidget::setMaximumSize ( WLength  width,
WLength  height 
) [pure virtual]

Set a maximum size.

Specify a minimum size for this widget.

See also:
resize(), maximumWidth(), maximumHeight()

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

virtual WLength Wt::WWidget::maximumWidth (  )  const [pure virtual]

Get the maximum width.

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

See also:
setMaximumSize(), maximumHeight()

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

virtual WLength Wt::WWidget::maximumHeight (  )  const [pure virtual]

Get the maximum height.

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

See also:
setMaximumSize(), maximumWidth()

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 WWidgets with a Static positionScheme().

It specifies if the WWidget 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 .

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

virtual Side Wt::WWidget::floatSide (  )  const [pure virtual]

Return the float side.

See also:
setFloatSide(Side)

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

virtual void Wt::WWidget::setMargin ( 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 .

See also:
WWidget::margin(Side side);

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

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

Get the margin set for that side.

See also:
WWidget::setMargin(WLength margin, int sides);

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.

See also:
hide(), show()

Implemented in Wt::WCompositeWidget, Wt::WDialog, Wt::WFormWidget, Wt::WWebWidget, Wt::Ext::Dialog, Wt::Ext::MessageBox, and Wt::Ext::Widget.

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.

See also:
setHidden()

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

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 WWidget is overlayed.

See also:
setPopup(bool)

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 WWidget type, the default value is inline (such as for example for WText, or WPushButton), or stacked (such as for example for WTable).

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

virtual bool Wt::WWidget::isInline (  )  const [pure virtual]

Returns whether this widget is inline or stacked.

See also:
setInline(bool)

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

virtual WCssDecorationStyle& Wt::WWidget::decorationStyle (  )  [pure virtual]

Access 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 change the total size of the widget when adding a non-zero-width border).

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

virtual void Wt::WWidget::setStyleClass ( const WString styleClass  )  [pure virtual]

Specify that a particular style class must be applied to this WWidget.

To remove the style class, set an empty string as style class.

See also:
WApplication::styleSheet()

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

virtual WString Wt::WWidget::styleClass (  )  const [pure virtual]

Returns the style class for this WWidget.

See also:
setStyleClass(const WString&)

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

virtual void Wt::WWidget::setVerticalAlignment ( VerticalAlignment  alignment,
WLength  length = WLength() 
) [pure virtual]

Set the vertical alignment of this (inline) WWidget.

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

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

virtual VerticalAlignment Wt::WWidget::verticalAlignment (  )  const [pure virtual]

Get the vertical alignment of this WWidget.

See also:
WWidget::setVerticalAlignment()

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

virtual WLength Wt::WWidget::verticalAlignmentLength (  )  const [pure virtual]

Get the a fixed vertical alignment with respect to the baseline of this WWidget.

See also:
WWidget::setVerticalAlignment()

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

virtual void Wt::WWidget::setToolTip ( const WString text  )  [pure virtual]

Set the tooltip for the widget.

The tooltip is displayed when the cursor rests above 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::WComboBox, Wt::WCompositeWidget, Wt::WGroupBox, Wt::WPushButton, Wt::WText, Wt::WWebWidget, Wt::Ext::AbstractButton, Wt::Ext::ComboBox, Wt::Ext::FormField, Wt::Ext::MessageBox, Wt::Ext::Panel, Wt::Ext::TableView, and Wt::Ext::TabWidget.

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.

See also:
JSlot, WApplication::doJavaScript()

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::WViewWidget, and Wt::WWebWidget.

virtual bool Wt::WWidget::loaded (  )  const [pure virtual]

Return if this widget has been loaded.

See also:
load()

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.

See also:
dropEvent, setDraggable, stopAcceptDrops

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

No longer accept a mime type for dropping.

See also:
acceptDrops

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.

See also:
WObject::id()

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

void Wt::WWidget::hide (  )  [slot]

Hide this WWidget.

See also:
setHidden(bool)

void Wt::WWidget::show (  )  [slot]

Show this WWidget.

See also:
setHidden(bool)

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 setAcceptDrops.

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

See also:
setAcceptDrops, setDraggable

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.


The documentation for this class was generated from the following files:
Generated on Mon Apr 14 15:15:01 2008 for Wt by doxygen 1.5.3