1
#define __SP_POLYLINE_C__
4
* SVG <polyline> implementation
7
* Lauris Kaplinski <lauris@kaplinski.com>
9
* Copyright (C) 1999-2002 Lauris Kaplinski
11
* Released under GNU GPL, read the file 'COPYING' for more information
16
#include "attributes.h"
17
#include "sp-polyline.h"
18
#include "display/curve.h"
19
#include <glibmm/i18n.h>
23
static void sp_polyline_class_init (SPPolyLineClass *klass);
24
static void sp_polyline_init (SPPolyLine *polyline);
26
static void sp_polyline_build (SPObject * object, SPDocument * document, Inkscape::XML::Node * repr);
27
static void sp_polyline_set (SPObject *object, unsigned int key, const gchar *value);
28
static Inkscape::XML::Node *sp_polyline_write (SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags);
30
static gchar * sp_polyline_description (SPItem * item);
32
static SPShapeClass *parent_class;
35
sp_polyline_get_type (void)
37
static GType polyline_type = 0;
40
GTypeInfo polyline_info = {
41
sizeof (SPPolyLineClass),
43
NULL, /* base_finalize */
44
(GClassInitFunc) sp_polyline_class_init,
45
NULL, /* klass_finalize */
46
NULL, /* klass_data */
49
(GInstanceInitFunc) sp_polyline_init,
50
NULL, /* value_table */
52
polyline_type = g_type_register_static (SP_TYPE_SHAPE, "SPPolyLine", &polyline_info, (GTypeFlags)0);
58
sp_polyline_class_init (SPPolyLineClass *klass)
60
GObjectClass * gobject_class;
61
SPObjectClass * sp_object_class;
62
SPItemClass * item_class;
64
gobject_class = (GObjectClass *) klass;
65
sp_object_class = (SPObjectClass *) klass;
66
item_class = (SPItemClass *) klass;
68
parent_class = (SPShapeClass *)g_type_class_ref (SP_TYPE_SHAPE);
70
sp_object_class->build = sp_polyline_build;
71
sp_object_class->set = sp_polyline_set;
72
sp_object_class->write = sp_polyline_write;
74
item_class->description = sp_polyline_description;
78
sp_polyline_init (SPPolyLine * /*polyline*/)
84
sp_polyline_build (SPObject * object, SPDocument * document, Inkscape::XML::Node * repr)
87
if (((SPObjectClass *) parent_class)->build)
88
((SPObjectClass *) parent_class)->build (object, document, repr);
90
sp_object_read_attr (object, "points");
94
sp_polyline_set (SPObject *object, unsigned int key, const gchar *value)
98
polyline = SP_POLYLINE (object);
101
case SP_ATTR_POINTS: {
108
curve = new SPCurve ();
117
while (*cptr != '\0' && (*cptr == ',' || *cptr == '\x20' || *cptr == '\x9' || *cptr == '\xD' || *cptr == '\xA')) {
122
x = g_ascii_strtod (cptr, &eptr);
123
if (eptr == cptr) break;
126
while (*cptr != '\0' && (*cptr == ',' || *cptr == '\x20' || *cptr == '\x9' || *cptr == '\xD' || *cptr == '\xA')) {
131
y = g_ascii_strtod (cptr, &eptr);
132
if (eptr == cptr) break;
142
sp_shape_set_curve (SP_SHAPE (polyline), curve, TRUE);
147
if (((SPObjectClass *) parent_class)->set)
148
((SPObjectClass *) parent_class)->set (object, key, value);
153
static Inkscape::XML::Node *
154
sp_polyline_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags)
156
SPPolyLine *polyline;
158
polyline = SP_POLYLINE (object);
160
if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) {
161
repr = xml_doc->createElement("svg:polyline");
164
if (repr != SP_OBJECT_REPR (object)) {
165
repr->mergeFrom(SP_OBJECT_REPR (object), "id");
168
if (((SPObjectClass *) (parent_class))->write)
169
((SPObjectClass *) (parent_class))->write (object, xml_doc, repr, flags);
175
sp_polyline_description(SPItem */*item*/)
177
return g_strdup(_("<b>Polyline</b>"));