diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-05-14 22:09:25 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-05-14 22:09:25 +0300 |
commit | ffee866c7eea91d38f6a27fbd4ecf38b573d32ee (patch) | |
tree | 10d02aede21898dbe802798777e0588e87a17e92 /src/gui/widgets/layout.h | |
parent | 916a53ec6e9eda8711ae7c2e9296463728370751 (diff) | |
download | plus-ffee866c7eea91d38f6a27fbd4ecf38b573d32ee.tar.gz plus-ffee866c7eea91d38f6a27fbd4ecf38b573d32ee.tar.bz2 plus-ffee866c7eea91d38f6a27fbd4ecf38b573d32ee.tar.xz plus-ffee866c7eea91d38f6a27fbd4ecf38b573d32ee.zip |
Move layoutcell into separate file.
Diffstat (limited to 'src/gui/widgets/layout.h')
-rw-r--r-- | src/gui/widgets/layout.h | 172 |
1 files changed, 3 insertions, 169 deletions
diff --git a/src/gui/widgets/layout.h b/src/gui/widgets/layout.h index bf41e1c8e..c41c6570f 100644 --- a/src/gui/widgets/layout.h +++ b/src/gui/widgets/layout.h @@ -23,12 +23,13 @@ #ifndef GUI_WIDGETS_LAYOUT_H #define GUI_WIDGETS_LAYOUT_H -#include "localconsts.h" +#include "gui/widgets/layoutcell.h" #include <vector> +#include "localconsts.h" + class BasicContainer2; -class LayoutCell; class Widget; /** @@ -121,173 +122,6 @@ class LayoutArray final }; /** - * This class describes the formatting of a widget in the cell of a layout - * table. Horizontally, a widget can either fill the width of the cell (minus - * the cell padding), or it can retain its size and be flushed left, or flush - * right, or centered in the cell. The process is similar for the vertical - * alignment, except that top is represented by LEFT and bottom by RIGHT. - */ -class LayoutCell -{ - friend class Layout; - friend class LayoutArray; - - public: - enum Alignment - { - LEFT = 0, - RIGHT, - CENTER, - FILL - }; - - virtual ~LayoutCell(); - - /** - * Sets the padding around the cell content. - */ - LayoutCell &setPadding(int p) - { mHPadding = p; mVPadding = p; return *this; } - - /** - * Sets the vertical padding around the cell content. - */ - LayoutCell &setVPadding(int p) - { mVPadding = p; return *this; } - - /** - * Sets the horisontal padding around the cell content. - */ - LayoutCell &setHPadding(int p) - { mHPadding = p; return *this; } - - /** - * Sets the horizontal alignment of the cell content. - */ - LayoutCell &setHAlign(const Alignment a) - { mAlign[0] = a; return *this; } - - /** - * Sets the vertical alignment of the cell content. - */ - LayoutCell &setVAlign(const Alignment a) - { mAlign[1] = a; return *this; } - - /** - * @see LayoutArray::at - */ - LayoutCell &at(const int x, const int y) A_WARN_UNUSED - { return getArray().at(x, y); } - - /** - * @see LayoutArray::place - */ - LayoutCell &place(Widget *wg, - const int x, const int y, - const int w = 1, const int h = 1) - { return getArray().place(wg, x, y, w, h); } - - /** - * @see LayoutArray::matchColWidth - */ - void matchColWidth(const int n1, const int n2) - { getArray().matchColWidth(n1, n2); } - - /** - * @see LayoutArray::setColWidth - */ - void setColWidth(const int n, const int w) - { getArray().setColWidth(n, w); } - - /** - * @see LayoutArray::setRowHeight - */ - void setRowHeight(const int n, const int h) - { getArray().setRowHeight(n, h); } - - /** - * @see LayoutArray::extend. - */ - void extend(const int x, const int y, - const int w, const int h) - { getArray().extend(x, y, w, h); } - - /** - * Sets the minimum widths and heights of this cell and of all the - * inner cells. - */ - void computeSizes(); - - void setType(int t) - { mType = t; } - - int getWidth() const A_WARN_UNUSED - { return mExtent[0]; } - - int getHeight() const A_WARN_UNUSED - { return mExtent[1]; } - - void setWidth(const int w) - { mExtent[0] = w; } - - void setHeight(const int h) - { mExtent[1] = h; } - - enum - { - NONE = 0, - WIDGET, - ARRAY - }; - - private: - LayoutCell(): - mWidget(nullptr), - mHPadding(0), - mVPadding(0), - mType(NONE) - { - mExtent[0] = 0; - mExtent[1] = 0; - mAlign[0] = LEFT; - mAlign[1] = LEFT; - mNbFill[0] = 0; - mNbFill[1] = 0; - mSize[0] = 0; - mSize[1] = 0; - } - - // Copy not allowed, as the cell may own an array. - explicit LayoutCell(LayoutCell const &); - LayoutCell &operator=(LayoutCell const &); - - union - { - Widget *mWidget; - LayoutArray *mArray; - }; - - /** - * Returns the embedded array. Creates it if the cell does not contain - * anything yet. Aborts if it contains a widget. - */ - LayoutArray &getArray(); - - /** - * @see LayoutArray::reflow - */ - void reflow(int nx, int ny, int nw, int nh); - - int mSize[2]; - int mHPadding; - int mVPadding; - int mExtent[2]; - Alignment mAlign[2]; - int mNbFill[2]; - int mType; -}; - -/** * 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. |