summaryrefslogtreecommitdiff
path: root/src/gui/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/widgets')
-rw-r--r--src/gui/widgets/container.cpp25
-rw-r--r--src/gui/widgets/container.h24
-rw-r--r--src/gui/widgets/layouthelper.cpp5
-rw-r--r--src/gui/widgets/layouthelper.h4
-rw-r--r--src/gui/widgets/setuptab.cpp1
-rw-r--r--src/gui/widgets/vertcontainer.h2
6 files changed, 51 insertions, 10 deletions
diff --git a/src/gui/widgets/container.cpp b/src/gui/widgets/container.cpp
index af4f0155..e1b99af7 100644
--- a/src/gui/widgets/container.cpp
+++ b/src/gui/widgets/container.cpp
@@ -21,7 +21,10 @@
#include "gui/widgets/container.h"
-Container::Container()
+#include "gui/widgets/layouthelper.h"
+
+Container::Container():
+ mLayoutHelper(0)
{
setOpaque(false);
}
@@ -30,4 +33,24 @@ Container::~Container()
{
while (!mWidgets.empty())
delete mWidgets.front();
+
+ delete mLayoutHelper;
+}
+
+Layout &Container::getLayout()
+{
+ if (!mLayoutHelper)
+ mLayoutHelper = new LayoutHelper(this);
+ return mLayoutHelper->getLayout();
+}
+
+LayoutCell &Container::place(int x, int y, gcn::Widget *wg, int w, int h)
+{
+ add(wg);
+ return getLayout().place(wg, x, y, w, h);
+}
+
+ContainerPlacer Container::getPlacer(int x, int y)
+{
+ return ContainerPlacer(this, &getLayout().at(x, y));
}
diff --git a/src/gui/widgets/container.h b/src/gui/widgets/container.h
index e582f2a8..46b719a1 100644
--- a/src/gui/widgets/container.h
+++ b/src/gui/widgets/container.h
@@ -24,6 +24,11 @@
#include <guichan/widgets/container.hpp>
+class ContainerPlacer;
+class Layout;
+class LayoutCell;
+class LayoutHelper;
+
/**
* A widget container.
*
@@ -38,6 +43,25 @@ class Container : public gcn::Container
public:
Container();
~Container();
+
+ protected:
+ /**
+ * Gets the layout handler for this container.
+ */
+ Layout &getLayout();
+
+ /**
+ * Adds a widget to the container and sets it at given cell.
+ */
+ LayoutCell &place(int x, int y, gcn::Widget *wg, int w = 1, int h = 1);
+
+ /**
+ * Returns a proxy for adding widgets in an inner table of the layout.
+ */
+ ContainerPlacer getPlacer(int x, int y);
+
+ private:
+ LayoutHelper *mLayoutHelper;
};
#endif
diff --git a/src/gui/widgets/layouthelper.cpp b/src/gui/widgets/layouthelper.cpp
index 1a634fcd..e1006bd9 100644
--- a/src/gui/widgets/layouthelper.cpp
+++ b/src/gui/widgets/layouthelper.cpp
@@ -32,11 +32,6 @@ LayoutHelper::~LayoutHelper()
mContainer->removeWidgetListener(this);
}
-Layout &LayoutHelper::getLayout()
-{
- return mLayout;
-}
-
LayoutCell &LayoutHelper::place(int x, int y, gcn::Widget *wg, int w, int h)
{
mContainer->add(wg);
diff --git a/src/gui/widgets/layouthelper.h b/src/gui/widgets/layouthelper.h
index 055e6fa6..b8512212 100644
--- a/src/gui/widgets/layouthelper.h
+++ b/src/gui/widgets/layouthelper.h
@@ -34,14 +34,14 @@
class LayoutHelper : public gcn::WidgetListener
{
public:
- LayoutHelper(gcn::Container *container);
+ explicit LayoutHelper(gcn::Container *container);
~LayoutHelper();
/**
* Gets the layout handler.
*/
- Layout &getLayout();
+ Layout &getLayout() { return mLayout; }
/**
* Computes the position of the widgets according to the current
diff --git a/src/gui/widgets/setuptab.cpp b/src/gui/widgets/setuptab.cpp
index a1a493ad..dc183a50 100644
--- a/src/gui/widgets/setuptab.cpp
+++ b/src/gui/widgets/setuptab.cpp
@@ -23,5 +23,4 @@
SetupTab::SetupTab()
{
- setOpaque(false);
}
diff --git a/src/gui/widgets/vertcontainer.h b/src/gui/widgets/vertcontainer.h
index 10bc68c3..c2403afb 100644
--- a/src/gui/widgets/vertcontainer.h
+++ b/src/gui/widgets/vertcontainer.h
@@ -28,7 +28,7 @@
/**
* A widget container.
*
- * This container places it's contents veritcally.
+ * This container places its contents vertically.
*/
class VertContainer : public Container, public gcn::WidgetListener
{