#include <layout.h>
Inherits Wt::Object, and Wt::LayoutItem.
Inherited by Wt::LayoutStdContainer< Container >, Wt::LayoutStdContainer< std::list< BoxLayoutItemCompound > >, Wt::LayoutStdContainer< std::list< CascadeLayoutItemCompound > >, and Wt::LayoutStdContainer< Wt::Matrix< MatrixLayoutItemCompound > >.
Public Member Functions | |
Layout (Widget *parent, int margin=0, int spacing=-1, const std::string &name="Layout::anon") | |
Layout (Layout *parentLayout, int margin=0, int spacing=-1, const std::string &name="Layout::anon") | |
Layout (int spacing=-1, const std::string &name="Layout::anon") | |
virtual | ~Layout () |
Widget * | mainWidget () const |
bool | isTopLevel () const |
virtual Size | sizeHint () const |
virtual Size | minimumSize () const |
virtual void | addItem (LayoutItem *li) |
virtual bool | removeItem (LayoutItem *li) |
returns true if a layoutitem is actually removed | |
virtual bool | eventFilter (Object *, Event *) |
virtual void | setGeometry (const Rect &r) |
Public Attributes | |
WVar< int > | margin |
WVar< int > | spacing |
WVar< bool > | autoAdd |
Protected Member Functions | |
virtual bool | onAboutToChangeAutoAdd (bool auto_add) |
virtual int | onSpacingOverride (int spacing) |
void | adjustMaximumSize (int margin) |
virtual bool | exists (const LayoutItem *li) const =0 |
void | markDeleted (LayoutItem *li) |
bool | isDeleted (LayoutItem *li) const |
void | enforce () |
enforces the layout in the mainWidget() children and layouts | |
void | postLayoutHintEvent () |
void | setWidthasPrimaryLength (bool width=true) |
bool | isWidthPrimaryLength () const |
template<typename TYPE> | |
int | primaryLength (const TYPE &t) const |
int | preferredLength (const LayoutItem *li, bool expand) const |
template<typename TYPE> | |
int | secondaryLength (const TYPE &t) const |
template<typename TYPE> | |
int | primaryOffset (const TYPE &t) const |
template<typename TYPE> | |
int | secondaryOffset (const TYPE &t) const |
Point | getPoint (int primary_offset, int secondary_offset) const |
Size | getSize (int primary, int secondary) const |
Rect | getRect (int primary_offset, int secondary_offset, int primary_size, int secondary_size) const |
int | primaryStretch (const SizePolicy &sp) const |
bool | mayGrowPrimally (const SizePolicy &sp) const |
bool | mayShrinkPrimally (const SizePolicy &sp) const |
bool | expandingPrimally (const SizePolicy &sp) const |
The Layout class takes ownership of child layouts (Objects), and other layoutitems that are not widgets. Widgets have their own ierarchy and so a Layout absolutely does not delete Widgets, in any way.
Layouts will be deleted when the parent layout dies or when they are explictely deleted. The rest of the layout items (spacer) will be deleted on Layout::remove() and/or ~Layout().
In the mean time however, we keep track of all these pointers into our container layout and layout actively syncronizes the list when a child is deleted.
In short: Layout contains LayoutItems. LayoutItems can be Layouts, Widgets and Spacers. Layouts are also children to parent Layout.
Layout Widgets Spacer Deleted on remove y n y Deleted on ~Layout y n y removed on deletion y y *
don't do that. That objects are now belong to Layout and cannot be deleted safely since they are not Objects. If you want them to be deleted remove them from the Layout via Layout::remove()
Wt::Layout::Layout | ( | Widget * | parent, | |
int | margin = 0 , |
|||
int | spacing = -1 , |
|||
const std::string & | name = "Layout::anon" | |||
) |
Wt::Layout::Layout | ( | Layout * | parentLayout, | |
int | margin = 0 , |
|||
int | spacing = -1 , |
|||
const std::string & | name = "Layout::anon" | |||
) |
Wt::Layout::Layout | ( | int | spacing = -1 , |
|
const std::string & | name = "Layout::anon" | |||
) |
virtual Wt::Layout::~Layout | ( | ) | [inline, virtual] |
void Wt::Layout::addItem | ( | LayoutItem * | li | ) | [virtual] |
void Wt::Layout::adjustMaximumSize | ( | int | margin | ) | [protected] |
void Wt::Layout::enforce | ( | ) | [protected] |
enforces the layout in the mainWidget() children and layouts
it can be only called if there is a main widget
we get events from the mainWidget only if exists. The type of events are:
The following uses cases has to be covered:
// we monitor the managed widgets // top level layout grabs it (if tll exists) Layout::eventFilter() { // on layoutHint event calls Layout::enforce(); // on resize calls Layout::setGeometry(r); // on child insert / remove in mainWidget // this implies enforce called in the next event processing Application::postEvent(mainWidget(), new LayoutHintEvent()); }
Reimplemented from Wt::Object.
virtual bool Wt::Layout::exists | ( | const LayoutItem * | li | ) | const [protected, pure virtual] |
bool Wt::Layout::expandingPrimally | ( | const SizePolicy & | sp | ) | const [protected] |
Point Wt::Layout::getPoint | ( | int | primary_offset, | |
int | secondary_offset | |||
) | const [protected] |
Rect Wt::Layout::getRect | ( | int | primary_offset, | |
int | secondary_offset, | |||
int | primary_size, | |||
int | secondary_size | |||
) | const [protected] |
Size Wt::Layout::getSize | ( | int | primary, | |
int | secondary | |||
) | const [protected] |
bool Wt::Layout::isDeleted | ( | LayoutItem * | li | ) | const [inline, protected] |
bool Wt::Layout::isTopLevel | ( | ) | const |
bool Wt::Layout::isWidthPrimaryLength | ( | ) | const [inline, protected] |
Widget * Wt::Layout::mainWidget | ( | ) | const |
void Wt::Layout::markDeleted | ( | LayoutItem * | li | ) | [inline, protected] |
bool Wt::Layout::mayGrowPrimally | ( | const SizePolicy & | sp | ) | const [protected] |
bool Wt::Layout::mayShrinkPrimally | ( | const SizePolicy & | sp | ) | const [protected] |
Size Wt::Layout::minimumSize | ( | ) | const [virtual] |
Reimplemented from Wt::LayoutItem.
bool Wt::Layout::onAboutToChangeAutoAdd | ( | bool | auto_add | ) | [protected, virtual] |
int Wt::Layout::onSpacingOverride | ( | int | spacing | ) | [protected, virtual] |
void Wt::Layout::postLayoutHintEvent | ( | ) | [protected] |
int Wt::Layout::preferredLength | ( | const LayoutItem * | li, | |
bool | expand | |||
) | const [protected] |
int Wt::Layout::primaryLength | ( | const TYPE & | t | ) | const [inline, protected] |
int Wt::Layout::primaryOffset | ( | const TYPE & | t | ) | const [protected] |
int Wt::Layout::primaryStretch | ( | const SizePolicy & | sp | ) | const [protected] |
bool Wt::Layout::removeItem | ( | LayoutItem * | li | ) | [virtual] |
returns true if a layoutitem is actually removed
Reimplemented in Wt::LayoutStdContainer< Container >, Wt::LayoutStdContainer< Wt::Matrix< MatrixLayoutItemCompound > >, Wt::LayoutStdContainer< std::list< CascadeLayoutItemCompound > >, and Wt::LayoutStdContainer< std::list< BoxLayoutItemCompound > >.
int Wt::Layout::secondaryLength | ( | const TYPE & | t | ) | const [protected] |
int Wt::Layout::secondaryOffset | ( | const TYPE & | t | ) | const [protected] |
void Wt::Layout::setGeometry | ( | const Rect & | r | ) | [virtual] |
Reimplemented from Wt::LayoutItem.
Reimplemented in Wt::CascadeLayout, Wt::GridLayout, and Wt::BoxLayout.
void Wt::Layout::setWidthasPrimaryLength | ( | bool | width = true |
) | [protected] |
Size Wt::Layout::sizeHint | ( | ) | const [virtual] |
Reimplemented from Wt::LayoutItem.
WVar<bool> Wt::Layout::autoAdd |
WVar<int> Wt::Layout::margin |
WVar<int> Wt::Layout::spacing |
This document is licensed under the terms of the GNU Free Documentation License and may be freely distributed under the conditions given by this license.