The Gnome Chemistry Utils
0.13.6
|
Item with Item children. More...
#include <group.h>
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) |
Item * | GetFirstChild (std::list< Item * >::iterator &it) |
Item * | GetNextChild (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 () |
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.
gccv::Group::Group | ( | Canvas * | canvas | ) |
gccv::Group::Group | ( | Canvas * | canvas, |
double | x, | ||
double | y | ||
) |
gccv::Group::Group | ( | Group * | parent, |
ItemClient * | client = NULL |
||
) |
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 |
||
) |
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.
void gccv::Group::AddChild | ( | Item * | item | ) |
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 |
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] |
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] |
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 | ) |
it | a list iterator. |
Item* gccv::Group::GetNextChild | ( | std::list< Item * >::iterator & | it | ) |
it | a list iterator initalized by a call to GetFirstChild(). |
void gccv::Group::Move | ( | double | x, |
double | y | ||
) | [virtual] |
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 | ) |
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 | ) |
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 | ) |
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 | ||
) |
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.