5
5
* Copyright (C) 2003 Michael Natterer <mitch@gimp.org>
6
6
* Simon Budig <simon@gimp.org>
8
* This program is free software; you can redistribute it and/or modify
8
* This program is free software: you can redistribute it and/or modify
9
9
* it under the terms of the GNU General Public License as published by
10
* the Free Software Foundation; either version 2 of the License, or
10
* the Free Software Foundation; either version 3 of the License, or
11
11
* (at your option) any later version.
13
13
* This program is distributed in the hope that it will be useful,
16
16
* GNU General Public License for more details.
18
18
* You should have received a copy of the GNU General Public License
19
* along with this program; if not, write to the Free Software
20
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19
* along with this program. If not, see <http://www.gnu.org/licenses/>.
23
22
#include "config.h"
25
25
#include <gtk/gtk.h>
27
27
#include "libgimpmath/gimpmath.h"
38
38
#include "gimpviewrenderervectors.h"
41
static void gimp_view_renderer_vectors_draw (GimpViewRenderer *renderer,
44
const GdkRectangle *area);
41
static void gimp_view_renderer_vectors_draw (GimpViewRenderer *renderer,
45
gint available_height);
47
48
G_DEFINE_TYPE (GimpViewRendererVectors, gimp_view_renderer_vectors,
67
gimp_view_renderer_vectors_draw (GimpViewRenderer *renderer,
70
const GdkRectangle *area)
68
gimp_view_renderer_vectors_draw (GimpViewRenderer *renderer,
72
gint available_height)
72
GtkStyle *style = gtk_widget_get_style (widget);
73
GimpVectors *vectors = GIMP_VECTORS (renderer->viewable);
74
GimpBezierDesc *bezdesc;
74
GtkStyle *style = gtk_widget_get_style (widget);
75
GimpVectors *vectors = GIMP_VECTORS (renderer->viewable);
76
const GimpBezierDesc *desc;
79
78
gdk_cairo_set_source_color (cr, &style->white);
81
x = area->x + (area->width - renderer->width) / 2;
82
y = area->y + (area->height - renderer->height) / 2;
84
cairo_translate (cr, x, y);
81
(available_width - renderer->width) / 2,
82
(available_height - renderer->height) / 2);
85
83
cairo_rectangle (cr, 0, 0, renderer->width, renderer->height);
86
84
cairo_clip_preserve (cr);
89
xscale = (gdouble) renderer->width / (gdouble) gimp_item_width (GIMP_ITEM (vectors));
90
yscale = (gdouble) renderer->height / (gdouble) gimp_item_height (GIMP_ITEM (vectors));
91
cairo_scale (cr, xscale, yscale);
93
/* determine line width */
94
xscale = yscale = 0.5;
95
cairo_device_to_user_distance (cr, &xscale, &yscale);
97
cairo_set_line_width (cr, MAX (xscale, yscale));
98
gdk_cairo_set_source_color (cr, &style->black);
100
bezdesc = gimp_vectors_make_bezier (vectors);
87
desc = gimp_vectors_get_bezier (vectors);
104
cairo_append_path (cr, (cairo_path_t *) bezdesc);
94
xscale = ((gdouble) renderer->width /
95
(gdouble) gimp_item_get_width (GIMP_ITEM (vectors)));
96
yscale = ((gdouble) renderer->height /
97
(gdouble) gimp_item_get_height (GIMP_ITEM (vectors)));
99
cairo_scale (cr, xscale, yscale);
101
/* determine line width */
102
xscale = yscale = 0.5;
103
cairo_device_to_user_distance (cr, &xscale, &yscale);
105
cairo_set_line_width (cr, MAX (xscale, yscale));
106
gdk_cairo_set_source_color (cr, &style->black);
108
cairo_append_path (cr, (cairo_path_t *) desc);
105
109
cairo_stroke (cr);
106
g_free (bezdesc->data);