Foundation classes for a basic GUI implementing simple widgets and events

Dependents:   TouchScreenGUIDemo

Revision:
18:d849f3ada858
Parent:
16:e9a771ecfdbe
--- a/Widgets/Widget.h	Sun May 22 16:35:23 2016 +0000
+++ b/Widgets/Widget.h	Sat May 28 14:50:14 2016 +0000
@@ -32,9 +32,7 @@
     
     /********************************************************
     * Common Widget methods
-    ********************************************************/
-    virtual bool isEventTarget(Event e);
-    
+    ********************************************************/    
     virtual void setLocation(int x, int y);
     virtual void setSize(int width, int height);
     virtual void setWidth(int width);
@@ -64,8 +62,12 @@
     void hide();
     bool isHidden();
     
-    void setEventHandler(EventHandler *handler);
-    void unsetEventHandler(EventHandler *handler);
+    /**
+    * Implementation of EventListener
+    **/
+    virtual void handleEvent(Event e);
+    virtual void setEventHandler(EventHandler *handler);
+    virtual void unsetEventHandler(EventHandler *handler);
     
     bool intersects(Widget *widget);
 
@@ -91,6 +93,9 @@
     * Convenience method
     **/
     GraphicsDisplay *display();
+    virtual void _reenumerateEvents();
+    virtual void _reenumerateHandledEvents();
+    virtual uint16_t _getHandledEvents();
     
 protected:
 
@@ -101,6 +106,12 @@
     virtual void _damage();
     virtual void _adjust();
     
+    /**
+    * Methods to help with event handling
+    **/
+    bool _isEventTarget(Event e);
+    
+    uint16_t _handledEvents;
     
     Widget* _parent;
     GraphicsContext* _context;
@@ -122,6 +133,8 @@
 
     bool _damaged;
     bool _damaging;
+    
+    LinkedList<EventHandler> _handlers;
 };
 
 #endif
\ No newline at end of file