From e55638d081e2e1ff6fbc06e0e8ac0381a04308e7 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Wed, 15 Sep 2010 21:29:18 +0000 Subject: updated comments, updated buy menu, info support for map window, added const to target selection --- src/ui/widget.h | 51 ++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 40 insertions(+), 11 deletions(-) (limited to 'src/ui/widget.h') diff --git a/src/ui/widget.h b/src/ui/widget.h index 1f87695..50678fa 100644 --- a/src/ui/widget.h +++ b/src/ui/widget.h @@ -27,6 +27,9 @@ class Widget { public: + /// types of custom events a widget can emit + enum Event {EventNone = 0, EventSelected = 1}; + /// create a new widget Widget(Widget *parent = 0); @@ -196,22 +199,45 @@ public: /// enable or disable widget border void set_border(bool border = true); - ///enable or disable widget background + /// enable or disable widget background void set_background(bool background = true); + + /// emit a custom event + void emit(const Event event, const void *data=0); - /* -- event distributors ----------------------------------- */ + /* -- event distributors --------------------------------------- */ - /// distribute resize event - virtual void event_resize(); - - /// distribute draw event - virtual void event_draw(); + /** + * @brief calls the resize event handler and sends the event to all child widgets + * @see resize + **/ + void event_resize(); + + /** + * @brief calls the draw event handler and sends the event to all child widgets + * @see draw + **/ + void event_draw(); - /// distribute keyboard events - virtual bool event_key(const bool pressed, const int key, const unsigned int modifier); + /** + * @brief calls the key event handlers and sends unhandled keys to the parent widget + * @see on_keypress + * @see on_keyrelease + **/ + bool event_key(const bool pressed, const int key, const unsigned int modifier); - /// distribute mouse movement events - virtual bool event_mouse(const math::Vector2f &cursor); + /** + * @brief calls the mouse event handlers and sends unhandled keys to the parent widget + * @see on_mousemove + * @see on_mouseover + **/ + bool event_mouse(const math::Vector2f &cursor); + + /** + * @brief calls the custom event handler and sends unhandled events to the parent widget + * @see on_event + **/ + bool event_emit(Widget *sender, const Event event, void *data = 0); protected: /// type definition for child widgets @@ -289,6 +315,9 @@ protected: /// called when the widget receives a key release virtual bool on_keyrelease(const int key, const unsigned int modifier); + + /// called when the widget receives a custom event + virtual bool on_emit(Widget *sender, const Event event, void *data=0); /* -- draw functions --------------------------------------- */ -- cgit v1.2.3