GooCanvas Types

GooCanvas Types — types used in GooCanvas.

Synopsis


#include <goocanvas.h>


            GooCanvasBounds;

enum        GooCanvasItemVisibility;

enum        GooCanvasPointerEvents;

enum        GooCanvasAnimateType;

            GooCanvasStyle;
enum        GooCanvasStyleValuesMask;
GooCanvasStyle* goo_canvas_style_new        (void);
GooCanvasStyle* goo_canvas_style_ref        (GooCanvasStyle *style);
void        goo_canvas_style_unref          (GooCanvasStyle *style);

            GooCanvasPoints;
GooCanvasPoints* goo_canvas_points_new      (int num_points);
GooCanvasPoints* goo_canvas_points_ref      (GooCanvasPoints *points);
void        goo_canvas_points_unref         (GooCanvasPoints *points);

            GooCanvasLineDash;
GooCanvasLineDash* goo_canvas_line_dash_new (gint num_dashes,
                                             ...);
GooCanvasLineDash* goo_canvas_line_dash_newv
                                            (gint num_dashes,
                                             double *dashes);
GooCanvasLineDash* goo_canvas_line_dash_ref (GooCanvasLineDash *dash);
void        goo_canvas_line_dash_unref      (GooCanvasLineDash *dash);

Description

This section describes the types used throughout GooCanvas.

Details

GooCanvasBounds

typedef struct {
  gdouble x1, y1, x2, y2;
} GooCanvasBounds;

GooCanvasBounds represents the bounding box of an item in the canvas.

gdouble x1; the left edge.
gdouble y1; the top edge.
gdouble x2; the right edge.
gdouble y2; the bottom edge.

enum GooCanvasItemVisibility

typedef enum
{
  GOO_CANVAS_ITEM_VISIBLE,
  GOO_CANVAS_ITEM_VISIBLE_ABOVE_THRESHOLD,
  GOO_CANVAS_ITEM_INVISIBLE
} GooCanvasItemVisibility;

The GooCanvasItemVisibility enumeration is used to specify when a canvas item is visible.

GOO_CANVAS_ITEM_VISIBLE the item is visible.
GOO_CANVAS_ITEM_VISIBLE_ABOVE_THRESHOLD the item is visible when the canvas scale setting is greater than or equal to the item's visibility threshold setting.
GOO_CANVAS_ITEM_INVISIBLE the item is invisible.

enum GooCanvasPointerEvents

typedef enum
{
  /* If the item must be visible to receive events. */
  GOO_CANVAS_EVENTS_VISIBLE_MASK	= 1 << 0,

  /* If the fill or stroke must be painted to receive events. */
  GOO_CANVAS_EVENTS_PAINTED_MASK	= 1 << 1,

  /* If the fill should receive events. */
  GOO_CANVAS_EVENTS_FILL_MASK		= 1 << 2,

  /* If the stroke should receive events. */
  GOO_CANVAS_EVENTS_STROKE_MASK		= 1 << 3,


  GOO_CANVAS_EVENTS_NONE		= 0,

  GOO_CANVAS_EVENTS_VISIBLE_PAINTED	= GOO_CANVAS_EVENTS_VISIBLE_MASK
					  | GOO_CANVAS_EVENTS_PAINTED_MASK
					  | GOO_CANVAS_EVENTS_FILL_MASK
					  | GOO_CANVAS_EVENTS_STROKE_MASK,
  GOO_CANVAS_EVENTS_VISIBLE_FILL	= GOO_CANVAS_EVENTS_VISIBLE_MASK
					  | GOO_CANVAS_EVENTS_FILL_MASK,
  GOO_CANVAS_EVENTS_VISIBLE_STROKE	= GOO_CANVAS_EVENTS_VISIBLE_MASK
					  | GOO_CANVAS_EVENTS_STROKE_MASK,
  GOO_CANVAS_EVENTS_VISIBLE		= GOO_CANVAS_EVENTS_VISIBLE_MASK
					  | GOO_CANVAS_EVENTS_FILL_MASK
					  | GOO_CANVAS_EVENTS_STROKE_MASK,

  GOO_CANVAS_EVENTS_PAINTED		= GOO_CANVAS_EVENTS_PAINTED_MASK
					  | GOO_CANVAS_EVENTS_FILL_MASK
					  | GOO_CANVAS_EVENTS_STROKE_MASK,
  GOO_CANVAS_EVENTS_FILL		= GOO_CANVAS_EVENTS_FILL_MASK,
  GOO_CANVAS_EVENTS_STROKE		= GOO_CANVAS_EVENTS_STROKE_MASK,
  GOO_CANVAS_EVENTS_ALL			= GOO_CANVAS_EVENTS_FILL_MASK
					  | GOO_CANVAS_EVENTS_STROKE_MASK
} GooCanvasPointerEvents;

