Public Member Functions | Private Attributes
Layout Class Reference

#include <layout.h>

Inheritance diagram for Layout:

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 43 of file layout.h.

Constructor & Destructor Documentation

◆ Layout()

Layout::Layout ( )

Definition at line 27 of file layout.cpp.

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

27  :
28  LayoutCell(),
29  mComputed(false)
30 {
31  getArray();
32  setPadding(6);
33 }
LayoutArray & getArray()
Definition: layoutcell.cpp:41
bool mComputed
Definition: layout.h:63
LayoutCell & setPadding(int p)
Definition: layoutcell.h:59

Member Function Documentation

◆ reflow()

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

Sets the positions of all the widgets.

See also

Definition at line 35 of file layout.cpp.

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(), setMargin(), LayoutHelper::widgetResized(), and Window::widgetResized().

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

◆ setMargin()

void Layout::setMargin ( int  m)

Sets the margin around the layout.

Definition at line 53 of file layout.h.

References reflow(), restrict, and LayoutCell::setPadding().

Referenced by ShortcutWindow::ShortcutWindow().

54  { setPadding(m); }
LayoutCell & setPadding(int p)
Definition: layoutcell.h:59

Field Documentation

◆ mComputed

bool Layout::mComputed

Definition at line 63 of file layout.h.

Referenced by reflow().

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