The Gnome Chemistry Utils  0.14.17
Public Member Functions | List of all members
gccv::Canvas Class Reference

the Canvas class More...

#include <gccv/canvas.h>

Public Member Functions

 Canvas (Client *client)
 
virtual ~Canvas ()
 
ItemGetItemAt (double x, double y)
 
GtkWidget * GetWidget ()
 
void Invalidate (double x0, double y0, double x1, double y1)
 
void SetBackgroundColor (GOColor color)
 
void SetZoom (double zoom)
 
void Render (cairo_t *cr, bool is_vector)
 
double GetZoom (void) const
 
GroupGetRoot (void) const
 
void SetGap (double val)
 
double GetGap (void) const
 
double & GetRefGap (void)
 
GOColor GetColor (void) const
 
PangoFontDescription * GetFont (void) const
 
GOColor GetBackgroundColor (void) const
 
unsigned GetLastEventState (void) const
 

Detailed Description

the Canvas class

This class is the container class for the items and is the only one interacting with the underlying Gtk+ framework. It uses a private widget derived from GtkDrawingArea.

Definition at line 53 of file canvas.h.

Constructor & Destructor Documentation

◆ Canvas()

gccv::Canvas::Canvas ( Client client)
Parameters
clientthe gccv::Client for the canvas or NULL.

Constructs a canvas for client which is mandatory if some interaction with the canvas is needed.

◆ ~Canvas()

virtual gccv::Canvas::~Canvas ( )
virtual

The destructor. You should not delete the canvas, as it will be destroyed with the enclosing widget. Instead, if you never show the widget in a window, use:

gtk_widget_destroy (canvas->GetWidget ());

Items are stored in an ordered tree whose top node is a gccv::Group instance which can be accessed by the GetRoot() method.

Member Function Documentation

◆ GetBackgroundColor()

gccv::Canvas::GetBackgroundColor ( void  ) const
inline
Returns
the background color.

Definition at line 160 of file canvas.h.

◆ GetColor()

gccv::Canvas::GetColor ( void  ) const
inline
Returns
the foreground color.

Definition at line 152 of file canvas.h.

◆ GetFont()

gccv::Canvas::GetFont ( void  ) const
inline
Returns
the font description.

Definition at line 156 of file canvas.h.

◆ GetGap()

gccv::Canvas::GetGap ( void  ) const
inline
Returns
the current gap for the canvas.

Definition at line 148 of file canvas.h.

◆ GetItemAt()

Item* gccv::Canvas::GetItemAt ( double  x,
double  y 
)
Parameters
xthe x coordiante.
ythe y coordinate.

Used to get the top item at or near the given position.

Returns
the found item or NULL if no item is nearer than the current gap from the given position.

◆ GetLastEventState()

gccv::Canvas::GetLastEventState ( void  ) const
inline
Returns
the GdkModifierType value for the last received event.

Definition at line 164 of file canvas.h.

◆ GetRefGap()

gccv::Canvas::GetRefGap ( void  )
inline
Returns
the current gap for the canvas as a reference.

Definition at line 148 of file canvas.h.

◆ GetRoot()

gccv::Canvas::GetRoot ( void  ) const
inline
Returns
the root item.

Definition at line 130 of file canvas.h.

◆ GetWidget()

GtkWidget* gccv::Canvas::GetWidget ( void  )
inline
Returns
the widget used by the canvas.

Definition at line 89 of file canvas.h.

References Invalidate(), Render(), SetBackgroundColor(), and SetZoom().

◆ GetZoom()

gccv::Canvas::GetZoom ( void  ) const
inline
Returns
the current zoom level for the canvas.

Definition at line 126 of file canvas.h.

◆ Invalidate()

void gccv::Canvas::Invalidate ( double  x0,
double  y0,
double  x1,
double  y1 
)
Parameters
x0the x coordinate for the top left of the invalidated rectangle.
y0the y coordinate for the top left of the scrolling rectangle.
x1the x coordinate for the bottom right of the scrolling rectangle.
y1the y coordinate for the bottom right of the scrolling rectangle.

Referenced by GetWidget().

◆ Render()

void gccv::Canvas::Render ( cairo_t *  cr,
bool  is_vector 
)
Parameters
cra cairo context.
is_vectorwhether the cairo context is vectorial or raster.

Renders the current canvas to the cairo context.

Referenced by GetWidget().

◆ SetBackgroundColor()

void gccv::Canvas::SetBackgroundColor ( GOColor  color)
Parameters
colora GOColor.

Sets the background color for the canvas widget

Referenced by GetWidget().

◆ SetGap()

gccv::Canvas::SetGap ( double  gap)
inline
Parameters
gapa distance at which an item might be from an event location to be selected for the event.

Sets the maximum distance at which an item might be from an event location to be selected for the event. When an even as a mouse button click occurs, and if it occurs on an item, the appropriate method of the item client will be called; else if it occurs on the background, the nearest item will be used if its distance from the event location is less than gap. If no item can be used, the event will have no associated gccv::ItemClient instance.

Definition at line 148 of file canvas.h.

◆ SetZoom()

void gccv::Canvas::SetZoom ( double  zoom)
Parameters
zoomthe new zoom level.

Sets the zoom level for the canvas.

Referenced by GetWidget().


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