gui2::twidget Class Reference

Base class for all widgets. More...

#include <widget.hpp>

Inheritance diagram for gui2::twidget:

Inheritance graph
[legend]
Collaboration diagram for gui2::twidget:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 twidget ()
virtual ~twidget ()
twidgetparent ()
void set_parent (twidget *parent)
const std::string & id () const
void set_id (const std::string &id)
const std::string & definition () const
virtual void set_definition (const std::string &definition)
 This should not be changed after the widget is shown, strange things might occur.
virtual void draw (surface &)=0
 Draws a widget.
int get_x () const
int get_y () const
unsigned get_width () const
unsigned get_height () const
virtual bool dirty () const
 Is the widget dirty?
virtual tpoint get_minimum_size () const =0
 Gets the minimum size for the object, 0,0 means no size required.
virtual tpoint get_best_size () const =0
 Gets the best size for the object, 0,0 means no size required.
virtual tpoint get_maximum_size () const =0
 Gets the best size for an object, 0,0 means no limits.
virtual void set_size (const SDL_Rect &rect)
 Sets a predefined size for the object.
virtual twidgetfind_widget (const tpoint &coordinate, const bool must_be_active)
 Gets the widget at the wanted coordinates.
virtual const twidgetfind_widget (const tpoint &coordinate, const bool must_be_active) const
 The const version of find_widget.
virtual twidgetfind_widget (const std::string &id, const bool must_be_active)
 Gets a widget with the wanted id.
virtual const twidgetfind_widget (const std::string &id, const bool must_be_active) const
 The const version of find_widget.
virtual bool has_widget (const twidget *widget) const
 Does the widget contain the widget.
twindowget_window ()
 The toplevel item should always be a window if not null is returned.
virtual void load_config ()
 loads the configuration of the widget, mainly used for controls.
SDL_Rect get_rect () const
virtual bool has_vertical_scrollbar () const
 If the best size doesn't fit we want to use the best size for normal widgets, and resize those who own a scrollbar.
virtual bool has_horizontal_scrollbar () const

Protected Member Functions

virtual void set_dirty (const bool dirty=true)

Private Attributes

std::string id_
 The id is the unique name of the widget in a certain context.
std::string definition_
 The definition is the id of that widget class.
twidgetparent_
int x_
int y_
unsigned w_
unsigned h_
bool dirty_


Detailed Description

Base class for all widgets.

This is a non visible widget but it does have dimentions and size hints.

Definition at line 117 of file gui/widgets/widget.hpp.


Constructor & Destructor Documentation

gui2::twidget::twidget (  )  [inline]

Definition at line 120 of file gui/widgets/widget.hpp.

virtual gui2::twidget::~twidget (  )  [inline, virtual]

Definition at line 130 of file gui/widgets/widget.hpp.


Member Function Documentation

twidget* gui2::twidget::parent (  )  [inline]

Definition at line 132 of file gui/widgets/widget.hpp.

References parent_.

Referenced by gui2::get_listbox().

void gui2::twidget::set_parent ( twidget parent  )  [inline]

const std::string& gui2::twidget::id (  )  const [inline]

void gui2::twidget::set_id ( const std::string &  id  )  [inline]

Definition at line 136 of file gui/widgets/widget.hpp.

References id_.

Referenced by gui2::tbuilder_listbox::build(), and gui2::tbuilder_control::init_control().

const std::string& gui2::twidget::definition (  )  const [inline]

Definition at line 138 of file gui/widgets/widget.hpp.

References definition_.

Referenced by gui2::tcontrol::load_config().

virtual void gui2::twidget::set_definition ( const std::string &  definition  )  [inline, virtual]

This should not be changed after the widget is shown, strange things might occur.

Reimplemented in gui2::tcontrol.

Definition at line 142 of file gui/widgets/widget.hpp.

References definition_.

Referenced by gui2::tbuilder_listbox::build(), and gui2::tcontrol::set_definition().

