Wt::WWidget Class Reference

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

#include <WWidget>

Inherits Wt::WResource.

Inherited by Wt::WCompositeWidget, and Wt::WWebWidget.

Inheritance diagram for Wt::WWidget:

Inheritance graph
[legend]
List of all members.

Public Types

 Static
 Relative
 Absolute
 Fixed
 None = 0x0
 No side.
 Top = 0x1
 Top side.
 Bottom = 0x2
 Bottom side.
 Left = 0x4
 Left side.
 Right = 0x8
 Right side.
 Verticals = (0x4 | 0x8)
 (Left | Right)
 Horizontals = (0x1 | 0x8)
 (Top | Bottom)
 All = (Top | Bottom | Left | Right)
 All sides.
 AlignBaseline = 0x0
 Align at baseline.
 AlignSub = 0x10
 Align below the baseline.
 AlignSuper = 0x20
 Align above the baseline.
 AlignTop = 0x30
 Align top of widget.
 AlignTextTop = 0x40
 Align text top ?
 AlignMiddle = 0x50
 Align middle of widget.
 AlignBottom = 0x60
 Align bottom of widget.
 AlignTextBottom = 0x70
 Align text bottom ?
 AlignLength = 0x80
 Specific length offset ?
 AlignLeft = 0x1
 Align children to the left.
 AlignRight = 0x2
 Align children to the right.
 AlignCenter = 0x3
 Align children to the center.
 AlignJustify = 0x4
 Justify children left and right.
enum  PositionScheme { Static, Relative, Absolute, Fixed }
 Layout mechanism for this widget. More...
enum  Side {
  None = 0x0, Top = 0x1, Bottom = 0x2, Left = 0x4,
  Right = 0x8, Verticals = (0x4 | 0x8), Horizontals = (0x1 | 0x8), All = (Top | Bottom | Left | Right)
}
 Enumeration that designates a side of widget. 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 setOffset (int s, WLength x)=0
 Position a non-statically positioned widget with respect to its parent.
virtual WLength offset (Side s) 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 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 remain empty.
virtual int clearSides () const =0
 Get the sides that should be 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 WCssDecorationStyledecorationStyle ()=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.

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.
virtual bool streamResourceData (std::ostream &stream)
 Stream the data for this resource.

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::HorizontalAlignment

The horizontal alignment of child widgets.

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.

enum Wt::WWidget::PositionScheme

Layout mechanism for this widget.

The layout mechanism for the WWidget.

See also:
setPositionScheme(PositionScheme scheme)
Enumerator:
Static  The WWidget is layed-out with other Static and Relative sibling widgets, in a consecutive way. Consecutive inline widgets are layed out in lines. Otherwise widgets are stacked vertically. Static WWidgets may also float to the left or right border.

See also:
setFloatSide(Side s)
Relative  Same as Static, but after layout, the WWidget is offset.
Absolute  The WWidget is positioned at an absolute position with respect to the nearest ancestor widget that either:
Fixed  The WWidget is positioned at fixed position with respect to the browser's view-pane.

enum Wt::WWidget::Side

Enumeration that designates a side of widget.

See also:
setOffset(Side s, WLength x), setFloatSide(Side s), setClearSides(int sides)
Enumerator:
None  No side.
Top  Top side.
Bottom  Bottom side.
Left  Left side.
Right  Right side.
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)
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 ?


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

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

virtual int Wt::WWidget::clearSides (  )  const [pure virtual]

Get the sides that should be remain empty.

Fixme: lookup what this actually does in the CSS manual.

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.

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

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

Return the float side.

See also:
setFloatSide(Side)

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

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

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

Hide this WWidget.

See also:
setHidden(bool)

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

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

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

Retrieve the offset of the widget.

See also:
setOffset(Side, WLength)

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

Get the widget position scheme.

See also:
setPositionScheme(PositionScheme)

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

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.

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

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

virtual void Wt::WWidget::setClearSides ( int  sides  )  [pure virtual]

Set the sides that should be remain empty.

Fixme: lookup what this actually does in the CSS manual.

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 .

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::WFormWidget, 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 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 void Wt::WWidget::setOffset ( int  s,
WLength  x 
) [pure virtual]

Position a non-statically positioned widget with respect to its parent.

This applies only to widgets that have a non-Static positionScheme(), as these latter widgets are layed out automatically in an inline or block flow.

When this widget uses a Relative position scheme, it specifies the offset with respect to its position as it would be when layed-out using a Static positionScheme(). In that case, one can specify an vertical offset (with respect to Top or Bottom ) to shift the widget up or down, or a horizontal offset (with respect to Left or Right ) to shift the widget to the left or to the right.

When this widget uses an Absolute or Fixed position scheme, it specifies the position within respectively the reference parent WWidget, or the browser viewport. In that case, the side refers to the sides of this reference.

In all cases, valid values for Side or only Left , Right , Bottom and Top .

See also:
offset(Side) const

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 void Wt::WWidget::setPositionScheme ( PositionScheme  scheme  )  [pure virtual]

Set the widget position scheme.

Set how the widget must be layed-out.

See also:
positionScheme()

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

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

Setting a style class will interfere with all layout and decoration style properties of the WWidget (does it?). To remove the style class, set an empty string as style class.

See also:
WApplication::styleSheet()

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

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

Show this WWidget.

See also:
setHidden(bool)

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

No longer accept a mime type for dropping.

See also:
acceptDrops

bool Wt::WWidget::streamResourceData ( std::ostream &  stream  )  [protected, virtual]

Stream the data for this resource.

Implement this method to output the data for this resource.

Returns whether all data has been streamed. If not, call flush() from outside the mean event loop to indicate that more data is available. This is how "server-push" is implemented. The stream is not closed until this function returns true.

See also:
flush()

Implements Wt::WResource.

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.

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

Short hand for WString::tr().

Create a message with the given key.

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

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


The documentation for this class was generated from the following files:
Generated on Sun Jul 1 19:37:18 2007 for Wt by doxygen 1.4.7