~ubuntu-branches/ubuntu/gutsy/goocanvas/gutsy

« back to all changes in this revision

Viewing changes to src/goocanvasutils.h

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2007-02-20 18:25:58 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20070220182558-tjofc7wdzkzlxzor
Tags: 0.6-0ubuntu1
* New upstream version (UVF exception #86533):
  - Major rewrite to make the model optional, so people can choose to have
    either a simple canvas or a model/view canvas. The standard items can be
    used in either scenario.
  - Added support for cascading style properties (things like fill color, 
    stroke width, font etc.). Properties use a GQuark for a unique 
    identifier, and a GValue for the property value, so they are very 
    flexible.
  - Added GooCanvasTable item to layout child items.
  - Made it much easier to create new items, by subclassing 
    GooCanvasItemSimple which handles most of the work. See demo/demo-item.c 
    for a simple item.
  - Added support for different units - pixels, points, inches or 
    millimeters, and allow setting of vertical 
    and horizontal resolution (dpi).
  - Added workaround for cairo's 16-bit limit, to support large canvases.
  - Added demo/scalability-demo which creates 100,000 items over a large 
    canvas. It takes a few seconds to create all the items, but once created 
    it seems to work fast enough.
  - Improved the animation code, supporting relative or absolute values for
    the x, y, scale and rotation.
  - Added "clip-path" and "clip-fill-rule" to specify a clip path 
    for an item.
* debian/control:
  - updated GTK requirement to 2.10
* debian/control, debian/libgoocanvas0.install, debian/libgoocanvas1.install,
  debian/rules:
  - updated for soname change

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
/*
16
16
 * Enum types.
17
17
 */
18
 
#define GOO_TYPE_CANVAS_POINTER_EVENTS   (goo_canvas_pointer_events_get_type ())
19
 
GType goo_canvas_pointer_events_get_type   (void) G_GNUC_CONST;
20
18
 
21
19
/**
22
20
 * GooCanvasPointerEvents
50
48
 */
51
49
typedef enum
52
50
{
53
 
  /* If the item must be visible to receive events. */
54
51
  GOO_CANVAS_EVENTS_VISIBLE_MASK        = 1 << 0,
55
 
 
56
 
  /* If the fill or stroke must be painted to receive events. */
57
52
  GOO_CANVAS_EVENTS_PAINTED_MASK        = 1 << 1,
58
 
 
59
 
  /* If the fill should receive events. */
60
53
  GOO_CANVAS_EVENTS_FILL_MASK           = 1 << 2,
61
 
 
62
 
  /* If the stroke should receive events. */
63
54
  GOO_CANVAS_EVENTS_STROKE_MASK         = 1 << 3,
64
55
 
65
 
 
66
56
  GOO_CANVAS_EVENTS_NONE                = 0,
67
 
 
68
 
  GOO_CANVAS_EVENTS_VISIBLE_PAINTED     = GOO_CANVAS_EVENTS_VISIBLE_MASK
69
 
                                          | GOO_CANVAS_EVENTS_PAINTED_MASK
70
 
                                          | GOO_CANVAS_EVENTS_FILL_MASK
71
 
                                          | GOO_CANVAS_EVENTS_STROKE_MASK,
72
 
  GOO_CANVAS_EVENTS_VISIBLE_FILL        = GOO_CANVAS_EVENTS_VISIBLE_MASK
73
 
                                          | GOO_CANVAS_EVENTS_FILL_MASK,
74
 
  GOO_CANVAS_EVENTS_VISIBLE_STROKE      = GOO_CANVAS_EVENTS_VISIBLE_MASK
75
 
                                          | GOO_CANVAS_EVENTS_STROKE_MASK,
76
 
  GOO_CANVAS_EVENTS_VISIBLE             = GOO_CANVAS_EVENTS_VISIBLE_MASK
77
 
                                          | GOO_CANVAS_EVENTS_FILL_MASK
78
 
                                          | GOO_CANVAS_EVENTS_STROKE_MASK,
79
 
 
80
 
  GOO_CANVAS_EVENTS_PAINTED             = GOO_CANVAS_EVENTS_PAINTED_MASK
81
 
                                          | GOO_CANVAS_EVENTS_FILL_MASK
82
 
                                          | GOO_CANVAS_EVENTS_STROKE_MASK,
 
57
  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,
 
58
  GOO_CANVAS_EVENTS_VISIBLE_FILL        = GOO_CANVAS_EVENTS_VISIBLE_MASK | GOO_CANVAS_EVENTS_FILL_MASK,
 
59
  GOO_CANVAS_EVENTS_VISIBLE_STROKE      = GOO_CANVAS_EVENTS_VISIBLE_MASK | GOO_CANVAS_EVENTS_STROKE_MASK,
 
60
  GOO_CANVAS_EVENTS_VISIBLE             = GOO_CANVAS_EVENTS_VISIBLE_MASK | GOO_CANVAS_EVENTS_FILL_MASK | GOO_CANVAS_EVENTS_STROKE_MASK,
 
61
  GOO_CANVAS_EVENTS_PAINTED             = GOO_CANVAS_EVENTS_PAINTED_MASK | GOO_CANVAS_EVENTS_FILL_MASK | GOO_CANVAS_EVENTS_STROKE_MASK,
83
62
  GOO_CANVAS_EVENTS_FILL                = GOO_CANVAS_EVENTS_FILL_MASK,
84
63
  GOO_CANVAS_EVENTS_STROKE              = GOO_CANVAS_EVENTS_STROKE_MASK,
85
 
  GOO_CANVAS_EVENTS_ALL                 = GOO_CANVAS_EVENTS_FILL_MASK
86
 
                                          | GOO_CANVAS_EVENTS_STROKE_MASK
 
64
  GOO_CANVAS_EVENTS_ALL                 = GOO_CANVAS_EVENTS_FILL_MASK | GOO_CANVAS_EVENTS_STROKE_MASK
87
65
} GooCanvasPointerEvents;
88
66
 
89
67
 
90
 
#define GOO_TYPE_CANVAS_ITEM_VISIBILITY   (goo_canvas_item_visibility_get_type ())
91
 
GType goo_canvas_item_visibility_get_type   (void) G_GNUC_CONST;
92
 
 
93
68
/**
94
69
 * GooCanvasItemVisibility
 
70
 * @GOO_CANVAS_ITEM_HIDDEN: the item is invisible, and is not allocated any
 
71
 *  space in layout container items such as #GooCanvasTable.
 
72
 * @GOO_CANVAS_ITEM_INVISIBLE: the item is invisible, but it is still allocated
 
73
 *  space in layout container items.
95
74
 * @GOO_CANVAS_ITEM_VISIBLE: the item is visible.
96
75
 * @GOO_CANVAS_ITEM_VISIBLE_ABOVE_THRESHOLD: the item is visible when the
97
76
 *  canvas scale setting is greater than or equal to the item's visibility
98
77
 *  threshold setting.
99
 
 * @GOO_CANVAS_ITEM_INVISIBLE: the item is invisible.
100
78
 *
101
79
 * The #GooCanvasItemVisibility enumeration is used to specify when a canvas
102
80
 * item is visible.
103
81
 */
 
82
/* NOTE: Values are important here, as we test for <= GOO_CANVAS_ITEM_INVISIBLE
 
83
   to check if an item is invisible or hidden. */
104
84
typedef enum
105
85
{
106
 
  GOO_CANVAS_ITEM_VISIBLE,
107
 
  GOO_CANVAS_ITEM_VISIBLE_ABOVE_THRESHOLD,
108
 
  GOO_CANVAS_ITEM_INVISIBLE
 
86
  GOO_CANVAS_ITEM_HIDDEN                        = 0,
 
87
  GOO_CANVAS_ITEM_INVISIBLE                     = 1,
 
88
  GOO_CANVAS_ITEM_VISIBLE                       = 2,
 
89
  GOO_CANVAS_ITEM_VISIBLE_ABOVE_THRESHOLD       = 3,
109
90
} GooCanvasItemVisibility;
110
91
 
111
92
 
 
93
/**
 
94
 * GooCanvasPathCommandType
 
95
 * @GOO_CANVAS_PATH_MOVE_TO: move to the given point.
 
96
 * @GOO_CANVAS_PATH_CLOSE_PATH: close the current path, drawing a line from the
 
97
 *  current position to the start of the path.
 
98
 * @GOO_CANVAS_PATH_LINE_TO: draw a line to the given point.
 
99
 * @GOO_CANVAS_PATH_HORIZONTAL_LINE_TO: draw a horizontal line to the given
 
100
 *  x coordinate.
 
101
 * @GOO_CANVAS_PATH_VERTICAL_LINE_TO: draw a vertical line to the given y
 
102
 *  coordinate.
 
103
 * @GOO_CANVAS_PATH_CURVE_TO: draw a bezier curve using two control
 
104
 *  points to the given point.
 
105
 * @GOO_CANVAS_PATH_SMOOTH_CURVE_TO: draw a bezier curve using a reflection
 
106
 *  of the last control point of the last curve as the first control point,
 
107
 *  and one new control point, to the given point.
 
108
 * @GOO_CANVAS_PATH_QUADRATIC_CURVE_TO: draw a quadratic bezier curve using
 
109
 *  a single control point to the given point.
 
110
 * @GOO_CANVAS_PATH_SMOOTH_QUADRATIC_CURVE_TO: draw a quadratic bezier curve
 
111
 *  using a reflection of the control point from the previous curve as the
 
112
 *  control point, to the given point.
 
113
 * @GOO_CANVAS_PATH_ELLIPTICAL_ARC: draw an elliptical arc, using the given
 
114
 *  2 radii, the x axis rotation, and the 2 flags to disambiguate the arc,
 
115
 *  to the given point.
 
116
 *
 
117
 * GooCanvasPathCommandType specifies the type of each command in the path.
 
118
 * See the path element in the <ulink url="http://www.w3.org/Graphics/SVG/">
 
119
 * Scalable Vector Graphics (SVG) specification</ulink> for more details.
 
120
 */
 
121
typedef enum
 
122
{
 
123
  /* Simple commands like moveto and lineto: MmZzLlHhVv. */
 
124
  GOO_CANVAS_PATH_MOVE_TO,
 
125
  GOO_CANVAS_PATH_CLOSE_PATH,
 
126
  GOO_CANVAS_PATH_LINE_TO,
 
127
  GOO_CANVAS_PATH_HORIZONTAL_LINE_TO,
 
128
  GOO_CANVAS_PATH_VERTICAL_LINE_TO,
 
129
 
 
130
  /* Bezier curve commands: CcSsQqTt. */
 
131
  GOO_CANVAS_PATH_CURVE_TO,
 
132
  GOO_CANVAS_PATH_SMOOTH_CURVE_TO,
 
133
  GOO_CANVAS_PATH_QUADRATIC_CURVE_TO,
 
134
  GOO_CANVAS_PATH_SMOOTH_QUADRATIC_CURVE_TO,
 
135
 
 
136
  /* The elliptical arc commands: Aa. */
 
137
  GOO_CANVAS_PATH_ELLIPTICAL_ARC
 
138
} GooCanvasPathCommandType;
 
139
 
 
140
 
 
141
typedef union _GooCanvasPathCommand  GooCanvasPathCommand;
 
142
 
 
143
/* Note that the command type is always the first element in each struct, so
 
144
   we can always use it whatever type of command it is. */
 
145
 
 
146
/**
 
147
 * GooCanvasPathCommand
 
148
 *
 
149
 * GooCanvasPathCommand holds the data for each command in the path.
 
150
 *
 
151
 * The @relative flag specifies that the coordinates for the command are
 
152
 * relative to the current point. Otherwise they are assumed to be absolute
 
153
 * coordinates.
 
154
 */
 
155
union _GooCanvasPathCommand
 
156
{
 
157
  /* Simple commands like moveto and lineto: MmZzLlHhVv. */
 
158
  struct {
 
159
    guint type : 5; /* GooCanvasPathCommandType */
 
160
    guint relative : 1;
 
161
    gdouble x, y;
 
162
  } simple;
 
163
 
 
164
  /* Bezier curve commands: CcSsQqTt. */
 
165
  struct {
 
166
    guint type : 5; /* GooCanvasPathCommandType */
 
167
    guint relative : 1;
 
168
    gdouble x, y, x1, y1, x2, y2;
 
169
  } curve;
 
170
 
 
171
  /* The elliptical arc commands: Aa. */
 
172
  struct {
 
173
    guint type : 5; /* GooCanvasPathCommandType */
 
174
    guint relative : 1;
 
175
    guint large_arc_flag : 1;
 
176
    guint sweep_flag : 1;
 
177
    gdouble rx, ry, x_axis_rotation, x, y;
 
178
  } arc;
 
179
};
 
180
 
 
181
 
 
182
GArray* goo_canvas_parse_path_data      (const gchar       *path_data);
 
183
void    goo_canvas_create_path          (GArray            *commands,
 
184
                                         cairo_t           *cr);
 
185
 
 
186
 
112
187
/*
113
188
 * Cairo utilities.
114
189
 */
131
206
  double dash_offset;
132
207
};
133
208
 