virtual void gui2::twidget::draw ( surface  )  [pure virtual]

int gui2::twidget::get_x (  )  const [inline]

int gui2::twidget::get_y (  )  const [inline]

unsigned gui2::twidget::get_width (  )  const [inline]

unsigned gui2::twidget::get_height (  )  const [inline]

Definition at line 156 of file gui/widgets/widget.hpp.

References h_.

Referenced by gui2::tvertical_scrollbar::get_length(), and gui2::ttext_box::update_offsets().

virtual bool gui2::twidget::dirty (  )  const [inline, virtual]

virtual tpoint gui2::twidget::get_minimum_size (  )  const [pure virtual]

Gets the minimum size for the object, 0,0 means no size required.

Implemented in gui2::tcontainer_, gui2::tcontrol, and gui2::tgrid.

Referenced by gui2::tgrid::tchild::get_minimum_size().

virtual tpoint gui2::twidget::get_best_size (  )  const [pure virtual]

Gets the best size for the object, 0,0 means no size required.

Implemented in gui2::tcontainer_, gui2::tcontrol, gui2::tgrid, gui2::tlistbox, and gui2::tspacer.

Referenced by gui2::tgrid::tchild::get_best_size(), and gui2::tgrid::tchild::set_size().

virtual tpoint gui2::twidget::get_maximum_size (  )  const [pure virtual]

Gets the best size for an object, 0,0 means no limits.

Implemented in gui2::tcontrol, and gui2::tgrid.

Referenced by gui2::tgrid::tchild::get_maximum_size(), and gui2::tgrid::tchild::set_size().

virtual void gui2::twidget::set_size ( const SDL_Rect &  rect  )  [inline, virtual]

Sets a predefined size for the object.

Reimplemented in gui2::tcontainer_, gui2::tcontrol, gui2::tgrid, gui2::tlistbox, gui2::tscrollbar_, and gui2::ttext_box.

Definition at line 171 of file gui/widgets/widget.hpp.

References dirty_, h_, w_, x_, and y_.

Referenced by gui2::tgrid::tchild::set_size(), gui2::tgrid::set_size(), and gui2::tcontrol::set_size().

virtual twidget* gui2::twidget::find_widget ( const tpoint coordinate,
const bool  must_be_active 
) [inline, virtual]

Gets the widget at the wanted coordinates.

Parameters:
coordinate The coordinate which should be inside the widget.
must_be_active The widget should be active, not all widgets have an active flag, those who don't ignore flag.
Returns:
The widget with the id.
Return values:
0 No widget at the wanted coordinate found (or not active if must_be_active was set).

Reimplemented in gui2::tcontainer_, gui2::tcontrol, gui2::tgrid, gui2::tlistbox, gui2::tpanel, and gui2::twindow.

Definition at line 193 of file gui/widgets/widget.hpp.

References h_, w_, gui2::tpoint::x, x_, gui2::tpoint::y, and y_.

Referenced by gui2::tgrid::find_widget(), and gui2::tcontrol::find_widget().

virtual const twidget* gui2::twidget::find_widget ( const tpoint coordinate,
const bool  must_be_active 
) const [inline, virtual]

The const version of find_widget.

Reimplemented in gui2::tcontainer_, gui2::tcontrol, gui2::tgrid, gui2::tlistbox, gui2::tpanel, and gui2::twindow.

Definition at line 201 of file gui/widgets/widget.hpp.

References h_, w_, gui2::tpoint::x, x_, gui2::tpoint::y, and y_.

virtual twidget* gui2::twidget::find_widget ( const std::string &  id,
const bool  must_be_active 
) [inline, virtual]

Gets a widget with the wanted id.

Parameters:
id The id of the widget to find.
must_be_active The widget should be active, not all widgets have an active flag, those who don't ignore flag.
Returns:
The widget with the id.
Return values:
0 No widget with the id found (or not active if must_be_active was set).

