From f030154fe727e25a2afe1f78b3998c2d2dba95e4 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Tue, 18 Aug 2009 09:24:15 +0000 Subject: astyle cleanup, corrects not loading of material textures --- src/ui/widget.h | 140 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 71 insertions(+), 69 deletions(-) (limited to 'src/ui/widget.h') diff --git a/src/ui/widget.h b/src/ui/widget.h index 20e4ac4..1f87695 100644 --- a/src/ui/widget.h +++ b/src/ui/widget.h @@ -28,28 +28,28 @@ class Widget public: /// create a new widget - Widget(Widget *parent=0); - + Widget(Widget *parent = 0); + /// destroy a widget virtual ~Widget(); - + /// parent widget this widget belongs to inline Widget *parent() const { return widget_parent; } - + /* -- inspectors -------------------------------------------- */ - + /// pixel coordinates of the top-left corner of this widget within its parent inline const math::Vector2f &location() const { return widget_location; } - + /// size of this widget in pixels inline const math::Vector2f &size() const { return widget_size; } - + /// x coordinate of the left of the widget /** * @see location() @@ -66,7 +66,7 @@ public: inline float right() const { return widget_location.x() + widget_size.width(); } - + /// y coordinate of the top of the widget /** * @see location() @@ -83,7 +83,7 @@ public: inline float bottom() const { return widget_location.y() + widget_size.height(); } - + /// width of the widget in pixels /** * @see size() @@ -91,7 +91,7 @@ public: inline float width() const { return widget_size.width(); } - + /// height of the widget in pixels /** * @see size() @@ -99,61 +99,61 @@ public: inline float height() const { return widget_size.height(); } - + /// widget label inline const std::string &label() const { return widget_label; } - + /// true if this widget will draw a background inline bool background() const { return widget_background; } - + /// true if this widget will draw a border inline bool border() const { return widget_border; } - + /// true if this widget is visible inline bool visible() const { return widget_visible; } - + /// true if this widget is not visible inline bool hidden() const { return !widget_visible; } - + /// the palette used to draw this widget const Palette *palette() const; - + /// the font used to draw this widget const Font *font() const; - + /// return true if the widget has input focus bool has_input_focus() const; - + /// returns true if the widget has mouse focus bool has_mouse_focus() const; - + /* -- 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 virtual void show(); - + /// hide the widget virtual void hide(); - + /// set visibility void set_visible(bool visible = true); - + /// set input focus void set_focus(); @@ -162,57 +162,57 @@ public: /// set the widget geometry void set_geometry(const math::Vector2f &location, const math::Vector2f &size); - + /// set location of the top-left corner, relative to the parent void set_location(const float x, const float y); - + /// set location of the top-left corner, relative to the parent void set_location(const math::Vector2f &location); - + /// set the widgets width and height void set_size(const float w, const float h); - + /// set the widgets width and height void set_size(const math::Vector2f &size); - + /// set the widgets width void set_width(const float w); - + /// set the widgets height void set_height(const float h); - + /// set the widgets palette void set_palette(const Palette *palette); - + /// set the widgets font void set_font(const Font *font); - + /// set the widgets label void set_label(std::string const &label); - + /// set the widgets label void set_label(const char *label); - + /// enable or disable widget border void set_border(bool border = true); - + ///enable or disable widget background void set_background(bool background = true); - + /* -- event distributors ----------------------------------- */ - + /// distribute resize event virtual void event_resize(); - + /// distribute draw event virtual void event_draw(); - + /// distribute keyboard events virtual 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); - + protected: /// type definition for child widgets typedef std::list Children; @@ -221,7 +221,7 @@ protected: inline Children &children() { return widget_children; } - + /// find the widget that has input focus virtual Widget *find_input_focus(); @@ -229,18 +229,20 @@ protected: /** @param cursor mouse cursor position relative to this widget's location */ Widget *find_mouse_focus(const math::Vector2f & cursor); - + /// list widget content size_t list(const size_t indent, const bool visible_only = false) const; - + /// print widget description virtual void print(const size_t indent) const; /// true of this sibling has local focus - inline bool focus() const { return widget_focus; } - + inline bool focus() const { + return widget_focus; + } + /* -- coordinate mapping ----------------------------------- */ - + /// map local coordinates to global coordinates inline math::Vector2f to_global_coords(const math::Vector2f &local) { math::Vector2f v(local); @@ -251,7 +253,7 @@ protected: } while (parent); return v; } - + /// map global coordinates to local coordinates inline math::Vector2f to_local_coords(const math::Vector2f &global) { math::Vector2f v(global); @@ -262,7 +264,7 @@ protected: } return v; } - + /// map local widget location to global location inline math::Vector2f global_location() { math::Vector2f v(widget_location); @@ -273,35 +275,35 @@ protected: } return v; } - + /* -- event handlers --------------------------------------- */ - + /// called when the mouse receives mouse movement virtual void on_mousemove(const math::Vector2f &cursor); - + /// 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); - + /* -- draw functions --------------------------------------- */ - + /// resize event virtual void resize(); - + /// draw the widget virtual void draw(); - + /// draw the widget background virtual void draw_background(); - + /// draw the widget border virtual void draw_border(); - + /// add a child widget virtual void add_child(Widget *child); @@ -310,7 +312,7 @@ protected: /// remove all child widgets virtual void remove_children(); - + private: void draw_debug_border(); @@ -318,19 +320,19 @@ private: bool widget_background; bool widget_border; bool widget_focus; - + math::Vector2f widget_location; math::Vector2f widget_size; std::string widget_label; - + Children widget_children; - + const Palette *widget_palette; const Font *widget_font; Widget *widget_parent; - + Children::iterator find_child(Widget *child); - + }; } -- cgit v1.2.3