summaryrefslogtreecommitdiff
path: root/src/gui/widgets/vertcontainer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/widgets/vertcontainer.cpp')
-rw-r--r--src/gui/widgets/vertcontainer.cpp43
1 files changed, 34 insertions, 9 deletions
diff --git a/src/gui/widgets/vertcontainer.cpp b/src/gui/widgets/vertcontainer.cpp
index d4cf0a13f..6f94df535 100644
--- a/src/gui/widgets/vertcontainer.cpp
+++ b/src/gui/widgets/vertcontainer.cpp
@@ -23,23 +23,45 @@
#include "debug.h"
-VertContainer::VertContainer(int spacing):
- mSpacing(spacing),
- mCount(0)
+VertContainer::VertContainer(int verticalItemSize, bool resizable,
+ int leftSpacing):
+ mVerticalItemSize(verticalItemSize),
+ mCount(0),
+ mNextY(0),
+ mLeftSpacing(leftSpacing),
+ mVerticalSpacing(0),
+ mResizable(resizable)
{
addWidgetListener(this);
}
-void VertContainer::add(gcn::Widget *widget)
+void VertContainer::add(gcn::Widget *widget, int spacing)
+{
+ add(widget, mResizable, spacing);
+}
+
+void VertContainer::add(gcn::Widget *widget, bool resizable, int spacing)
{
if (!widget)
return;
Container::add(widget);
- widget->setPosition(0, mCount * mSpacing);
- widget->setSize(getWidth(), mSpacing);
- mCount++;
- setHeight(mCount * mSpacing);
+ widget->setPosition(mLeftSpacing, mNextY);
+ if (resizable)
+ {
+ widget->setSize(getWidth() - mLeftSpacing, mVerticalItemSize);
+ mResizableWidgets.push_back(widget);
+ }
+ else if (widget->getHeight() > mVerticalItemSize)
+ {
+ widget->setSize(widget->getWidth(), mVerticalItemSize);
+ }
+
+ if (spacing == -1)
+ mNextY += mVerticalItemSize + (mVerticalSpacing * 2);
+ else
+ mNextY += mVerticalItemSize + (spacing * 2);
+ setHeight(mNextY);
}
void VertContainer::clear()
@@ -51,6 +73,9 @@ void VertContainer::clear()
void VertContainer::widgetResized(const gcn::Event &event _UNUSED_)
{
- for (WidgetListIterator it = mWidgets.begin(); it != mWidgets.end(); it++)
+ for (WidgetListIterator it = mResizableWidgets.begin();
+ it != mResizableWidgets.end(); it++)
+ {
(*it)->setWidth(getWidth());
+ }
}