Wt  3.3.9
Public Member Functions | Protected Member Functions | Private Member Functions | List of all members
Wt::WLayout Class Referenceabstract

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

#include <Wt/WLayout>

Inheritance diagram for Wt::WLayout:
Inheritance graph
[legend]

Public Member Functions

virtual ~WLayout ()
 Destructor. More...
 
virtual void addItem (WLayoutItem *item)=0
 Adds a layout item. More...
 
void addWidget (WWidget *widget)
 Adds the given widget to the layout. More...
 
virtual void removeItem (WLayoutItem *item)=0
 Removes a layout item (widget or nested layout). More...
 
bool removeWidget (WWidget *widget)
 Removes the given widget from the layout. More...
 
virtual int count () const =0
 Returns the number of items in this layout. More...
 
virtual WLayoutItemitemAt (int index) const =0
 Returns the layout item at a specific index. More...
 
virtual int indexOf (WLayoutItem *item) const
 Returns the index of a given item. More...
 
virtual WWidgetItemfindWidgetItem (WWidget *widget)
 Finds the widget item associated with the given widget.
 
void setLayoutHint (const std::string &name, const std::string &value)
 Provides a hint to the layout implementation. More...
 
virtual WWidgetwidget ()
 Returns the widget that is held by this WLayoutItem. More...
 
virtual WLayoutlayout ()
 Returns the layout that implements this WLayoutItem. More...
 
virtual WLayoutparentLayout () const
 Returns the layout in which this item is contained.
 
WLayoutItemImplimpl () const
 Returns the implementation for this layout item. More...
 
void setContentsMargins (int left, int top, int right, int bottom)
 Set contents margins (in pixels). More...
 
void getContentsMargins (int *left, int *top, int *right, int *bottom) const
 Returns the contents margins. More...
 
virtual void clear ()=0
 Removes and deletes all child widgets and nested layouts. More...
 
- Public Member Functions inherited from Wt::WLayoutItem
virtual ~WLayoutItem ()
 Destructor.
 
- Public Member Functions inherited from Wt::WObject
 WObject (WObject *parent=0)
 Create a WObject with a given parent object. More...
 
virtual ~WObject ()
 Destructor. More...
 
virtual const std::string id () const
 Returns the (unique) identifier for this object. More...
 
virtual void setObjectName (const std::string &name)
 Sets an object name. More...
 
virtual std::string objectName () const
 Returns the object name. More...
 
void resetLearnedSlots ()
 Resets learned stateless slot implementations. More...
 
template<class T >
void resetLearnedSlot (void(T::*method)())
 Resets a learned stateless slot implementation. More...
 
template<class T >
WStatelessSlot * implementStateless (void(T::*method)())
 Declares a slot to be stateless and learn client-side behaviour on first invocation. More...
 
template<class T >
WStatelessSlot * implementStateless (void(T::*method)(), void(T::*undoMethod)())
 Declares a slot to be stateless and learn client-side behaviour in advance. More...
 
void isNotStateless ()
 Marks the current function as not stateless. More...
 
template<class T >
WStatelessSlot * implementJavaScript (void(T::*method)(), const std::string &jsCode)
 Provides a JavaScript implementation for a method. More...
 
void addChild (WObject *child)
 Adds a child object. More...
 
virtual void removeChild (WObject *child)
 Removes a child object. More...
 
const std::vector< WObject * > & children () const
 Returns the children.
 
WObjectparent () const
 Returns the parent object.
 

Protected Member Functions

 WLayout ()
 Create a layout.
 
void update (WLayoutItem *item=0)
 Update the layout. More...
 
void updateAddItem (WLayoutItem *item)
 Update the layout, adding the given layout item. More...
 
void updateRemoveItem (WLayoutItem *item)
 Update the layout, remove the given layout item. More...
 
void setLayoutInParent (WWidget *parent)
 Set the layout in the parent. More...
 
void clearLayoutItem (WLayoutItem *item)
 Clears and deletes an item. More...
 
- Protected Member Functions inherited from Wt::WObject
virtual WStatelessSlot * getStateless (Method method)
 On-demand stateless slot implementation. More...
 

Private Member Functions

virtual void setParentWidget (WWidget *parent)
 Internal method.
 
virtual void setParentLayout (WLayout *parentLayout)
 Internal method.
 

Additional Inherited Members

- Public Types inherited from Wt::WObject
typedef void(WObject::* Method) ()
 Typedef for a WObject method without arguments.
 
- Static Protected Member Functions inherited from Wt::WObject
static WObjectsender ()
 Returns the sender of the current slot call. More...
 

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

Constructor & Destructor Documentation

Wt::WLayout::~WLayout ( )
virtual

Destructor.

This will delete the layout (and nested layouts), but not the contained widgets.

Member Function Documentation

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

Adds 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::WGridLayout, Wt::WBoxLayout, Wt::WBorderLayout, Wt::WDefaultLayout, and Wt::WFitLayout.

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

Adds 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::clear ( )
pure virtual

Removes and deletes all child widgets and nested layouts.

This is similar to WContainerWidget::clear(), with the exception that the layout itself is not deleted.

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

void Wt::WLayout::clearLayoutItem ( WLayoutItem item)
protected

Clears and deletes an item.

This also deletes nested widgets and layouts.

See also
clear()
virtual int Wt::WLayout::count ( ) const
pure virtual

Returns 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::WGridLayout, Wt::WBoxLayout, Wt::WBorderLayout, Wt::WDefaultLayout, and Wt::WFitLayout.

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

Returns the contents margins.

See also
setContentsMargins()
WLayoutItemImpl* Wt::WLayout::impl ( ) const
virtual

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

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

Returns 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) const

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

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

Returns the layout item at a specific index.

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

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

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

virtual WLayout* Wt::WLayout::layout ( )
virtual

Returns the layout that implements this WLayoutItem.

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

Implements Wt::WLayoutItem.

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

Removes a layout item (widget or nested layout).

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

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

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

Removes the given widget from the layout.

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

Returns true if succesful.

See also
addWidget(WWidget *), removeItem(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::setLayoutHint ( const std::string &  name,
const std::string &  value 
)

Provides a hint to the layout implementation.

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

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

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

virtual WWidget* Wt::WLayout::widget ( )
virtual

Returns the widget that is held by this WLayoutItem.

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

Implements Wt::WLayoutItem.


Generated on Tue Nov 21 2017 for the C++ Web Toolkit (Wt) by doxygen 1.8.11