widget Class Reference

#include <widget.hpp>

Inheritance diagram for widget:

Inheritance graph
[legend]
Collaboration diagram for widget:

Collaboration graph
[legend]

List of all members.


Detailed Description

Definition at line 53 of file widget.hpp.


Event callbacks

typedef bool(* event_handler )(widget *this_widget, const SDL_Event &)
event_handlerget_event_handler ()
 The event handler pointer is provided to override the default event handler of a particular widget object without needing to go to the trouble of creating a whole new derived class.

Public Types

enum  widget_flags { NO_FLAGS = 0, WIDGET_INVISIBLE = (1 << 0), WIDGET_INACTIVE = (1 << 1), WIDGET_CAN_FOCUS = (1 << 2) }

Public Member Functions

void add_child (widget *)
virtual void draw ()
virtual bool handle_event (const SDL_Event &)
void remove_child (widget *)
 widget (widget *parent, const int x, const int y, const int w, const int h, const platform::color &foreground, const platform::color &background)
virtual ~widget ()
Utilities
bool button_down_here (int button)
 Determines whether or not the latest mouse-down was in this widget.
void draw_box (int x, int y, int w, int h)
 Draws a box (in local coordinates).
void draw_line (int x0, int y0, int x1, int y1)
 Draws a line (in local coordinates).
void get_abs (int &x, int &y)
 Transforms the given local coordinates to absolute window coordinates.
void get_local (int &x, int &y)
 Transforms the given absolute window coordinates into local widget coordinates.
Accessors
platform::colorget_background ()
data::simple_stack< widget * > & get_children ()
gsgl::flags_tget_flags ()
platform::colorget_foreground ()
int & get_h ()
widget *& get_next_tab ()
widgetget_parent ()
widget *& get_prev_tab ()
platform::texture *& get_texture ()
int & get_w ()
int & get_x ()
int & get_y ()
void set_flags (const gsgl::flags_t f, bool flag_on)

Private Attributes

platform::color background
data::simple_stack< widget * > children
gsgl::flags_t flags
platform::color foreground
int h
event_handler handler
widgetnext_tab
widgetparent
widgetprev_tab
platform::texturetex
int w
int x
int y

Member Typedef Documentation

typedef bool(* event_handler)(widget *this_widget, const SDL_Event &)


Member Enumeration Documentation

Enumerator:
NO_FLAGS 
WIDGET_INVISIBLE  The widget is invisible but still active.
WIDGET_INACTIVE  The widget is neither visible nor active.
WIDGET_CAN_FOCUS  The widget is capable of handling keyboard events.

Definition at line 66 of file widget.hpp.


Constructor & Destructor Documentation

widget ( widget parent,
const int  x,
const int  y,
const int  w,
const int  h,
const platform::color foreground,
const platform::color background 
)

Definition at line 49 of file widget.cpp.

References widget::add_child().

~widget (  )  [virtual]

Definition at line 57 of file widget.cpp.

References widget::children.


Member Function Documentation

void add_child ( widget child  ) 

Definition at line 73 of file widget.cpp.

References widget::children, and widget::parent.

Referenced by tabbox::add_tab(), and widget::widget().

bool button_down_here ( int  button  ) 

Determines whether or not the latest mouse-down was in this widget.

Definition at line 156 of file widget.cpp.

References widget::get_h(), widget::get_local(), widget::get_w(), and singleton::global_instance().

Referenced by treebox_node::handle_event(), and button::handle_event().

void draw (  )  [virtual]

void draw_box ( int  x,
int  y,
int  w,
int  h 
)

Draws a box (in local coordinates).

Definition at line 179 of file widget.cpp.

References display::draw_rectangle(), and widget::get_abs().

void draw_line ( int  x0,
int  y0,
int  x1,
int  y1 
)

Draws a line (in local coordinates).

Definition at line 167 of file widget.cpp.

References widget::get_abs().

void get_abs ( int &  x,
int &  y 
)

Transforms the given local coordinates to absolute window coordinates.

Definition at line 124 of file widget.cpp.

References widget::parent, and widget::w.

Referenced by widget::draw_box(), and widget::draw_line().

platform::color& get_background (  )  [inline]

Definition at line 96 of file widget.hpp.

Referenced by tabbox::add_tab(), and button::draw().

data::simple_stack<widget *>& get_children (  )  [inline]

event_handler& get_event_handler (  )  [inline]

The event handler pointer is provided to override the default event handler of a particular widget object without needing to go to the trouble of creating a whole new derived class.

If the event handler is non-null, it will be called instead of handle_event(); if it returns false, then handle_event() will be called as well.

Definition at line 114 of file widget.hpp.

Referenced by application::handle_ui_event().

gsgl::flags_t& get_flags (  )  [inline]

Definition at line 81 of file widget.hpp.

Referenced by textbox::draw(), application::draw_ui(), and application::handle_ui_event().

platform::color& get_foreground (  )  [inline]

int& get_h (  )  [inline]

void get_local ( int &  x,
int &  y 
)

Transforms the given absolute window coordinates into local widget coordinates.

Definition at line 140 of file widget.cpp.

References widget::w.

Referenced by widget::button_down_here(), and tabbox::handle_event().

widget* & get_next_tab (  )  [inline]

Definition at line 84 of file widget.hpp.

widget* get_parent (  )  [inline]

Definition at line 87 of file widget.hpp.

widget* & get_prev_tab (  )  [inline]

Definition at line 85 of file widget.hpp.

platform::texture* & get_texture (  )  [inline]

Definition at line 97 of file widget.hpp.

int& get_w (  )  [inline]

int& get_x (  )  [inline]

int& get_y (  )  [inline]

bool handle_event ( const SDL_Event &  e  )  [virtual]

Reimplemented in button, tabbox, treebox_plus, and treebox_node.

Definition at line 117 of file widget.cpp.

Referenced by application::handle_ui_event().

void remove_child ( widget child  ) 

Definition at line 80 of file widget.cpp.

References widget::children, and widget::parent.

Referenced by treebox::clear_tree_nodes(), and treebox_node::clear_tree_nodes().

void set_flags ( const gsgl::flags_t  f,
bool  flag_on 
)


Member Data Documentation

Definition at line 62 of file widget.hpp.

Referenced by widget::draw().

Definition at line 59 of file widget.hpp.

Referenced by widget::add_child(), widget::remove_child(), and widget::~widget().

gsgl::flags_t flags [private]

Definition at line 56 of file widget.hpp.

Referenced by widget::set_flags().

Definition at line 62 of file widget.hpp.

int h [private]

Definition at line 61 of file widget.hpp.

Referenced by widget::draw().

Definition at line 139 of file widget.hpp.

Referenced by button::set_on_click_handler().

widget * next_tab [private]

Definition at line 58 of file widget.hpp.

widget* parent [private]

Definition at line 58 of file widget.hpp.

Referenced by widget::add_child(), widget::get_abs(), and widget::remove_child().

widget * prev_tab [private]

Definition at line 58 of file widget.hpp.

platform::texture* tex [private]

Definition at line 63 of file widget.hpp.

Referenced by widget::draw().

int w [private]

Definition at line 61 of file widget.hpp.

Referenced by widget::draw(), widget::get_abs(), and widget::get_local().

int x [private]

Definition at line 61 of file widget.hpp.

Referenced by textbox::draw(), and application::handle_ui_event().

int y [private]

Definition at line 61 of file widget.hpp.

Referenced by textbox::draw().


The documentation for this class was generated from the following files:

Generated on Sat Mar 1 13:50:06 2008 for Periapsis Project by  doxygen 1.5.5