Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/widget.h')
-rw-r--r--src/ui/widget.h51
1 files changed, 40 insertions, 11 deletions
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 --------------------------------------- */