Layer Class Reference
[Toolkit classes]

A simple container for Graphics. More...

#include <layer.h>

Inherits Graphic.

Inherited by AnimationSlide, LogicConnectionPath, LogicConnector, MemBoard, MemDisplay, MemRegister, RobotBuilder, RobotModel, and TestAnimate.

Collaboration diagram for Layer:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 Layer ()
 Location (0,0), fills the screen.
 Layer (Point location, Point size)
 Layer (int x, int y, int w, int h)
 ~Layer ()
 A deleted layer takes all its objects with it.
void draw (BITMAP *canvas, Point offset)
 Calls the draw() methods of every object in this Layer.
void add (Graphic *g)
 Adds g on top of existing objects.
void addBehind (Graphic *g)
 Adds g behind existing objects.
void remove (Graphic *g)
 Removes g from this object.
int w ()
 The width of this object.
int h ()
 The height of this object.
Point layerSize ()
 A Point representing the size of this object.

Protected Attributes

Point size
std::list< Graphic * > items


Detailed Description

A simple container for Graphics.

The Layer class provides a tree structure to Graphics objects. It contains a list of Graphics and displays them in its draw() method. Note that Layers are themselves Graphics, and thus can be stored inside other Layers. This means that calling the draw() method of the root of a tree composed of Layers will draw the entire structure, with the leaves on top.

Because the location of Graphics objects is relative, moving a layer (via the move() and moveTo() methods of Graphic) will also move all objects it contains. Each Layer also has a size, which restricts the area in which its children may be drawn. Nothing in a Layer can be drawn outside the rectangle with its top left corner at (location) and its bottom right corner at (location + size).


Constructor & Destructor Documentation

Layer::Layer (  ) 

Location (0,0), fills the screen.

Layer::Layer ( Point  location,
Point  size 
)

Layer::Layer ( int  x,
int  y,
int  w,
int  h 
)

Layer::~Layer (  ) 

A deleted layer takes all its objects with it.


Member Function Documentation

void Layer::add ( Graphic g  ) 

Adds g on top of existing objects.

void Layer::addBehind ( Graphic g  ) 

Adds g behind existing objects.

void Layer::draw ( BITMAP *  canvas,
Point  offset 
) [virtual]

Calls the draw() methods of every object in this Layer.

Implements Graphic.

int Layer::h (  )  [inline]

The height of this object.

Point Layer::layerSize (  )  [inline]

A Point representing the size of this object.

void Layer::remove ( Graphic g  ) 

Removes g from this object.

Note that g must be the same pointer as the object that was originally added. Passing an identical object will not work.

int Layer::w (  )  [inline]

The width of this object.


Member Data Documentation

std::list<Graphic*> Layer::items [protected]

Point Layer::size [protected]


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

Generated on Mon Mar 16 14:33:09 2009 for LearningGaming by  doxygen 1.5.7.1