Wt::WLayout Class Reference

An abstract base class for layout managers. More...

#include <Wt/WLayout>

Inheritance diagram for Wt::WLayout:

Inheritance graph
[legend]

List of all members.

Public Member Functions

virtual ~WLayout ()
 Destroy the layout.
virtual void addItem (WLayoutItem *item)=0
 Add a layout item.
void addWidget (WWidget *widget)
 Add the given widget to the layout.
virtual void removeItem (WLayoutItem *item)=0
 Remove a layout item (widget or nested layout).
void removeWidget (WWidget *widget)
 Remove the given widget from the layout.
virtual int count () const =0
 Return the number of items in this layout.
virtual WLayoutItemitemAt (int index) const =0
 Return the layout item at a specific index.
virtual int indexOf (WLayoutItem *item) const
 Return the index of a given item.
virtual WWidgetItemfindWidgetItem (WWidget *widget)
 Finds the widget item associated with the given widget.
void setLayoutHint (const std::string &name, const std::string &value)
 Provide a hint to the layout implementation.
virtual WWidgetwidget ()
 Get the widget that is held by this WLayoutItem.
virtual WLayoutlayout ()
 Get the layout that implements this WLayoutItem.
WLayoutItemImplimpl () const
 Get the implementation for this layout item.
void setContentsMargins (int left, int top, int right, int bottom)
 Set contents margins (in pixels).
void getContentsMargins (int *left, int *top, int *right, int *bottom) const
 Returns the contents margins.

Protected Member Functions

 WLayout ()
 Create a layout.
void update (WLayoutItem *item=0)
 Update the layout.
void updateAddItem (WLayoutItem *item)
 Update the layout, adding the given layout item.
void updateRemoveItem (WLayoutItem *item)
 Update the layout, remove the given layout item.
void setLayoutInParent (WWidget *parent)
 Set the layout in the parent.


Detailed Description

An abstract base class for layout managers.

This class is the abstract base class for any layout manager. A layout manager is associated with a container widget, and manages the layout of children inside the whole space available to the container widget.

Layout managers may be used with WContainerWidget and Ext::Container container widgets. A suitable implementation for all layout classes is not yet available for both containers, and thus you need to refer to the documentation of a layout manager to see if it is applicable to your situation.

The implementation of the layout manager depends on the container widget to which it is set, and is therefore deferred to WLayoutImpl.

A layout never assumes ownership of contained items, instead these are owned by the parent widget to which the layout is applied.

Note:
When applying a layout manager to a WContainerWidget, you may not define any padding for the container widget. Instead, use setContentsMargins().

Member Function Documentation

virtual void Wt::WLayout::addItem ( WLayoutItem item  )  [pure virtual]

Add a layout item.

The item may be a widget or nested layout.

How the item is layed out with respect to siblings is implementation specific to the layout manager. In some cases, a layout manager will overload this method with extra arguments that specify layout options.

See also:
removeItem(WLayoutItem *), addWidget(WWidget *)

Implemented in Wt::WBorderLayout, Wt::WBoxLayout, Wt::WDefaultLayout, Wt::WFitLayout, and Wt::WGridLayout.

void Wt::WLayout::addWidget ( WWidget widget  ) 

Add the given widget to the layout.

This method wraps the widget in a WWidgetItem and calls addItem(WLayoutItem *).

How the widget is layed out with respect to siblings is implementation specific to the layout manager. In some cases, a layout manager will overload this method with extra arguments that specify layout options.

See also:
removeWidget(WWidget *), addItem(WLayoutItem *)

virtual void Wt::WLayout::removeItem ( WLayoutItem item  )  [pure virtual]

Remove a layout item (widget or nested layout).

See also:
addItem(WLayoutItem *), removeWidget(WWidget *)

Implemented in Wt::WBorderLayout, Wt::WBoxLayout, Wt::WDefaultLayout, Wt::WFitLayout, and Wt::WGridLayout.

void Wt::WLayout::removeWidget ( WWidget widget  ) 

Remove the given widget from the layout.

This method finds the corresponding WWidgetItem and calls removeItem(WLayoutItem *). The widget itself is not destroyed.

See also:
addWidget(WWidget *), removeItem(WLayoutItem *)

virtual int Wt::WLayout::count (  )  const [pure virtual]

Return the number of items in this layout.

This may be a theoretical number, which is greater than the actual number of items. It can be used to iterate over the items in the layout, in conjunction with itemAt().

Implemented in Wt::WBorderLayout, Wt::WBoxLayout, Wt::WDefaultLayout, Wt::WFitLayout, and Wt::WGridLayout.

virtual WLayoutItem* Wt::WLayout::itemAt ( int  index  )  const [pure virtual]

Return the layout item at a specific index.

If there is no item at the index, 0 is returned.

See also:
indexOf(WLayoutItem *), count()

Implemented in Wt::WBorderLayout, Wt::WBoxLayout, Wt::WDefaultLayout, Wt::WFitLayout, and Wt::WGridLayout.

int Wt::WLayout::indexOf ( WLayoutItem item  )  const [virtual]

Return the index of a given item.

The default implementation loops over all items, and returns the index for which itemAt(index) equals item.

See also:
itemAt(int)

Reimplemented in Wt::WDefaultLayout, and Wt::WFitLayout.

void Wt::WLayout::setLayoutHint ( const std::string &  name,
const std::string &  value 
)

Provide a hint to the layout implementation.

In some caes, a layout implementation may require some hints for rendering its contents. Possible hints are indicated in the reference documentation for each layout manager.

virtual WWidget* Wt::WLayout::widget (  )  [inline, virtual]

Get the widget that is held by this WLayoutItem.

This implements a type-safe upcasting mechanism to a WWidgetItem.

Implements Wt::WLayoutItem.

virtual WLayout* Wt::WLayout::layout (  )  [inline, virtual]

Get the layout that implements this WLayoutItem.

This implements a type-safe upcasting mechanism to a WLayout.

Implements Wt::WLayoutItem.

WLayoutItemImpl* Wt::WLayout::impl (  )  const [inline, virtual]

Get the implementation for this layout item.

The implementation of a layout item depends on the kind of container for which the layout does layout management.

Implements Wt::WLayoutItem.

void Wt::WLayout::setContentsMargins ( int  left,
int  top,
int  right,
int  bottom 
)

Set contents margins (in pixels).

The default contents margins are 9 pixels in all directions.

Note:
Only used when the layout manager is applied to a WContainerWidget.
See also:
setContentsMargins()

void Wt::WLayout::getContentsMargins ( int *  left,
int *  top,
int *  right,
int *  bottom 
) const

Returns the contents margins.

See also:
getContentsMargins()

void Wt::WLayout::update ( WLayoutItem item = 0  )  [protected]

Update the layout.

Must be called whenever some properties of the layout have changed.

void Wt::WLayout::updateAddItem ( WLayoutItem item  )  [protected]

Update the layout, adding the given layout item.

Must be called from the implementation of addItem(WLayoutItem *)

void Wt::WLayout::updateRemoveItem ( WLayoutItem item  )  [protected]

Update the layout, remove the given layout item.

Must be called from the implementation of removeItem(WLayoutItem *)

void Wt::WLayout::setLayoutInParent ( WWidget parent  )  [protected]

Set the layout in the parent.

Must be called from the constructor after the layout has been fully created (since it will call virtual methods count() and itemAt()).


Generated on Fri Apr 24 16:25:59 2009 for Wt by doxygen 1.5.6