43 std::vector<int> layoutMax;
47 int visibleChilds = 0;
48 std::list<Widget*>::const_iterator currChild(
mChildren.begin());
49 std::list<Widget*>::const_iterator endChildren(
mChildren.end());
50 for (; currChild != endChildren; ++currChild) {
51 Widget* child = *currChild;
57 if (
mLayout == LayoutPolicy::Vertical) {
64 layoutMax.push_back(tmpSize);
78 layoutMax.push_back(tmpSize);
88 layoutMax.push_back(tmpSize);
96 unsigned int layout = 0;
97 if (
mLayout == LayoutPolicy::Vertical && visibleChilds > 0) {
100 for (; currChild != endChildren; ++currChild) {
101 if (!(*currChild)->isVisible()) {
104 int columnW = layoutMax[layout];
105 int const layoutW = (*currChild)->getWidth() + (*currChild)->getMarginLeft() +
106 ((*currChild)->getMarginRight() > 0 ? (*currChild)->getMarginRight() : 0);
108 (*currChild)->getMarginLeft(), (*currChild)->getMarginTop(), layoutW, (*currChild)->getHeight());
112 if (y + (*currChild)->getMarginTop() + dim.
height +
113 ((*currChild)->getMarginBottom() > 0 ? (*currChild)->getMarginBottom() : 0) >
118 columnW = layoutMax[layout];
123 case Alignment::Left:
126 case Alignment::Center:
127 dim.
x += x + (columnW - layoutW) / 2;
129 case Alignment::Right:
130 dim.
x += x + (columnW - layoutW);
133 throwException(
"Unknown alignment.");
136 (*currChild)->setDimension(dim);
137 y += (*currChild)->getHeight() + (*currChild)->getMarginTop() + (*currChild)->getMarginBottom() +
139 totalW = std::max(totalW, dim.
x + dim.
width);
140 totalH = std::max(totalH, y);
145 totalH = std::max(totalH, containerH);
147 totalW = std::max(totalW, containerW);
149 }
else if (
mLayout == LayoutPolicy::Horizontal && visibleChilds > 0) {
152 for (; currChild != endChildren; ++currChild) {
153 if (!(*currChild)->isVisible()) {
156 int rowH = layoutMax[layout];
157 int const layoutH = (*currChild)->getHeight() + (*currChild)->getMarginTop() +
158 ((*currChild)->getMarginBottom() > 0 ? (*currChild)->getMarginBottom() : 0);
160 (*currChild)->getMarginLeft(), (*currChild)->getMarginTop(), (*currChild)->getWidth(), layoutH);
164 if (x + (*currChild)->getMarginLeft() + dim.
width +
165 ((*currChild)->getMarginRight() > 0 ? (*currChild)->getMarginRight() : 0) >
170 rowH = layoutMax[layout];
178 case Alignment::Center:
179 dim.
y += y + (rowH - layoutH) / 2;
181 case Alignment::Bottom:
182 dim.
y += y + (rowH - layoutH);
185 throwException(
"Unknown alignment.");
188 (*currChild)->setDimension(dim);
189 x += (*currChild)->getWidth() + (*currChild)->getMarginLeft() + (*currChild)->getMarginRight() +
191 totalW = std::max(totalW, x);
192 totalH = std::max(totalH, dim.
y + dim.
height);
197 totalW = std::max(totalW, containerW);
199 totalH = std::max(totalH, containerH);