2 * Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation
5 * This file is part of the Gnome Library.
7 * The Gnome Library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public License as
9 * published by the Free Software Foundation; either version 2 of the
10 * License, or (at your option) any later version.
12 * The Gnome Library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
17 * You should have received a copy of the GNU Library General Public
18 * License along with the Gnome Library; see the file COPYING.LIB. If not,
19 * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
25 /* Miscellaneous utility functions for the GnomeCanvas widget
27 * GnomeCanvas is basically a port of the Tk toolkit's most excellent canvas widget. Tk is
28 * copyrighted by the Regents of the University of California, Sun Microsystems, and other parties.
30 * Author: Federico Mena <federico@nuclecu.unam.mx>
33 #ifndef GNOME_CANVAS_UTIL_H
34 #define GNOME_CANVAS_UTIL_H
36 #include <libgnomecanvas/gnome-canvas.h>
38 #include <libart_lgpl/art_svp.h>
39 #include <libart_lgpl/art_vpath.h>
40 #include <libart_lgpl/art_svp_vpath_stroke.h>
45 typedef struct _GnomeCanvasPoints GnomeCanvasPoints;
47 /* This structure defines an array of points. X coordinates are stored in the even-numbered
48 * indices, and Y coordinates are stored in the odd-numbered indices. num_points indicates the
49 * number of points, so the array is 2*num_points elements big.
51 struct _GnomeCanvasPoints {
58 /* Allocate a new GnomeCanvasPoints structure with enough space for the specified number of points */
59 GnomeCanvasPoints *gnome_canvas_points_new (int num_points);
61 /* Increate ref count */
62 GnomeCanvasPoints *gnome_canvas_points_ref (GnomeCanvasPoints *points);
63 #define gnome_canvas_points_unref gnome_canvas_points_free
65 /* Decrease ref count and free structure if it has reached zero */
66 void gnome_canvas_points_free (GnomeCanvasPoints *points);
68 /* Given three points forming an angle, compute the coordinates of the inside and outside points of
69 * the mitered corner formed by a line of a given width at that angle.
71 * If the angle is less than 11 degrees, then FALSE is returned and the return points are not
72 * modified. Otherwise, TRUE is returned.
74 int gnome_canvas_get_miter_points (double x1, double y1, double x2, double y2, double x3, double y3,
76 double *mx1, double *my1, double *mx2, double *my2);
78 /* Compute the butt points of a line segment. If project is FALSE, then the results are as follows:
80 * -------------------* (bx1, by1)
82 * (x1, y1) *------------------* (x2, y2)
84 * -------------------* (bx2, by2)
86 * that is, the line is not projected beyond (x2, y2). If project is TRUE, then the results are as
89 * -------------------* (bx1, by1)
91 * (x1, y1) *-------------* |
93 * -------------------* (bx2, by2)
95 void gnome_canvas_get_butt_points (double x1, double y1, double x2, double y2,
96 double width, int project,
97 double *bx1, double *by1, double *bx2, double *by2);
99 /* Calculate the distance from a polygon to a point. The polygon's X coordinates are in the even
100 * indices of the poly array, and the Y coordinates are in the odd indices.
102 double gnome_canvas_polygon_to_point (double *poly, int num_points, double x, double y);
105 /* Render the svp over the buf. */
106 void gnome_canvas_render_svp (GnomeCanvasBuf *buf, ArtSVP *svp, guint32 rgba);
108 /* Sets the svp to the new value, requesting repaint on what's changed. This function takes responsibility for
111 void gnome_canvas_update_svp (GnomeCanvas *canvas, ArtSVP **p_svp, ArtSVP *new_svp);
113 /* Sets the svp to the new value, clipping if necessary, and requesting repaint
114 * on what's changed. This function takes responsibility for freeing new_svp.
116 void gnome_canvas_update_svp_clip (GnomeCanvas *canvas, ArtSVP **p_svp, ArtSVP *new_svp,
119 /* Sets the svp to the new value, requesting repaint on what's changed. This
120 * function takes responsibility for freeing new_svp. This routine also adds the
121 * svp's bbox to the item's.
123 void gnome_canvas_item_reset_bounds (GnomeCanvasItem *item);
125 /* Sets the svp to the new value, requesting repaint on what's changed. This function takes responsibility for
126 * freeing new_svp. This routine also adds the svp's bbox to the item's.
128 void gnome_canvas_item_update_svp (GnomeCanvasItem *item, ArtSVP **p_svp, ArtSVP *new_svp);
130 /* Sets the svp to the new value, clipping if necessary, and requesting repaint
131 * on what's changed. This function takes responsibility for freeing new_svp.
133 void gnome_canvas_item_update_svp_clip (GnomeCanvasItem *item, ArtSVP **p_svp, ArtSVP *new_svp,
136 /* Request redraw of the svp if in aa mode, or the entire item in in xlib
139 void gnome_canvas_item_request_redraw_svp (GnomeCanvasItem *item, const ArtSVP *svp);
141 /* Sets the bbox to the new value, requesting full repaint. */
142 void gnome_canvas_update_bbox (GnomeCanvasItem *item, int x1, int y1, int x2, int y2);
144 /* Ensure that the buffer is in RGB format, suitable for compositing. */
145 void gnome_canvas_buf_ensure_buf (GnomeCanvasBuf *buf);
147 /* Convert from GDK line join specifier to libart. */
148 ArtPathStrokeJoinType gnome_canvas_join_gdk_to_art (GdkJoinStyle gdk_join);
150 /* Convert from GDK line cap specifier to libart. */
151 ArtPathStrokeCapType gnome_canvas_cap_gdk_to_art (GdkCapStyle gdk_cap);