Specifies when an item receives pointer events such as mouse clicks.

GOO_CANVAS_EVENTS_VISIBLE_MASK a mask indicating that the item only receives events when it is visible.
GOO_CANVAS_EVENTS_PAINTED_MASK a mask indicating that the item only receives events when the specified parts of it are painted.
GOO_CANVAS_EVENTS_FILL_MASK a mask indicating that the filled part of the item receives events.
GOO_CANVAS_EVENTS_STROKE_MASK a mask indicating that the stroked part of the item receives events.
GOO_CANVAS_EVENTS_NONE the item doesn't receive events at all.
GOO_CANVAS_EVENTS_VISIBLE_PAINTED the item receives events in its painted areas when it is visible (the default).
GOO_CANVAS_EVENTS_VISIBLE_FILL the item's interior receives events when it is visible.
GOO_CANVAS_EVENTS_VISIBLE_STROKE the item's perimeter receives events when it is visible.
GOO_CANVAS_EVENTS_VISIBLE the item receives events when it is visible, whether it is painted or not.
GOO_CANVAS_EVENTS_PAINTED the item receives events in its painted areas, whether it is visible or not.
GOO_CANVAS_EVENTS_FILL the item's interior receives events, whether it is visible or painted or not.
GOO_CANVAS_EVENTS_STROKE the item's perimeter receives events, whether it is visible or painted or not.
GOO_CANVAS_EVENTS_ALL the item's perimeter and interior receive events, whether it is visible or painted or not.

enum GooCanvasAnimateType

typedef enum
{
  GOO_CANVAS_ANIMATE_FREEZE,
  GOO_CANVAS_ANIMATE_RESET,
  GOO_CANVAS_ANIMATE_RESTART,
  GOO_CANVAS_ANIMATE_BOUNCE
} GooCanvasAnimateType;

GooCanvasAnimateType is used to specify what happens when the end of an animation is reached.

GOO_CANVAS_ANIMATE_FREEZE the item remains in the final position.
GOO_CANVAS_ANIMATE_RESET the item is moved back to the initial position.
GOO_CANVAS_ANIMATE_RESTART the animation is restarted from the initial position.
GOO_CANVAS_ANIMATE_BOUNCE the animation bounces back and forth between the start and end positions.

GooCanvasStyle

typedef struct {
  int ref_count;

  /* This specifies which fields are actually set. If the STROKE_PATTERN bit
     is set, and stroke_pattern is NULL, no stroke will be drawn. */
  GooCanvasStyleValuesMask mask;

  cairo_pattern_t *stroke_pattern;
  cairo_pattern_t *fill_pattern;

  double line_width, line_join_miter_limit;

  GooCanvasLineDash *dash;

  /* We use bitmasks here to cut down on memory use a bit. I've given each
     field a few bits more than it needs to allow for new values. */
  cairo_fill_rule_t fill_rule       : 3;
  cairo_operator_t  op              : 6;
  cairo_antialias_t antialias       : 4;
  cairo_line_cap_t  line_cap        : 4;
  cairo_line_join_t line_join       : 4;
} GooCanvasStyle;

GooCanvasStyle describes the style in which an item is to be drawn, e.g. its stroke and fill colors or patterns, and its line width and style.

int ref_count; the reference count of the struct.
GooCanvasStyleValuesMask mask; a mask specifying which fields of the GooCanvasStyle have been set.
cairo_pattern_t *stroke_pattern; the stroke pattern (or color).
cairo_pattern_t *fill_pattern; the fill pattern (or color).
double line_width; the line width.
double line_join_miter_limit; the minimum angle in degrees at which the miter join style will be used. For smaller angles a bevel join is used instead.
GooCanvasLineDash *dash; the dash pattern.
cairo_fill_rule_t fill_rule : 3; the fill rule.
cairo_operator_t op : 6; the drawing operator.
cairo_antialias_t antialias : 4; the type of antialiasing to do.
cairo_line_cap_t line_cap : 4; the line cap style.
cairo_line_join_t line_join : 4; the line join style.

enum GooCanvasStyleValuesMask

typedef enum
{
  GOO_CANVAS_STYLE_STROKE_PATTERN	 = 1 << 0,
  GOO_CANVAS_STYLE_FILL_PATTERN		 = 1 << 1,
  GOO_CANVAS_STYLE_FILL_RULE		 = 1 << 2,
  GOO_CANVAS_STYLE_OPERATOR		 = 1 << 3,
  GOO_CANVAS_STYLE_ANTIALIAS		 = 1 << 4,

  GOO_CANVAS_STYLE_LINE_WIDTH		 = 1 << 5,
  GOO_CANVAS_STYLE_LINE_CAP		 = 1 << 6,
  GOO_CANVAS_STYLE_LINE_JOIN		 = 1 << 7,
  GOO_CANVAS_STYLE_LINE_JOIN_MITER_LIMIT = 1 << 8,
  GOO_CANVAS_STYLE_LINE_DASH		 = 1 << 9
} GooCanvasStyleValuesMask;

