From b417df720584c101f3799874a0c836a543a8d0a8 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sun, 12 Oct 2008 14:55:10 +0000 Subject: user interface updates, work-in-progress --- src/ui/button.h | 45 +++++++++++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 16 deletions(-) (limited to 'src/ui/button.h') diff --git a/src/ui/button.h b/src/ui/button.h index c074467..b1bb522 100644 --- a/src/ui/button.h +++ b/src/ui/button.h @@ -10,32 +10,45 @@ #include #include "ui/label.h" -namespace ui { +namespace ui +{ -class Button : public Label { +class Button : public Label +{ public: - Button (Widget *parent, const char *text=0, const char *command=0); + Button(Widget *parent, const char *text=0, const char *command=0); ~Button(); - - void set_command(std::string const &command); + + /// set the command this button will execute + void set_command(const std::string &command); + + /// set the command this button will execute void set_command(const char *command); - - inline std::string const & command() const { return button_command; } - + + /// the command this button executes + inline const std::string & command() const { + return button_command; + } + /// print button description - virtual void print(size_t indent); - - /// handle keyboard events - virtual bool keypress(unsigned int key, unsigned int modifier); - virtual bool keyrelease(unsigned int key, unsigned int modifier); - + virtual void print(const size_t indent) const; + + /// called when the mouse enters the widget + virtual void on_mouseover(const math::Vector2f &cursor); + + /// called when the widget receives a key press + virtual bool on_keypress(const int key, const unsigned int modifier); + + /// called when the widget receives a key release + virtual bool on_keyrelease(const int key, const unsigned int modifier); + protected: /// draw the button border virtual void draw_border(); - + /// draw the button text virtual void draw_text(); - + private: std::string button_command; }; -- cgit v1.2.3