summaryrefslogtreecommitdiff
path: root/src/gui/widgets
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2009-04-10 02:20:04 +0200
committerBjørn Lindeijer <bjorn@lindeijer.nl>2009-04-10 02:27:44 +0200
commit33afe8f744587b9a8da67e85298bb2e1c28d083d (patch)
tree807981f32e1f73da6f8719631b46fd493a0e7ae3 /src/gui/widgets
parent07e8a1b8408ed40cbf2031476627647057f62141 (diff)
downloadmana-33afe8f744587b9a8da67e85298bb2e1c28d083d.tar.gz
mana-33afe8f744587b9a8da67e85298bb2e1c28d083d.tar.bz2
mana-33afe8f744587b9a8da67e85298bb2e1c28d083d.tar.xz
mana-33afe8f744587b9a8da67e85298bb2e1c28d083d.zip
Reduced the GCContainer to be even more trivial
A container that deletes all its children on destruction doesn't have to be so complicated. Also renamed it to simply Container, since I think it should simply be default behavior. WindowContainer and Popup classes now inherit from this Container.
Diffstat (limited to 'src/gui/widgets')
-rw-r--r--src/gui/widgets/avatar.h4
-rw-r--r--src/gui/widgets/container.cpp (renamed from src/gui/widgets/gccontainer.cpp)34
-rw-r--r--src/gui/widgets/container.h (renamed from src/gui/widgets/gccontainer.h)24
-rw-r--r--src/gui/widgets/popup.cpp7
-rw-r--r--src/gui/widgets/popup.h4
-rw-r--r--src/gui/widgets/window.cpp6
-rw-r--r--src/gui/widgets/windowcontainer.h4
7 files changed, 17 insertions, 66 deletions
diff --git a/src/gui/widgets/avatar.h b/src/gui/widgets/avatar.h
index d1380bfd..550e43b4 100644
--- a/src/gui/widgets/avatar.h
+++ b/src/gui/widgets/avatar.h
@@ -24,14 +24,14 @@
#include "guichanfwd.h"
-#include "gui/widgets/gccontainer.h"
+#include "gui/widgets/container.h"
#include <string>
class Image;
class Icon;
-class Avatar : public GCContainer
+class Avatar : public Container
{
public:
/**
diff --git a/src/gui/widgets/gccontainer.cpp b/src/gui/widgets/container.cpp
index 8325ccd4..10ef78a5 100644
--- a/src/gui/widgets/gccontainer.cpp
+++ b/src/gui/widgets/container.cpp
@@ -19,36 +19,10 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include "gccontainer.h"
+#include "gui/widgets/container.h"
-GCContainer::~GCContainer()
+Container::~Container()
{
- WidgetIterator i = mDeathList.begin();
-
- while (i != mDeathList.end()) {
- /* Take care _not_ to modify the list in our _announceDeath method */
- gcn::Widget *w = (*i);
- i = mDeathList.erase(i);
- delete w;
- }
-
- mDeathList.clear();
-}
-
-void GCContainer::add(gcn::Widget *w)
-{
- mDeathList.push_back(w);
- Container::add(w);
-}
-
-void GCContainer::add(gcn::Widget *w, int x, int y)
-{
- mDeathList.push_back(w);
- Container::add(w, x, y);
-}
-
-void GCContainer::death(const gcn::Event &event)
-{
- mDeathList.remove(event.getSource());
- Container::death(event);
+ while (!mWidgets.empty())
+ delete mWidgets.front();
}
diff --git a/src/gui/widgets/gccontainer.h b/src/gui/widgets/container.h
index da584a42..a6d1610e 100644
--- a/src/gui/widgets/gccontainer.h
+++ b/src/gui/widgets/container.h
@@ -19,32 +19,20 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifndef GUI_GCCONTAINER_H
-#define GUI_GCCONTAINER_H
-
-#include <list>
+#ifndef GUI_CONTAINER_H
+#define GUI_CONTAINER_H
#include <guichan/widgets/container.hpp>
/**
- * A garbage collecting container. Childs added to this container are
+ * A widget container. The only difference between the standard Guichan
+ * container and this one is that childs added to this container are
* automatically deleted when the container is deleted.
*/
-class GCContainer : public gcn::Container
+class Container : public gcn::Container
{
public:
- virtual ~GCContainer();
-
- virtual void add(gcn::Widget *w);
-
- virtual void add(gcn::Widget *w, int x, int y);
-
- virtual void death(const gcn::Event &event);
-
- protected:
- typedef std::list<gcn::Widget*> Widgets;
- typedef Widgets::iterator WidgetIterator;
- Widgets mDeathList;
+ ~Container();
};
#endif
diff --git a/src/gui/widgets/popup.cpp b/src/gui/widgets/popup.cpp
index 9040d6b2..7d73e749 100644
--- a/src/gui/widgets/popup.cpp
+++ b/src/gui/widgets/popup.cpp
@@ -65,13 +65,6 @@ Popup::~Popup()
savePopupConfiguration();
- while (!mWidgets.empty())
- {
- gcn::Widget *w = mWidgets.front();
- remove(w);
- delete(w);
- }
-
mSkin->instances--;
}
diff --git a/src/gui/widgets/popup.h b/src/gui/widgets/popup.h
index 71ce2d89..928c8d32 100644
--- a/src/gui/widgets/popup.h
+++ b/src/gui/widgets/popup.h
@@ -23,7 +23,7 @@
#ifndef POPUP_H
#define POPUP_H
-#include <guichan/widgets/container.hpp>
+#include "gui/widgets/container.h"
#include "guichanfwd.h"
@@ -41,7 +41,7 @@ class WindowContainer;
*
* \ingroup GUI
*/
-class Popup : public gcn::Container
+class Popup : public Container
{
public:
/**
diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp
index 0aadeb3e..1d7961f3 100644
--- a/src/gui/widgets/window.cpp
+++ b/src/gui/widgets/window.cpp
@@ -97,11 +97,7 @@ Window::~Window()
delete mLayout;
while (!mWidgets.empty())
- {
- gcn::Widget *w = mWidgets.front();
- remove(w);
- delete(w);
- }
+ delete mWidgets.front();
removeWidgetListener(this);
diff --git a/src/gui/widgets/windowcontainer.h b/src/gui/widgets/windowcontainer.h
index bc918184..a2c285cb 100644
--- a/src/gui/widgets/windowcontainer.h
+++ b/src/gui/widgets/windowcontainer.h
@@ -22,7 +22,7 @@
#ifndef WINDOWCONTAINER_H
#define WINDOWCONTAINER_H
-#include <guichan/widgets/container.hpp>
+#include "gui/widgets/container.h"
/**
* A window container. This container adds functionality for more convenient
@@ -30,7 +30,7 @@
*
* \ingroup GUI
*/
-class WindowContainer : public gcn::Container
+class WindowContainer : public Container
{
public:
/**