From 02fcd22d8cde355aa898a8c6bb4773d9434b8e9a Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Fri, 10 Oct 2008 16:41:38 +0000 Subject: adds KeyPress, DevInfo and Stats widgets --- src/ui/widget.h | 44 ++++++++++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 16 deletions(-) (limited to 'src/ui/widget.h') diff --git a/src/ui/widget.h b/src/ui/widget.h index 54c8d96..2078134 100644 --- a/src/ui/widget.h +++ b/src/ui/widget.h @@ -17,6 +17,7 @@ #include "math/vector2f.h" #include "ui/font.h" #include "ui/palette.h" +#include "ui/definitions.h" #include "sys/sys.h" namespace ui { @@ -66,18 +67,30 @@ public: /* -- mutators --------------------------------------------- */ + /// raise the widget to the top of the widget stack + void raise(); + + /// lower the widget to the bottom of the widget stack + void lower(); + /// show the widget void show(); /// hide the widget void hide(); + /// set visibility + void set_visible(bool visible = true); + /// set location of the top-left corner void set_location(float const x, float const y); /// set the widgets width and height void set_size(float const w, float const h); + /// set the widgets width and height + void set_size(math::Vector2f const &size); + /// set the widgets width void set_width(float const w); @@ -106,24 +119,28 @@ public: /// draw event virtual void event_draw(); - /// handle mouse movement - virtual void mousemove(float x, float y); - - /// handle keyboard events - virtual void keypress(unsigned int key, unsigned int modifier); + /// keyboard event + virtual bool event_key(bool pressed, unsigned int key, unsigned int modifier); - virtual void keyrelease(unsigned int key, unsigned int modifier); + /// find the child widget with focus + /** @param pos local position within the widget + */ + Widget *event_focus(math::Vector2f const & pos); /// child widgets inline Children &children() { return widget_children; } - /// raise the widget to the top of the widget stack - void raise(); +protected: + /// handle keyboard events + /** returns true if the event was handled by this widget + */ + virtual bool keypress(unsigned int key, unsigned int modifier); - /// lower the widget to the bottom of the widget stack - void lower(); + /// handle keyboard events + /** returns true if the event was handled by this widget + */ + virtual bool keyrelease(unsigned int key, unsigned int modifier); -protected: /// draw the widget virtual void draw(); @@ -179,11 +196,6 @@ protected: /// remove a child widget void remove_child(Widget *child); - /// find the child widget with focus - /** @param pos local position within the widget - */ - Widget *find_focus(math::Vector2f const & pos); - private: bool widget_visible; bool widget_background; -- cgit v1.2.3