gccv::Group Class Reference

Item with Item children. More...

#include <group.h>

Inheritance diagram for gccv::Group:

gccv::Item

List of all members.

Public Member Functions

 Group (Canvas *canvas)
 Group (Canvas *canvas, double x, double y)
 Group (Group *parent, ItemClient *client=NULL)
 Group (Group *parent, double x, double y, ItemClient *client=NULL)
virtual ~Group ()
void AddChild (Item *item)
void RemoveChild (Item *item)
void MoveToFront (Item *item)
void MoveToBack (Item *item)
ItemGetFirstChild (std::list< Item * >::iterator &it)
ItemGetNextChild (std::list< Item * >::iterator &it)
void AdjustBounds (double &x0, double &y0, double &x1, double &y1) const
void SetPosition (double x, double y)
double Distance (double x, double y, Item **item) const
bool Draw (cairo_t *cr, double x0, double y0, double x1, double y1, bool is_vector) const
void Move (double x, double y)

Protected Member Functions

void UpdateBounds ()


Detailed Description

Item with Item children.

A Group is an Item grouping several children Item instances in a std::list. Children might also be Group items themselves so that it allows for a hierarchical tree if Item instances. The Canvas class owns a top level Group (see Canvas::GetRoot()) and all Item instances in the canvas are descendants of this root Group. The Group class owns a pair of coordinates, x and y, which are used to shift all the children.

Definition at line 46 of file group.h.


Constructor & Destructor Documentation

gccv::Group::Group ( Canvas canvas  ) 

Parameters:
canvas a Canvas.
Creates a new Group and sets it as a child of the root Group of canvas.

gccv::Group::Group ( Canvas canvas,
double  x,
double  y 
)

Parameters:
canvas a Canvas.
x the horizontal group shift.
y the vertical group shift.
Creates a new Group at (x, y) and sets it as a child of the root Group of canvas.

gccv::Group::Group ( Group parent,
ItemClient client = NULL 
)

Parameters:
parent the Group to which the new Group will be added.
client the ItemClient for the new Group if any.
Creates a new Group inside parent and sets client as its associated ItemClient.

gccv::Group::Group ( Group parent,
double  x,
double  y,
ItemClient client = NULL 
)

Parameters:
parent the Group to which the new Group will be added.
x the horizontal group shift.
y the vertical group shift.
client the ItemClient for the new Group if any.
Creates a new Group at (x, y) inside parent and sets client as its associated ItemClient.

virtual gccv::Group::~Group (  )  [virtual]

The destructor. When a Group is destroyed, all its children are destroyed too.


Member Function Documentation

void gccv::Group::AddChild ( Item item  ) 

Parameters:
item the new child.
Adds item to the children list so that it will be displayed first, and so will appear under other overlapping children. To add an Item on top all other children, use thius method and then Group::MoveToFront().

void gccv::Group::AdjustBounds ( double &  x0,
double &  y0,
double &  x1,
double &  y1 
) const

Parameters:
x0 the top left horizontal bound to adjust.
y0 the top left vertical bound to adjust.
x1 the bottom right horizontal bound to adjust.
y1 the bottom right top left vertical to adjustw.
Adjusts the parameters according to the shift values. This allows to evaluate the absolute position of an Item inside the Canvas.

double gccv::Group::Distance ( double  x,
double  y,
Item **  item 
) const [virtual]

Parameters:
x horizontal position
y vertical position
item where to store the nearest Item.
Implementation of Item::Distance() for the Group class. Sets item to the descendant Item nearest to the given position.

Reimplemented from gccv::Item.

bool gccv::Group::Draw ( cairo_t *  cr,
double  x0,
double  y0,
double  x1,
double  y1,
bool  is_vector 
) const [virtual]

Parameters:
cr a cairo_t.
x0 the top left horizontal bound of the region to draw.
y0 the top left vertical bound of the region to draw.
x1 the bottom right horizontal bound of the region to draw.
y1 the bottom right top left vertical bound of the region to draw.
is_vector whether the cairo_t is a vectorial context.
Draws Group children to cr, limiting things to the given region.

Reimplemented from gccv::Item.

Item* gccv::Group::GetFirstChild ( std::list< Item * >::iterator &  it  ) 

Parameters:
it a list iterator.
Returns:
the first child Item. Actually, the one displayed first.

Item* gccv::Group::GetNextChild ( std::list< Item * >::iterator &  it  ) 

Parameters:
it a list iterator initalized by a call to GetFirstChild().
Returns:
the next child Item if any.

void gccv::Group::Move ( double  x,
double  y 
) [virtual]

Parameters:
x the horizontal deplacement
y the vertical deplacement
Moves the Group and hence all its descendants by changing the Group shift values.

Reimplemented from gccv::Item.

void gccv::Group::MoveToBack ( Item item  ) 

Parameters:
item to move in the list.
Changes the Item position in the children list so that it is displayed first below other overlapping children.

void gccv::Group::MoveToFront ( Item item  ) 

Parameters:
item to move in the list.
Changes the Item position in the children list so that it is displayed last on top of other overlapping children.

void gccv::Group::RemoveChild ( Item item  ) 

Parameters:
item to remove.
Removes item to the children list but does not destroys it. item will not be displayed anymore unless it is added to a new Group.

void gccv::Group::SetPosition ( double  x,
double  y 
)

Parameters:
x the horizontal position
y the vertical position
Sets the Group shift values.

void gccv::Group::UpdateBounds (  )  [protected, virtual]

Updates Item::m_x0, Item::m_y0, Item::m_x1 and Item::m_y1. All derived classes should implement this method to set the bounds and call Item::UpdateBounds() when done.

Reimplemented from gccv::Item.


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

Generated on Fri Sep 24 15:58:43 2010 for The Gnome Chemistry Utils by  doxygen 1.5.9