Reimplemented in gui2::tcontainer_, gui2::tcontrol, gui2::tgrid, gui2::tpanel, and gui2::twindow.

Definition at line 220 of file gui/widgets/widget.hpp.

References id_.

virtual const twidget* gui2::twidget::find_widget ( const std::string &  id,
const bool  must_be_active 
) const [inline, virtual]

The const version of find_widget.

Reimplemented in gui2::tcontainer_, gui2::tcontrol, gui2::tgrid, gui2::tpanel, and gui2::twindow.

Definition at line 225 of file gui/widgets/widget.hpp.

References id_.

virtual bool gui2::twidget::has_widget ( const twidget widget  )  const [inline, virtual]

Does the widget contain the widget.

This makes more sence in container classes.

Reimplemented in gui2::tcontainer_, and gui2::tgrid.

Definition at line 234 of file gui/widgets/widget.hpp.

twindow * gui2::twidget::get_window (  ) 

The toplevel item should always be a window if not null is returned.

Reimplemented in gui2::twindow.

Definition at line 47 of file gui/widgets/widget.cpp.

References parent_.

Referenced by gui2::tbutton::mouse_left_button_click().

virtual void gui2::twidget::load_config (  )  [inline, virtual]

loads the configuration of the widget, mainly used for controls.

Reimplemented in gui2::tcontrol.

Definition at line 241 of file gui/widgets/widget.hpp.

SDL_Rect gui2::twidget::get_rect (  )  const [inline]

virtual bool gui2::twidget::has_vertical_scrollbar (  )  const [inline, virtual]

If the best size doesn't fit we want to use the best size for normal widgets, and resize those who own a scrollbar.

Reimplemented in gui2::tcontainer_, gui2::tgrid, gui2::tlistbox, and gui2::tpanel.

Definition at line 251 of file gui/widgets/widget.hpp.

Referenced by gui2::tgrid::has_vertical_scrollbar(), and gui2::tgrid::set_size().

virtual bool gui2::twidget::has_horizontal_scrollbar (  )  const [inline, virtual]

Definition at line 252 of file gui/widgets/widget.hpp.

virtual void gui2::twidget::set_dirty ( const bool  dirty = true  )  [inline, protected, virtual]


Member Data Documentation

std::string gui2::twidget::id_ [private]

The id is the unique name of the widget in a certain context.

This is needed for certain widgets so the engine knows which widget is which. Eg it knows which button is pressed and thuswhich engine action is connected to the button.

Definition at line 266 of file gui/widgets/widget.hpp.

Referenced by find_widget(), id(), and set_id().

std::string gui2::twidget::definition_ [private]

The definition is the id of that widget class.

Eg for a button it [button_definition]id. A button can have multiple definitions which all look different but for the engine still is a button.

Definition at line 271 of file gui/widgets/widget.hpp.

Referenced by definition(), and set_definition().

Definition at line 273 of file gui/widgets/widget.hpp.

Referenced by get_window(), parent(), set_dirty(), and set_parent().

int gui2::twidget::x_ [private]

Definition at line 274 of file gui/widgets/widget.hpp.

Referenced by find_widget(), get_rect(), get_x(), and set_size().

int gui2::twidget::y_ [private]

Definition at line 274 of file gui/widgets/widget.hpp.

Referenced by find_widget(), get_rect(), get_y(), and set_size().

unsigned gui2::twidget::w_ [private]

Definition at line 275 of file gui/widgets/widget.hpp.

Referenced by find_widget(), get_rect(), get_width(), and set_size().

unsigned gui2::twidget::h_ [private]

Definition at line 275 of file gui/widgets/widget.hpp.

Referenced by find_widget(), get_height(), get_rect(), and set_size().

bool gui2::twidget::dirty_ [private]

Definition at line 276 of file gui/widgets/widget.hpp.

Referenced by dirty(), set_dirty(), and set_size().


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

Generated by doxygen 1.5.5 on 23 May 2008 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs