From 5f11ca70fa1f5a062bd4bb27cb2db2752f7c9a56 Mon Sep 17 00:00:00 2001 From: "simon.kagstrom" Date: Sat, 2 Jan 2010 16:04:50 +0000 Subject: [PATCH] Forgot these --- gui_view.hh | 22 ++++++++++++++++++++++ listener.cpp | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 gui_view.hh create mode 100644 listener.cpp diff --git a/gui_view.hh b/gui_view.hh new file mode 100644 index 0000000..bb7fa94 --- /dev/null +++ b/gui_view.hh @@ -0,0 +1,22 @@ +#ifndef __GUI_VIEW_HH__ +#define __GUI_VIEW_HH__ + +#include + +#include "widget.hh" + +class GuiView : public Widget +{ +public: + GuiView(); + + virtual void updateTheme(); + + virtual void viewPushCallback(); + + virtual void viewPopCallback(); + + virtual void draw(SDL_Surface *where) = 0; +}; + +#endif /* __GUI_VIEW_HH__ */ diff --git a/listener.cpp b/listener.cpp new file mode 100644 index 0000000..3949c9a --- /dev/null +++ b/listener.cpp @@ -0,0 +1,38 @@ +#include "listener.hh" +#include "utils.hh" + +ListenerManager::ListenerManager() +{ + printf("Flushing listeners\n"); + this->flushListeners(); +} + +void ListenerManager::registerListener(Listener *kl) +{ + int n_listeners = sizeof(this->listeners) / sizeof(*this->listeners); + int i; + + /* Don't register already registered listeners */ + for (i = 0; i < n_listeners; i++) + if (this->listeners[i] == kl) + return; + /* Find a free spot */ + for (i = 0; i < n_listeners; i++) + if (!this->listeners[i]) + break; + + panic_if(i == n_listeners, + "No free listeners!\n"); + this->listeners[i] = kl; +} + +void ListenerManager::unregisterListener(Listener *kl) +{ + int n_listeners = sizeof(this->listeners) / sizeof(*this->listeners); + + for (int i = 0; i < n_listeners; i++) + { + if (this->listeners[i] == kl) + this->listeners[i] = NULL; + } +}