The Battle for Wesnoth  1.13.11+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Public Member Functions | List of all members
gui2::placer_base Class Referenceabstract

Base class for the placement helper. More...

#include <placer.hpp>

Inheritance diagram for gui2::placer_base:
Inheritance graph

Public Member Functions

virtual MAKE_ENUM(tgrow_direction,(horizontal,"horizontal")(vertical,"vertical"))
public 
~placer_base ()
 The direction the placer should grow towards. More...
 
virtual void initialize ()=0
 Initialises the placer. More...
 
virtual void add_item (const point &size)=0
 Adds a item to be placed. More...
 
virtual point get_size () const =0
 Gets the required size of all items. More...
 
virtual point get_origin (const unsigned index) const =0
 Gets the origin for an item. More...
 

Detailed Description

Base class for the placement helper.

The normal operation for the usage of the class is:

Note
The origins can only be retrieved after all items are added since the adding of a later item may influence a previous item. E.g. in a vertical list with two columns the position of the second column depends on the width of the first and a later row may have a wider column 1 as an earlier row.

Definition at line 50 of file placer.hpp.

Constructor & Destructor Documentation

gui2::placer_base::~placer_base ( )
virtual

The direction the placer should grow towards.

Builder function.

Precondition
parallel_items > 0
Parameters
grow_directionThe direction in which the items will be added.
parallel_itemsThe direction perpendicular towards the grow direction has a fixed number of items. This value sets that limit. For a list containing only horizontally or vertically placed items the value should be 1.

Definition at line 40 of file placer.cpp.

Member Function Documentation

virtual void gui2::placer_base::add_item ( const point size)
pure virtual

Adds a item to be placed.

Parameters
sizeThe required size for the item.

Implemented in gui2::implementation::placer_horizontal_list, and gui2::implementation::placer_vertical_list.

virtual point gui2::placer_base::get_origin ( const unsigned  index) const
pure virtual

Gets the origin for an item.

Parameters
indexThe index of the item whose origin to return. The index is the index of the call to add_item().
Returns
The origin where to place the widget.

Implemented in gui2::implementation::placer_horizontal_list, and gui2::implementation::placer_vertical_list.

virtual point gui2::placer_base::get_size ( ) const
pure virtual

Gets the required size of all items.

Returns
The required size.

Implemented in gui2::implementation::placer_horizontal_list, and gui2::implementation::placer_vertical_list.

virtual void gui2::placer_base::initialize ( )
pure virtual

Initialises the placer.

When the placement needs to be calculated the state often needs to be reset, items are placed, removed or changed visibility causing the old placement to be invalid.

Implemented in gui2::implementation::placer_horizontal_list, and gui2::implementation::placer_vertical_list.


The documentation for this class was generated from the following files: