5#include "fifechan/widgets/adjustingcontainer.hpp"
10#include "fifechan/exception.hpp"
14 AdjustingContainer::AdjustingContainer()
23 AdjustingContainer::~AdjustingContainer() =
default;
57 return Alignment::Left;
168 unsigned int columnCount = 0;
169 unsigned int rowCount = 0;
178 for (j = 0; j < columnCount; j++) {
186 case Alignment::Left:
187 mContainedWidget->setX(basex);
189 case Alignment::Center:
190 mContainedWidget->setX(basex + ((
mColumnWidths[columnCount] - mContainedWidget->getWidth()) / 2));
192 case Alignment::Right:
193 mContainedWidget->setX(basex +
mColumnWidths[columnCount] - mContainedWidget->getWidth());
196 throwException(
"Unknown alignment.");
199 mContainedWidget->setY(y);
Alignment getColumnAlignment(unsigned int column) const
Get a specific column's alignment.
virtual void adjustContent()
Rearrange the widgets and resize the container.
unsigned int mNumberOfRows
Number of rows in the layout (derived from children count).
std::vector< Alignment > mColumnAlignment
The alignment of each column.
unsigned int mWidth
Cached container width used during layout.
std::vector< unsigned int > mColumnWidths
Computed width for each column (in pixels).
void adjustSize() override
Resizes the widget's size to fit the content exactly.
virtual void setNumberOfColumns(unsigned int numberOfColumns)
Set the number of columns to divide the widgets into.
virtual unsigned int getNumberOfColumns() const
Get the number of columns the widget is divided.
Rectangle getChildrenArea() override
Gets the area of the widget occupied by the widget's children.
virtual void setColumnAlignment(unsigned int column, Alignment alignment)
Set a specific column's alignment.
unsigned int mHeight
Cached container height used during layout.
std::vector< Widget * > mContainedWidgets
The widgets contained in the adjusting container in layout order.
unsigned int mNumberOfColumns
Number of columns in the layout.
void remove(Widget *widget) override
Removes a specific child from the widget.
Alignment
Possible alignment values for each column.
std::vector< unsigned int > mRowHeights
Computed height for each row (in pixels).
void removeAllChildren() override
Remvoes all children from the widget.
void add(Widget *widget) override
Adds a widget to the container.
void remove(Widget *widget) override
Removes a widget from the Container.
virtual void setHorizontalSpacing(unsigned int spacing)
Set the horizontal spacing between columns.
unsigned int mVerticalSpacing
VerticalSpacing.
unsigned int mHorizontalSpacing
HorizontalSpacing.
virtual void add(Widget *widget)
Adds a widget to the container.
void resizeToContent()
Resizes the widget's size to fit the content exactly, calls recursively all childs.
void removeAllChildren() override
Removes all widgets from the the container.
virtual void setVerticalSpacing(unsigned int spacing)
Set the vertical spacing between rows.
Represents a rectangular area (X, Y, Width, Height).
int width
Holds the width of the rectangle.
int y
Holds the x coordinate of the rectangle.
int x
Holds the x coordinate of the rectangle.
int height
Holds the height of the rectangle.