Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes

gui2::tcanvas Class Reference

A simple canvas which can be drawn upon. More...

#include <canvas.hpp>

Collaboration diagram for gui2::tcanvas:
Collaboration graph
[legend]

List of all members.

Classes

class  tshape
 Abstract base class for all other shapes. More...

Public Types

typedef boost::intrusive_ptr
< tshape
tshape_ptr
typedef boost::intrusive_ptr
< const tshape
const_tshape_ptr

Public Member Functions

 tcanvas ()
void draw (const bool force=false)
 Draws the canvas.
void blit (surface &surf, SDL_Rect rect)
 Blits the canvas unto another surface.
void set_cfg (const config &cfg)
 Sets the config.
void set_width (const unsigned width)
unsigned get_width () const
void set_height (const unsigned height)
unsigned get_height () const
surfacesurf ()
void set_variable (const std::string &key, const variant &value)

Private Member Functions

void set_dirty (const bool dirty=true)
void parse_cfg (const config &cfg)
 Parses a config object.

Private Attributes

std::vector< tshape_ptrshapes_
 Vector with the shapes to draw.
unsigned blur_depth_
 The depth of the blur to use in the pre committing.
unsigned w_
 Width of the canvas.
unsigned h_
 Height of the canvas.
surface canvas_
 The surface we draw all items on.
game_logic::map_formula_callable variables_
 The variables of the canvas.
bool dirty_
 The dirty state of the canvas.

Detailed Description

A simple canvas which can be drawn upon.

The class has a config which contains what to draw.

NOTE we might add some caching in a later state, for now every draw cycle does a full redraw.

The copy constructor does a shallow copy of the shapes to draw. a clone() will be implemented if really needed.

Definition at line 44 of file canvas.hpp.


Member Typedef Documentation

typedef boost::intrusive_ptr<const tshape> gui2::tcanvas::const_tshape_ptr

Definition at line 73 of file canvas.hpp.

typedef boost::intrusive_ptr<tshape> gui2::tcanvas::tshape_ptr

Definition at line 72 of file canvas.hpp.


Constructor & Destructor Documentation

gui2::tcanvas::tcanvas (  ) 

Definition at line 1397 of file canvas.cpp.


Member Function Documentation

void gui2::tcanvas::blit ( surface surf,
SDL_Rect  rect 
)

Blits the canvas unto another surface.

It makes sure the image on the canvas is up to date. Also executes the pre-blitting functions.

Parameters:
surf The surface to blit upon.
rect The place to blit to.

Todo:
we should use: get_surface_portion(surf, r, false) no need to optimize format, since blur_surface will undo it

Definition at line 1437 of file canvas.cpp.

References blur_depth_, blur_surface(), canvas_, draw(), get_surface_portion(), is_neutral(), and sdl_blit().

Here is the call graph for this function:

void gui2::tcanvas::draw ( const bool  force = false  ) 

Draws the canvas.

Parameters:
force If the canvas isn't dirty it isn't redrawn unless force is set to true.

Definition at line 1408 of file canvas.cpp.

References game_logic::map_formula_callable::add(), surface::assign(), canvas_, create_neutral_surface(), DBG_GUI_D, dirty_, gui2::get_screen_size_variables(), h_, gui2::log_gui_draw, log_scope2, shapes_, variables_, and w_.

Referenced by blit().

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 111 of file canvas.hpp.

References h_.

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

Definition at line 108 of file canvas.hpp.

References w_.

void gui2::tcanvas::parse_cfg ( const config cfg  )  [private]

Parses a config object.

The config object is parsed and serialized by this function after which the config object is no longer required and thus not stored in the object.

Parameters:
cfg The config object with the data to draw, see http://www.wesnoth.org/wiki/GUICanvasWML

Definition at line 1458 of file canvas.cpp.

References config::all_children_range(), blur_depth_, config::any_child::cfg, DBG_GUI_P, ERR_GUI_P, config::any_child::key, gui2::log_gui_parse, log_scope2, shapes_, and type.

Referenced by set_cfg().

Here is the call graph for this function:

Here is the caller graph for this function:

void gui2::tcanvas::set_cfg ( const config cfg  )  [inline]

Sets the config.

Parameters:
cfg The config object with the data to draw, see http://www.wesnoth.org/wiki/GUICanvasWML for more information.

Definition at line 103 of file canvas.hpp.

References parse_cfg().

Here is the call graph for this function:

void gui2::tcanvas::set_dirty ( const bool  dirty = true  )  [inline, private]

Definition at line 150 of file canvas.hpp.

References dirty_.

Referenced by set_height(), set_variable(), and set_width().

Here is the caller graph for this function:

void gui2::tcanvas::set_height ( const unsigned  height  )  [inline]

Definition at line 110 of file canvas.hpp.

References h_, and set_dirty().

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

Here is the call graph for this function:

Here is the caller graph for this function:

void gui2::tcanvas::set_variable ( const std::string &  key,
const variant value 
) [inline]
void gui2::tcanvas::set_width ( const unsigned  width  )  [inline]

Definition at line 107 of file canvas.hpp.

References set_dirty(), and w_.

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

Here is the call graph for this function:

Here is the caller graph for this function:

surface& gui2::tcanvas::surf (  )  [inline]

Definition at line 113 of file canvas.hpp.

References canvas_.


Member Data Documentation

unsigned gui2::tcanvas::blur_depth_ [private]

The depth of the blur to use in the pre committing.

Note:
at the moment there's one pre commit function, namely the blurring so use a variable here, might get more functions in the future. When that happens need to evaluate whether variables are the best thing to use.

Definition at line 133 of file canvas.hpp.

Referenced by blit(), and parse_cfg().

The surface we draw all items on.

Definition at line 142 of file canvas.hpp.

Referenced by blit(), draw(), and surf().

bool gui2::tcanvas::dirty_ [private]

The dirty state of the canvas.

Definition at line 148 of file canvas.hpp.

Referenced by draw(), and set_dirty().

unsigned gui2::tcanvas::h_ [private]

Height of the canvas.

Definition at line 139 of file canvas.hpp.

Referenced by draw(), get_height(), and set_height().

std::vector<tshape_ptr> gui2::tcanvas::shapes_ [private]

Vector with the shapes to draw.

Definition at line 123 of file canvas.hpp.

Referenced by draw(), and parse_cfg().

The variables of the canvas.

Definition at line 145 of file canvas.hpp.

Referenced by draw(), and set_variable().

unsigned gui2::tcanvas::w_ [private]

Width of the canvas.

Definition at line 136 of file canvas.hpp.

Referenced by draw(), get_width(), and set_width().


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated by doxygen 1.7.1 on Thu May 24 2012 01:21:49 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs