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

Base class for the placement helper. More...

#include <placer.hpp>

Inheritance diagram for gui2::tplacer_:
Inheritance graph

Public Member Functions

virtual MAKE_ENUM(tgrow_direction,(horizontal,"horizontal")(vertical,"vertical"))
public 
~tplacer_ ()
 The direction the placer should grow towards. More...
 
virtual void initialise ()=0
 Initialises the placer. More...
 
virtual void add_item (const tpoint &size)=0
 Adds a item to be placed. More...
 
virtual tpoint get_size () const =0
 Gets the required size of all items. More...
 
virtual tpoint 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 52 of file placer.hpp.

Constructor & Destructor Documentation

gui2::tplacer_::~tplacer_ ( )
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::tplacer_::add_item ( const tpoint size)
pure virtual

Adds a item to be placed.

Parameters
sizeThe required size for the item.

Implemented in gui2::implementation::tplacer_horizontal_list, and gui2::implementation::tplacer_vertical_list.

virtual tpoint gui2::tplacer_::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::tplacer_horizontal_list, and gui2::implementation::tplacer_vertical_list.

virtual tpoint gui2::tplacer_::get_size ( ) const
pure virtual

Gets the required size of all items.

Returns
The required size.

Implemented in gui2::implementation::tplacer_horizontal_list, and gui2::implementation::tplacer_vertical_list.

virtual void gui2::tplacer_::initialise ( )
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::tplacer_horizontal_list, and gui2::implementation::tplacer_vertical_list.


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