summaryrefslogtreecommitdiff
path: root/src/gui/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/widgets')
-rw-r--r--src/gui/widgets/setuptab.h4
-rw-r--r--src/gui/widgets/setuptabscroll.cpp64
-rw-r--r--src/gui/widgets/setuptabscroll.h28
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