Specifies which fields of a GooCanvasStyle object have been set.

GOO_CANVAS_STYLE_STROKE_PATTERN the stroke pattern has been set.
GOO_CANVAS_STYLE_FILL_PATTERN the fill pattern has been set.
GOO_CANVAS_STYLE_FILL_RULE the fill rule has been set.
GOO_CANVAS_STYLE_OPERATOR the operator has been set.
GOO_CANVAS_STYLE_ANTIALIAS the antialias setting has been set.
GOO_CANVAS_STYLE_LINE_WIDTH the line width has been set.
GOO_CANVAS_STYLE_LINE_CAP the line cap style has been set.
GOO_CANVAS_STYLE_LINE_JOIN the line join style has been set.
GOO_CANVAS_STYLE_LINE_JOIN_MITER_LIMIT the miter limit of line joins has been set.
GOO_CANVAS_STYLE_LINE_DASH the line dash pattern has been set.

goo_canvas_style_new ()

GooCanvasStyle* goo_canvas_style_new        (void);

Creates a new GooCanvasStyle, using the default settings.

Returns : a new GooCanvasStyle.

goo_canvas_style_ref ()

GooCanvasStyle* goo_canvas_style_ref        (GooCanvasStyle *style);

Increments the reference count of a GooCanvasStyle.

style : a GooCanvasStyle.
Returns : the GooCanvasStyle.

goo_canvas_style_unref ()

void        goo_canvas_style_unref          (GooCanvasStyle *style);

Decrements the reference count of the GooCanvasStyle. If the reference count falls to 0, the GooCanvasStyle is freed.

style : a GooCanvasStyle.

GooCanvasPoints

typedef struct {
  double *coords;
  int num_points;
  int ref_count;
} GooCanvasPoints;

GooCairoPoints represents an array of points.

double *coords; the coordinates of the points, in pairs.
int num_points; the number of points.
int ref_count; the reference count of the struct.

goo_canvas_points_new ()

GooCanvasPoints* goo_canvas_points_new      (int num_points);

Creates a new GooCanvasPoints struct with space for the given number of points. It should be freed with goo_canvas_points_unref().

num_points : the number of points to create space for.
Returns : a new GooCanvasPoints struct.

goo_canvas_points_ref ()

GooCanvasPoints* goo_canvas_points_ref      (GooCanvasPoints *points);

Increments the reference count of the given GooCanvasPoints struct.

points : a GooCanvasPoints struct.
Returns : the GooCanvasPoints struct.

goo_canvas_points_unref ()

void        goo_canvas_points_unref         (GooCanvasPoints *points);

Decrements the reference count of the given GooCanvasPoints struct, freeing it if the reference count falls to zero.

points : a GooCanvasPoints struct.

GooCanvasLineDash

typedef struct {
  int ref_count;
  int num_dashes;
  double *dashes;
  double dash_offset;
} GooCanvasLineDash;

GooCanvasLineDash specifies a dash pattern to be used when drawing items.

int ref_count; the reference count of the struct.
int num_dashes; the number of dashes and gaps between them.
double *dashes; the sizes of each dash and gap.
double dash_offset; the start offset into the dash pattern.

goo_canvas_line_dash_new ()

GooCanvasLineDash* goo_canvas_line_dash_new (gint num_dashes,
                                             ...);

Creates a new dash pattern.

num_dashes : the number of dashes and gaps in the pattern.
... : the length of each dash and gap.
Returns : a new dash pattern.

goo_canvas_line_dash_newv ()

GooCanvasLineDash* goo_canvas_line_dash_newv
                                            (gint num_dashes,
                                             double *dashes);

Creates a new dash pattern. Takes ownership of the dashes vector.

num_dashes : the number of dashes and gaps in the pattern.
dashes : a g_new-allocated vector of doubles, the length of each dash and gap.
Returns : a new dash pattern.

goo_canvas_line_dash_ref ()

GooCanvasLineDash* goo_canvas_line_dash_ref (GooCanvasLineDash *dash);

Increments the reference count of the dash pattern.

dash : a GooCanvasLineDash.
Returns : the dash pattern.

goo_canvas_line_dash_unref ()

void        goo_canvas_line_dash_unref      (GooCanvasLineDash *dash);

Decrements the reference count of the dash pattern. If it falls to 0 it is freed.

dash : a GooCanvasLineDash.