diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2009-04-10 02:20:04 +0200 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2009-04-10 02:27:44 +0200 |
commit | 33afe8f744587b9a8da67e85298bb2e1c28d083d (patch) | |
tree | 807981f32e1f73da6f8719631b46fd493a0e7ae3 /src/gui | |
parent | 07e8a1b8408ed40cbf2031476627647057f62141 (diff) | |
download | mana-client-33afe8f744587b9a8da67e85298bb2e1c28d083d.tar.gz mana-client-33afe8f744587b9a8da67e85298bb2e1c28d083d.tar.bz2 mana-client-33afe8f744587b9a8da67e85298bb2e1c28d083d.tar.xz mana-client-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')
-rw-r--r-- | src/gui/guildwindow.cpp | 1 | ||||
-rw-r--r-- | src/gui/guildwindow.h | 8 | ||||
-rw-r--r-- | src/gui/setuptab.h | 4 | ||||
-rw-r--r-- | src/gui/skilldialog.cpp | 5 | ||||
-rw-r--r-- | src/gui/widgets/avatar.h | 4 | ||||
-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.cpp | 7 | ||||
-rw-r--r-- | src/gui/widgets/popup.h | 4 | ||||
-rw-r--r-- | src/gui/widgets/window.cpp | 6 | ||||
-rw-r--r-- | src/gui/widgets/windowcontainer.h | 4 |
11 files changed, 21 insertions, 80 deletions
diff --git a/src/gui/guildwindow.cpp b/src/gui/guildwindow.cpp index 91759687..020edf44 100644 --- a/src/gui/guildwindow.cpp +++ b/src/gui/guildwindow.cpp @@ -80,7 +80,6 @@ GuildWindow::GuildWindow(): GuildWindow::~GuildWindow() { - delete mGuildTabs; } void GuildWindow::update() diff --git a/src/gui/guildwindow.h b/src/gui/guildwindow.h index 3d7ac3ea..15f35b00 100644 --- a/src/gui/guildwindow.h +++ b/src/gui/guildwindow.h @@ -38,20 +38,12 @@ class TextDialog; class ConfirmDialog; class GuildListBox; class ScrollArea; -class GCContainer; class TabbedArea; class GuildWindow : public Window, public gcn::ActionListener { public: - /** - * Constructor. - */ GuildWindow(); - - /** - * Destructor. - */ ~GuildWindow(); /** diff --git a/src/gui/setuptab.h b/src/gui/setuptab.h index 7b92e2fe..f0af1ea9 100644 --- a/src/gui/setuptab.h +++ b/src/gui/setuptab.h @@ -22,14 +22,14 @@ #ifndef GUI_SETUPTAB_H #define GUI_SETUPTAB_H -#include "gui/widgets/gccontainer.h" +#include "gui/widgets/container.h" #include <string> /** * A container for the contents of a tab in the setup window. */ -class SetupTab : public GCContainer +class SetupTab : public Container { public: SetupTab(); diff --git a/src/gui/skilldialog.cpp b/src/gui/skilldialog.cpp index 5788aa99..c3ff1ded 100644 --- a/src/gui/skilldialog.cpp +++ b/src/gui/skilldialog.cpp @@ -22,7 +22,7 @@ #include "gui/skilldialog.h" #include "gui/widgets/button.h" -#include "gui/widgets/gccontainer.h" +#include "gui/widgets/container.h" #include "gui/widgets/icon.h" #include "gui/widgets/label.h" #include "gui/widgets/listbox.h" @@ -40,7 +40,7 @@ #include <string> #include <vector> -class SkillTab : public GCContainer, public gcn::ActionListener +class SkillTab : public Container, public gcn::ActionListener { public: /** @@ -197,7 +197,6 @@ SkillTab::SkillTab(const std::string &type): type(type) } update(); - } int SkillTab::getSkillNum() 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: /** |