Wt  4.0.2
Public Types | Public Member Functions | Private Member Functions | List of all members
Wt::WBorderLayout Class Reference

A layout manager which divides the container region in five regions. More...

#include <Wt/WBorderLayout.h>

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

Public Types

typedef LayoutPosition Position
 Typedef for enum Wt::LayoutPosition.
 
- Public Types inherited from Wt::WObject
typedef void(WObject::* Method) ()
 Typedef for a WObject method without arguments.
 

Public Member Functions

 WBorderLayout ()
 Creates a new border layout.
 
 ~WBorderLayout ()
 Destructor.
 
void setSpacing (int size)
 Sets spacing between each item. More...
 
int spacing () const
 Returns the spacing between each item. More...
 
virtual void addItem (std::unique_ptr< WLayoutItem > item) override
 Adds a layout item. More...
 
virtual std::unique_ptr< WLayoutItemremoveItem (WLayoutItem *item) override
 Removes a layout item (widget or nested layout). More...
 
virtual WLayoutItemitemAt (int index) const override
 Returns the layout item at a specific index. More...
 
virtual int count () const override
 Returns the number of items in this layout. More...
 
void addWidget (std::unique_ptr< WWidget > widget, LayoutPosition position)
 Adds a widget to the given position. More...
 
void add (std::unique_ptr< WLayoutItem > item, LayoutPosition position)
 Adds a layout item to the given position. More...
 
WWidgetwidgetAt (LayoutPosition position) const
 Returns the widget at a position. More...
 
WLayoutItemitemAt (LayoutPosition position) const
 Returns the item at a position. More...
 
LayoutPosition position (WLayoutItem *item) const
 Returns the position at which the given layout item is set.
 
- Public Member Functions inherited from Wt::WLayout
virtual ~WLayout ()
 Destructor. More...
 
void setPreferredImplementation (LayoutImplementation implementation)
 Set the preferred layout implementation. More...
 
void addWidget (std::unique_ptr< WWidget > widget)
 Adds the given widget to the layout. More...
 
std::unique_ptr< WWidgetremoveWidget (WWidget *widget)
 Removes the given widget from the layout. More...
 
virtual int indexOf (WLayoutItem *item) const
 Returns the index of a given item. More...
 
virtual WWidgetItemfindWidgetItem (WWidget *widget) override
 Finds the widget item associated with the given widget.
 
virtual WWidgetwidget () override
 Returns the widget that is held by this WLayoutItem. More...
 
virtual WLayoutlayout () override
 Returns the layout that implements this WLayoutItem. More...
 
virtual WLayoutparentLayout () const override
 Returns the layout in which this item is contained.
 
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...
 
- Public Member Functions inherited from Wt::WLayoutItem
virtual ~WLayoutItem ()
 Destructor.
 
- Public Member Functions inherited from Wt::WObject
void addChild (std::unique_ptr< WObject > child)
 Add a child WObject whose lifetime is determined by this WObject.
 
template<typename Child >
Child * addChild (std::unique_ptr< Child > child)
 Add a child WObject, returning a raw pointer. More...
 
std::unique_ptr< WObjectremoveChild (WObject *child)
 Remove a child WObject, so its lifetime is no longer determined by this WObject.
 
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...
 
- Public Member Functions inherited from Wt::Core::observable
 observable () noexcept
 Default constructor.
 
virtual ~observable ()
 Destructor. More...
 

Private Member Functions

virtual void setParentWidget (WWidget *parent) override
 Internal method.
 

Additional Inherited Members

- Static Public Member Functions inherited from Wt::WLayout
static void setDefaultImplementation (LayoutImplementation implementation)
 Sets the preferred layout implementation globally. More...
 
- Protected Member Functions inherited from Wt::WLayout
 WLayout ()
 Create a layout.
 
void update (WLayoutItem *item=nullptr)
 Update the layout. More...
 
- Protected Member Functions inherited from Wt::WObject
virtual WStatelessSlot * getStateless (Method method)
 On-demand stateless slot implementation. More...
 

Detailed Description

A layout manager which divides the container region in five regions.

The five regions are composed of:

  ------------------------------------
  |              North               |
  ------------------------------------
  |      |                    |      |
  | West |       Center       | East |
  |      |                    |      |
  ------------------------------------
  |              South               |
  ------------------------------------

Each region may hold no more than one widget, and for all but the Center region, the widget is optional.

The North, West, East, and South widgets will take their preferred sizes, while the Center widget takes all available remaining space.

Usage example:

auto w = addWidget(std::make_unique<Wt::WContainerWidget>());
auto layout = std::make_unique<Wt::WBorderLayout>();
layout->addWidget(std::make_unique<Wt::WText>("West-side is best"), Wt::LayoutPosition::West);
layout->addWidget(std::make_unique<Wt::WText>("East-side is best"), Wt::LayoutPosition::East);
// use layout but do not justify vertically

Member Function Documentation

void Wt::WBorderLayout::add ( std::unique_ptr< WLayoutItem item,
LayoutPosition  position 
)

Adds a layout item to the given position.

Only one widget per position is supported.

void Wt::WBorderLayout::addItem ( std::unique_ptr< WLayoutItem item)
overridevirtual

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

Implements Wt::WLayout.

void Wt::WBorderLayout::addWidget ( std::unique_ptr< WWidget widget,
LayoutPosition  position 
)

Adds a widget to the given position.

Only one widget per position is supported.

See also
add(WLayoutItem *, Position)
int Wt::WBorderLayout::count ( ) const
overridevirtual

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

Implements Wt::WLayout.

WLayoutItem * Wt::WBorderLayout::itemAt ( int  index) const
overridevirtual

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

Implements Wt::WLayout.

WLayoutItem * Wt::WBorderLayout::itemAt ( LayoutPosition  position) const

Returns the item at a position.

Returns 0 if no item was set for that position.

std::unique_ptr< WLayoutItem > Wt::WBorderLayout::removeItem ( WLayoutItem item)
overridevirtual

Removes a layout item (widget or nested layout).

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

Implements Wt::WLayout.

void Wt::WBorderLayout::setSpacing ( int  size)

Sets spacing between each item.

The default spacing is 6 pixels.

int Wt::WBorderLayout::spacing ( ) const

Returns the spacing between each item.

See also
setSpacing()
WWidget * Wt::WBorderLayout::widgetAt ( LayoutPosition  position) const

Returns the widget at a position.

Returns 0 if no widget was set for that position.


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