The Gnome Chemistry Utils  0.14.0
Public Member Functions | Protected Member Functions | List of all members
gccv::Group Class Reference

Item with Item children. More...

#include <group.h>

Inheritance diagram for gccv::Group:
gccv::Item

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)
- Public Member Functions inherited from gccv::Item
 Item (Canvas *canvas)
 Item (Group *parent, ItemClient *client=NULL)
virtual ~Item ()
void GetBounds (double &x0, double &y0, double &x1, double &y1) const
void Invalidate () const
void SetVisible (bool visible)
virtual void BuildPath (cairo_t *cr) const
virtual void Draw (cairo_t *cr, bool is_vector) const
bool IsTopLevel () const
void SetClient (ItemClient *val)
ItemClientGetClient (void)
Group const * GetParent (void) const
bool GetVisible (void) const
void SetOperator (cairo_operator_t val)
cairo_operator_t GetOperator (void) const

Protected Member Functions

void UpdateBounds ()
- Protected Member Functions inherited from gccv::Item
void BoundsChanged ()
Canvas const * GetCanvas () const

Additional Inherited Members

- Protected Attributes inherited from gccv::Item
double m_x0
double m_y0
double m_x1
double m_y1

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
canvasa 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
canvasa Canvas.
xthe horizontal group shift.
ythe 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
parentthe Group to which the new Group will be added.
clientthe 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
parentthe Group to which the new Group will be added.
xthe horizontal group shift.
ythe vertical group shift.
clientthe 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
itemthe 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
x0the top left horizontal bound to adjust.
y0the top left vertical bound to adjust.
x1the bottom right horizontal bound to adjust.
y1the 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
xhorizontal position
yvertical position
itemwhere 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
cra cairo_t.
x0the top left horizontal bound of the region to draw.
y0the top left vertical bound of the region to draw.
x1the bottom right horizontal bound of the region to draw.
y1the bottom right top left vertical bound of the region to draw.
is_vectorwhether 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
ita list iterator.
Returns
the first child Item. Actually, the one displayed first.
Item* gccv::Group::GetNextChild ( std::list< Item * >::iterator &  it)
Parameters
ita 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
xthe horizontal deplacement
ythe 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
itemto 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
itemto 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
itemto 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
xthe horizontal position
ythe vertical position

Sets the Group shift values.

void gccv::Group::UpdateBounds ( )
protectedvirtual

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: