VirtualSurface Class Reference
[C++ Wrapper for SDL]

Container for Surface.

Other surface (any class derived from Surface) may be attached to VirtualSurface, in a father-child relationship. Rendering is done automatically, using this VirtualSurface as an intermediate SDL_Surface, in a efficient way. More...

#include <VirtualSurface.hh>

Inheritance diagram for VirtualSurface:

Inheritance graph
[legend]
List of all members.

Public Member Functions

 VirtualSurface (const std::string &name, SDL_Surface *surf)
 VirtualSurface (const std::string &name, int width, int height)
void addChild (Surface *child)
 Add a child to this VirtualSurface.
void removeChild (Surface *child)
 Remove a child to this VirtualSurface.
int getNbChild () const
 Get the number of child currently contained by this VirtualSurface.
void updateChildZOrder ()
 Private method, you shouldn't need that.
virtual void enable ()
 Enable this widget.
virtual void show ()
 Show this surface on the screen.
virtual void setZoom (double zoom)
virtual void update ()
 Method called each frame, to perfom user custom code.
virtual void render ()
 Private method.
void invalidate (const Rect &zone)
 Set a marker on a rectangle that must be redrawn next time.
void invalidate (const Point &pos, const Point &size)
 Set a marker on a rectangle that must be redrawn next time.

Protected Types

typedef std::vector< Surface * > SurfaceList
typedef std::vector< RectRectList

Protected Attributes

SurfaceList child_list_
RectList invalidated_surf_
std::string name_

Detailed Description

Container for Surface.

Other surface (any class derived from Surface) may be attached to VirtualSurface, in a father-child relationship. Rendering is done automatically, using this VirtualSurface as an intermediate SDL_Surface, in a efficient way.


Member Function Documentation

void VirtualSurface::addChild ( Surface child  ) 

Add a child to this VirtualSurface.

Parameters:
child Child to add.
Note:
You can add the same child multiple time, so take care.

void VirtualSurface::enable (  )  [virtual]

Enable this widget.

Note:
This is the default.

Reimplemented from Surface.

Reimplemented in sdlvisu::DialogBox.

int VirtualSurface::getNbChild (  )  const

Get the number of child currently contained by this VirtualSurface.

Returns:
The current number of child this VS contains.

void VirtualSurface::invalidate ( const Point pos,
const Point size 
)

Set a marker on a rectangle that must be redrawn next time.

To call when a visual change has occured in this rectangle (like adding, moving or removing a sprite).

Parameters:
pos A top-left point relative to this VirtualSurface position.
size The size of the invalidated rectangle.

void VirtualSurface::invalidate ( const Rect zone  ) 

Set a marker on a rectangle that must be redrawn next time.

To call when a visual change has occured in this rectangle (like adding, moving or removing a sprite).

Parameters:
zone A rectangle relative to this VirtualSurface position.

void VirtualSurface::removeChild ( Surface child  ) 

Remove a child to this VirtualSurface.

Parameters:
child Child to remove.

void VirtualSurface::render (  )  [virtual]

Private method.

Called after update round, to effectively render images. Don't override it, should only be used by VirtualSurface.

Reimplemented from Surface.

void VirtualSurface::show (  )  [virtual]

Show this surface on the screen.

Note:
This is the default.

Reimplemented from Surface.

Reimplemented in sdlvisu::ActionPopup.

void VirtualSurface::update (  )  [virtual]

Method called each frame, to perfom user custom code.

You should override it.

Since a parent is assigned to the surface (and this parent is itself attached by other means to the root screen), this method is called at each frame. It is not called if this surface or one of its parent is disabled. In this method you can do what you want with your object, like processing input, updating other programs attributes, changing surface property, ...

Note:
Don't forget to call update for the base class at the end of your function , otherwise strange things will happen.

Reimplemented from Surface.

Reimplemented in VirtualScrollableSurface, sdlvisu::ActionPopup, sdlvisu::DialogBox, sdlvisu::VisuField, and sdlvisu::Panel.

void VirtualSurface::updateChildZOrder (  ) 

Private method, you shouldn't need that.

Update child Z-order in children vector, when a child change its Z attribute.


The documentation for this class was generated from the following files:
Generated on Sat Jun 23 16:14:50 2007 for Stechec/TBT by  doxygen 1.4.7