ManaPlus
Public Member Functions | Private Attributes
Layout Class Reference

#include <layout.h>

Inheritance diagram for Layout:
LayoutCell

Public Member Functions

 Layout ()
 
void setMargin (int m)
 
void reflow (int &nW, int &nH)
 
- Public Member Functions inherited from LayoutCell
virtual ~LayoutCell ()
 
LayoutCellsetPadding (int p)
 
int getVPadding () const
 
int getHPadding () const
 
LayoutCellsetVPadding (int p)
 
LayoutCellsetHPadding (int p)
 
LayoutCellsetHAlign (const Alignment a)
 
LayoutCellsetVAlign (const Alignment a)
 
LayoutCellat (const int x, const int y)
 
LayoutCellplace (Widget *const wg, const int x, const int y, const int w, const int h)
 
void matchColWidth (const int n1, const int n2)
 
void setColWidth (const int n, const int w)
 
void setRowHeight (const int n, const int h)
 
void extend (const int x, const int y, const int w, const int h)
 
void computeSizes ()
 
void setType (int t)
 
int getWidth () const
 
int getHeight () const
 
void setWidth (const int w)
 
void setHeight (const int h)
 

Private Attributes

bool mComputed
 

Additional Inherited Members

- Public Types inherited from LayoutCell
enum  Alignment { LEFT = 0 , RIGHT , CENTER , FILL }
 
enum  { NONE = 0 , WIDGET , ARRAY }
 
- Static Public Attributes inherited from LayoutCell
static LayoutCell emptyCell
 

Detailed Description

This class is an helper for setting the position of widgets. They are positioned along the cells of some rectangular tables. The layout may either be a single table or a tree of nested tables.

The size of a given table column can either be set manually or be chosen from the widest widget of the column. An empty column has a AUTO_DEF width, which means it will be extended so that the layout fits its minimum width.

The process is similar for table rows. By default, there is a spacing of 4 pixels between rows and between columns, and a margin of 6 pixels around the whole layout.

Definition at line 44 of file layout.h.

Constructor & Destructor Documentation

◆ Layout()

Layout::Layout ( )

Definition at line 28 of file layout.cpp.

28  :
29  LayoutCell(),
30  mComputed(false)
31 {
32  getArray();
33  setPadding(6);
34 }
LayoutCell & setPadding(int p)
Definition: layoutcell.h:60
LayoutArray & getArray()
Definition: layoutcell.cpp:42
bool mComputed
Definition: layout.h:64

References LayoutCell::getArray(), and LayoutCell::setPadding().

Member Function Documentation

◆ reflow()

void Layout::reflow ( int &  nW,
int &  nH 
)

Sets the positions of all the widgets.

See also
LayoutArray::reflow

Definition at line 36 of file layout.cpp.

37 {
38  if (!mComputed)
39  {
40  computeSizes();
41  mComputed = true;
42  }
43 
44  nw = (nw == 0 ? mSize[0] + 2 * mHPadding : nw);
45  nh = (nh == 0 ? mSize[1] + 2 * mVPadding : nh);
46  LayoutCell::reflow(0, 0, nw, nh);
47 }
void reflow(int nx, int ny, int nw, int nh)
Definition: layoutcell.cpp:64
int mSize[2]
Definition: layoutcell.h:196
int mHPadding
Definition: layoutcell.h:197
void computeSizes()
Definition: layoutcell.cpp:79
int mVPadding
Definition: layoutcell.h:198

References LayoutCell::computeSizes(), mComputed, LayoutCell::mHPadding, LayoutCell::mSize, LayoutCell::mVPadding, and LayoutCell::reflow().

Referenced by EditServerDialog::EditServerDialog(), Window::redraw(), LayoutHelper::reflowLayout(), Window::reflowLayout(), ServerDialog::ServerDialog(), LayoutHelper::widgetResized(), and Window::widgetResized().

◆ setMargin()

void Layout::setMargin ( int  m)
inline

Sets the margin around the layout.

Definition at line 54 of file layout.h.

55  { setPadding(m); }

References LayoutCell::setPadding().

Referenced by ShortcutWindow::ShortcutWindow().

Field Documentation

◆ mComputed

bool Layout::mComputed
private

Definition at line 64 of file layout.h.

Referenced by reflow().


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