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

The base class for the canvas contents. More...

#include <item.h>

Inheritance diagram for gccv::Item:
gccv::Group gccv::LineItem gccv::Wedge gccv::BezierArrow gccv::FillItem gccv::Line gccv::PolyLine gccv::Squiggle gccv::Hash gccv::Circle gccv::Leaf gccv::Polygon gccv::Rectangle gccv::Arrow gccv::Text

Public Member Functions

 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 double Distance (double x, double y, Item **item) const
virtual void BuildPath (cairo_t *cr) const
virtual void Draw (cairo_t *cr, bool is_vector) const
virtual bool Draw (cairo_t *cr, double x0, double y0, double x1, double y1, bool is_vector) const
virtual void Move (double x, double y)
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 BoundsChanged ()
virtual void UpdateBounds ()
Canvas const * GetCanvas () const

Protected Attributes

double m_x0
double m_y0
double m_x1
double m_y1

Detailed Description

The base class for the canvas contents.

The Item class is the base class for everything that might be included inside the Canvas associated widget. If the item represents an object, it can be linked to it if the object derives from the ItemClient class. In that case, the client object is notified when an event occurs for the item.

Definition at line 100 of file item.h.

Constructor & Destructor Documentation

gccv::Item::Item ( Canvas canvas)
Parameters
canvasa Canvas.

Creates a new Item and sets it as a child of the root Group of canvas.

gccv::Item::Item ( Group parent,
ItemClient client = NULL 
)
Parameters
parentthe Group to which the new Item will be added.
clientthe ItemClient for the new Item if any.

Creates a new Item inside parent and sets client as its associated ItemClient.

virtual gccv::Item::~Item ( )
virtual

The destructor.

Member Function Documentation

void gccv::Item::BoundsChanged ( )
protected

Must be called when the bounds have changed.

virtual void gccv::Item::BuildPath ( cairo_t *  cr) const
virtual
Parameters
cra cairo_t.

Builds the cairo path corresponding to the Item bounds. Doesn't draw anything.

Reimplemented in gccv::Polygon.

virtual double gccv::Item::Distance ( double  x,
double  y,
Item **  item 
) const
virtual
Parameters
xhorizontal position
yvertical position
itemwhere to store the Item.

Evaluates an approximative distance between the point defined by (x,y) and the Item. A complex Item like a Group should set the nearest Item in item. Simple item just set themselves. return 0. when the point is inside the item, a reasonable small value when the point is near the Item, and a large value when far. Defult implementation returns G_MAXDOUBLE.

Reimplemented in gccv::Group, gccv::Rectangle, gccv::Leaf, gccv::Circle, gccv::Wedge, gccv::Polygon, gccv::Squiggle, gccv::Line, gccv::Arrow, gccv::PolyLine, and gccv::BezierArrow.

virtual void gccv::Item::Draw ( cairo_t *  cr,
bool  is_vector 
) const
virtual
Parameters
cra cairo_t.
is_vectorwhether the cairo_t is a vectorial context.

Draws Item to cr. is_vector might be used to enhance rendering in the case of a raster target. Derived classes should override at least one of the Draw() methods

Reimplemented in gccv::Text, gccv::Rectangle, gccv::Leaf, gccv::Circle, gccv::Wedge, gccv::Polygon, gccv::Squiggle, gccv::Line, gccv::Arrow, gccv::PolyLine, gccv::Hash, and gccv::BezierArrow.

virtual bool gccv::Item::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 Item to cr, limiting the operations to the given rectangular region. is_vector might be used to enhance rendering in the case of a raster target. Derived classes should override at least one of the Draw() methods

Returns
true if done. Default implementation returns false. When false is returned the other Draw() method is called.

Reimplemented in gccv::Group.

void gccv::Item::GetBounds ( double &  x0,
double &  y0,
double &  x1,
double &  y1 
) const
Parameters
x0where to store the top left horizontal bound.
y0where to store the top left vertical bound.
x1where to store the bottom right horizontal bound.
y1where to store the bottom right vertical bound.

Retrieves the current bounds coordinate for the Item.

Canvas const* gccv::Item::GetCanvas ( ) const
inlineprotected
Returns
the Canvas enclosing the Item.

Definition at line 214 of file item.h.

gccv::Item::GetClient ( void  )
inline
Returns
the ItemClient associated with the Item.

Definition at line 247 of file item.h.

gccv::Item::GetOperator ( void  ) const
inline
Returns
the cairo_operator_t used when rendering the item.

Definition at line 264 of file item.h.

gccv::Item::GetParent ( void  ) const
inline
Returns
the Item parent Group.

Definition at line 251 of file item.h.

gccv::Item::GetVisible ( void  ) const
inline
Returns
true if the item is visible, false if hidden.

Definition at line 255 of file item.h.

void gccv::Item::Invalidate ( ) const

Invalidates the Item and force a redraw of the rectangular region defined by its bounds.

bool gccv::Item::IsTopLevel ( ) const
Returns
whether the item parent is the canvas root item.
virtual void gccv::Item::Move ( double  x,
double  y 
)
virtual
Parameters
xthe horizontal deplacement
ythe vertical deplacement

Moves the Item.

Reimplemented in gccv::Text, gccv::Group, gccv::Rectangle, gccv::Leaf, gccv::Polygon, gccv::Circle, gccv::Wedge, gccv::Squiggle, gccv::Line, gccv::PolyLine, and gccv::BezierArrow.

gccv::Item::SetClient ( ItemClient Client)
inline
Parameters
Clientan ItemClient instance.

Sets the Item Client associated with the Item.

Definition at line 247 of file item.h.

gccv::Item::SetOperator ( cairo_operator_t  Operator)
inline
Parameters
Operatora cairo_operator_t.

Sets the cairo_operator_t used by the item.

Definition at line 264 of file item.h.

void gccv::Item::SetVisible ( bool  visible)
Parameters
visiblewhether the Item should be visible.

Show or Hide the Item according to the value of visible.

virtual void gccv::Item::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 in gccv::Group, gccv::Rectangle, gccv::Leaf, gccv::Polygon, gccv::Circle, gccv::Wedge, gccv::Squiggle, gccv::Line, gccv::PolyLine, gccv::Arrow, and gccv::BezierArrow.

Member Data Documentation

double gccv::Item::m_x0
protected

The top left horizontal bound.

Definition at line 220 of file item.h.

double gccv::Item::m_x1
protected

The bottom right horizontal bound.

Definition at line 228 of file item.h.

double gccv::Item::m_y0
protected

The top left vertical bound.

Definition at line 224 of file item.h.

double gccv::Item::m_y1
protected

The bottom right vertical bound.

Definition at line 232 of file item.h.


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