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::Rectangle gccv::Arrow gccv::Text

List of all members.

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 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)
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:
canvas a 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:
parent the Group to which the new Item will be added.
client the 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 double gccv::Item::Distance ( double  x,
double  y,
Item **  item 
) const [virtual]

Parameters:
x horizontal position
y vertical position
item where 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::Arrow, gccv::BezierArrow, gccv::Circle, gccv::Group, gccv::Leaf, gccv::Line, gccv::PolyLine, gccv::Rectangle, gccv::Squiggle, and gccv::Wedge.

virtual bool gccv::Item::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 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.

virtual void gccv::Item::Draw ( cairo_t *  cr,
bool  is_vector 
) const [virtual]

Parameters:
cr a cairo_t.
is_vector whether 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::Arrow, gccv::BezierArrow, gccv::Circle, gccv::Hash, gccv::Leaf, gccv::Line, gccv::PolyLine, gccv::Rectangle, gccv::Squiggle, gccv::Text, and gccv::Wedge.

void gccv::Item::GetBounds ( double &  x0,
double &  y0,
double &  x1,
double &  y1 
) const

Parameters:
x0 where to store the top left horizontal bound.
y0 where to store the top left vertical bound.
x1 where to store the bottom right horizontal bound.
y1 where to store the bottom right vertical bound.
Retrieves the current bounds coordinate for the Itm.

Canvas const* gccv::Item::GetCanvas (  )  const [inline, protected]

Returns:
the Canvas enclosing the Item.

Definition at line 204 of file item.h.

gccv::Item::GetClient ( void   )  [inline]

Returns:
the ItemClient associated with the Item.

Definition at line 237 of file item.h.

gccv::Item::GetOperator ( void   )  const [inline]

Returns:
the cairo_operator_t used when rendering the item.

Definition at line 254 of file item.h.

gccv::Item::GetParent ( void   )  const [inline]

Returns:
the Item parent Group.

Definition at line 241 of file item.h.

gccv::Item::GetVisible ( void   )  const [inline]

Returns:
true if the item is visible, false if hidden.

Definition at line 245 of file item.h.

void gccv::Item::Invalidate (  )  const

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

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

Parameters:
x the horizontal deplacement
y the vertical deplacement
Moves the Item.

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

gccv::Item::SetClient ( ItemClient Client  )  [inline]

Parameters:
Client an ItemClient instance.
Sets the Item Client associated with the Item.

Definition at line 237 of file item.h.

gccv::Item::SetOperator ( cairo_operator_t  Operator  )  [inline]

Parameters:
Operator a cairo_operator_t.
Sets the cairo_operator_t used by the item.

Definition at line 254 of file item.h.

void gccv::Item::SetVisible ( bool  visible  ) 

Parameters:
visible whether the Item should be visible.
Show or Hide the Item according to the value of visible.

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


Member Data Documentation

double gccv::Item::m_x0 [protected]

The top left horizontal bound.

Definition at line 210 of file item.h.

double gccv::Item::m_x1 [protected]

The bottom right horizontal bound.

Definition at line 218 of file item.h.

double gccv::Item::m_y0 [protected]

The top left vertical bound.

Definition at line 214 of file item.h.

double gccv::Item::m_y1 [protected]

The bottom right vertical bound.

Definition at line 222 of file item.h.


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