134
 
#define GOO_TYPE_CANVAS_LINE_DASH   (goo_canvas_line_dash_get_type ())
135
 
 
 
209
#define GOO_TYPE_CANVAS_LINE_DASH  (goo_canvas_line_dash_get_type ())
136
210
GType              goo_canvas_line_dash_get_type (void) G_GNUC_CONST;
137
211
GooCanvasLineDash* goo_canvas_line_dash_new   (gint               num_dashes,
138
212
                                               ...);
141
215
GooCanvasLineDash* goo_canvas_line_dash_ref   (GooCanvasLineDash *dash);
142
216
void               goo_canvas_line_dash_unref (GooCanvasLineDash *dash);
143
217
 
144
 
 
145
218
#define GOO_TYPE_CAIRO_MATRIX      (goo_cairo_matrix_get_type())
146
 
 
147
219
GType              goo_cairo_matrix_get_type  (void) G_GNUC_CONST;
148
220
cairo_matrix_t*    goo_cairo_matrix_copy      (cairo_matrix_t    *matrix);
149
221
 
150
 
 
151
222
#define GOO_TYPE_CAIRO_PATTERN     (goo_cairo_pattern_get_type ())
152
223
GType              goo_cairo_pattern_get_type (void) G_GNUC_CONST;
153
224
 
 
225
#define GOO_TYPE_CAIRO_FILL_RULE   (goo_cairo_fill_rule_get_type ())
 
226
GType              goo_cairo_fill_rule_get_type (void) G_GNUC_CONST;
 
227
 
 
228
#define GOO_TYPE_CAIRO_OPERATOR    (goo_cairo_operator_get_type())
 
229
GType              goo_cairo_operator_get_type  (void) G_GNUC_CONST;
 
230
 
 
231
#define GOO_TYPE_CAIRO_ANTIALIAS   (goo_cairo_antialias_get_type())
 
232
GType              goo_cairo_antialias_get_type (void) G_GNUC_CONST;
 
233
 
 
234
#define GOO_TYPE_CAIRO_LINE_CAP    (goo_cairo_line_cap_get_type ())
 
235
GType              goo_cairo_line_cap_get_type  (void) G_GNUC_CONST;
 
236
 
 
237
#define GOO_TYPE_CAIRO_LINE_JOIN   (goo_cairo_line_join_get_type ())
 
238
GType              goo_cairo_line_join_get_type (void) G_GNUC_CONST;
 
239
 
154
240
 
155
241
G_END_DECLS
156
242