Foundation classes for a basic GUI implementing simple widgets and events. (Fork for custom changes.)

Fork of SimpleGUI by Duncan McIntyre

Revision:
12:63db16fea709
Parent:
0:0a590815d51c
--- a/Events/EventHandler.h	Fri Apr 22 16:12:42 2016 +0000
+++ b/Events/EventHandler.h	Sun May 08 14:42:08 2016 +0000
@@ -2,20 +2,44 @@
 #define SIMPLEGUI_EVENT_HANDLER_H
 
 #include "Event.h"
+#include "EventHandlerFunction.h"
 
-typedef void (* EventHandler)(Event e, EventListener* target);
-
-class EventHandlerWrapper {
+class EventHandler {
     
     public:
 
-    EventHandlerWrapper(uint8_t eventType, EventHandler h) : type(eventType), handler(h), prev(NULL), next(NULL) {}
+    EventHandler(EventType eventType, EventHandlerFunction fn) : type(eventType)
+    {
+        _fp.attach(fn);
+    }
+    
     
-    uint8_t type;
-    EventHandler handler;
-    EventHandlerWrapper* prev;
-    EventHandlerWrapper* next;
+    template<typename T>
+    EventHandler(EventType eventType, T* tptr, void (T::*mptr)(Event)) : type(eventType)
+    {
+        _fp.attach(tptr, mptr);
+    }
+    
+    void handle(Event e) {
+        _fp.call(e);
+    }
+    
+    EventType type;
+    FunctionPointerArg1<void,Event> _fp;
 };
 
+class EventHandlerList {
+    
+    public:
+    
+    EventHandlerList(EventHandler* eventHandler) : handler(eventHandler), next(NULL), prev(NULL)
+    {
+    }
+    
+    EventHandler *handler;
+    EventHandlerList *next;
+    EventHandlerList *prev;
+
+};
 
 #endif
\ No newline at end of file