diff options
author | Andrei Karas <akaras@inbox.ru> | 2011-04-05 17:47:46 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2011-06-19 18:46:08 +0300 |
commit | 40764f894c6ef0def1d0eb0677d064da13701bcd (patch) | |
tree | 4400b0b56d20ebb3e66187990a01615a0c2adb3a /src/gui/widgets | |
parent | 0b31fa647c786513c9addc5f8c55708f05226e03 (diff) | |
download | manaverse-40764f894c6ef0def1d0eb0677d064da13701bcd.tar.gz manaverse-40764f894c6ef0def1d0eb0677d064da13701bcd.tar.bz2 manaverse-40764f894c6ef0def1d0eb0677d064da13701bcd.tar.xz manaverse-40764f894c6ef0def1d0eb0677d064da13701bcd.zip |
Redesign Misc setup page.
Diffstat (limited to 'src/gui/widgets')
-rw-r--r-- | src/gui/widgets/setuptab.h | 4 | ||||
-rw-r--r-- | src/gui/widgets/setuptabscroll.cpp | 64 | ||||
-rw-r--r-- | src/gui/widgets/setuptabscroll.h | 28 |
3 files changed, 94 insertions, 2 deletions
diff --git a/src/gui/widgets/setuptab.h b/src/gui/widgets/setuptab.h index 73788ff6d..ddc0c8958 100644 --- a/src/gui/widgets/setuptab.h +++ b/src/gui/widgets/setuptab.h @@ -25,12 +25,14 @@ #include "gui/widgets/container.h" +#include <guichan/actionlistener.hpp> + #include <string> /** * A container for the contents of a tab in the setup window. */ -class SetupTab : public Container +class SetupTab : public Container, public gcn::ActionListener { public: SetupTab(); diff --git a/src/gui/widgets/setuptabscroll.cpp b/src/gui/widgets/setuptabscroll.cpp index c46ebaf97..ece4fef8f 100644 --- a/src/gui/widgets/setuptabscroll.cpp +++ b/src/gui/widgets/setuptabscroll.cpp @@ -20,6 +20,8 @@ #include "gui/widgets/setuptabscroll.h" +#include "gui/setupitem.h" + #include "gui/widgets/layouthelper.h" #include "gui/widgets/scrollarea.h" #include "gui/widgets/vertcontainer.h" @@ -42,8 +44,68 @@ SetupTabScroll::SetupTabScroll() : SetupTabScroll::~SetupTabScroll() { -// delete mScroll; mScroll = 0; + delete mContainer; mContainer = 0; + + std::set<SetupItem*>::iterator it = mAllItems.begin(); + std::set<SetupItem*>::iterator it_end = mAllItems.end(); + while (it != it_end) + { + delete *it; + ++ it; + } + mAllItems.clear(); +} + +void SetupTabScroll::addControl(SetupItem *widget) +{ + std::map<std::string,SetupItem*>::iterator iter + = mItems.find(widget->getActionEventId()); + if (iter != mItems.end()) + { + delete (*iter).second; + mItems.erase(iter); + } + mItems[widget->getActionEventId()] = widget; + mAllItems.insert(widget); +} + +void SetupTabScroll::addControl(SetupItem *widget, std::string event) +{ + std::map<std::string,SetupItem*>::iterator iter + = mItems.find(event); + if (iter != mItems.end()) + { + delete (*iter).second; + mItems.erase(iter); + } + mItems[event] = widget; + mAllItems.insert(widget); +} + +void SetupTabScroll::apply() +{ + std::map<std::string,SetupItem*>::iterator iter; + for (iter = mItems.begin(); iter != mItems.end(); ++ iter) + (*iter).second->apply((*iter).first); +} + +void SetupTabScroll::cancel() +{ + std::map<std::string,SetupItem*>::iterator iter; + for (iter = mItems.begin(); iter != mItems.end(); ++ iter) + (*iter).second->cancel((*iter).first); +} + +void SetupTabScroll::externalUpdated() +{ + std::map<std::string,SetupItem*>::iterator iter; + for (iter = mItems.begin(); iter != mItems.end(); ++ iter) + { + SetupItem *widget = (*iter).second; + if (!widget->isMainConfig()) + (*iter).second->externalUpdated((*iter).first); + } } diff --git a/src/gui/widgets/setuptabscroll.h b/src/gui/widgets/setuptabscroll.h index 83a5e272c..119756969 100644 --- a/src/gui/widgets/setuptabscroll.h +++ b/src/gui/widgets/setuptabscroll.h @@ -23,6 +23,16 @@ #include "gui/widgets/setuptab.h" +#include <map> +#include <set> + +#ifdef __GNUC__ +#define _UNUSED_ __attribute__ ((unused)) +#else +#define _UNUSED_ +#endif + +class SetupItem; class ScrollArea; class VertContainer; @@ -33,9 +43,27 @@ class SetupTabScroll : public SetupTab ~SetupTabScroll(); + void addControl(SetupItem *widget); + + void addControl(SetupItem *widget, std::string event); + + VertContainer *getContainer() + { return mContainer; } + + virtual void apply(); + + virtual void cancel(); + + virtual void externalUpdated(); + + virtual void action(const gcn::ActionEvent &event _UNUSED_) + { } + protected: VertContainer *mContainer; ScrollArea *mScroll; + std::map<std::string,SetupItem*> mItems; + std::set<SetupItem*> mAllItems; }; #endif |