1 #define __SP_FETILE_CPP__
3 /** \file
4 * SVG <feTile> implementation.
5 *
6 */
7 /*
8 * Authors:
9 * hugo Rodrigues <haa.rodrigues@gmail.com>
10 *
11 * Copyright (C) 2006 Hugo Rodrigues
12 *
13 * Released under GNU GPL, read the file 'COPYING' for more information
14 */
16 #ifdef HAVE_CONFIG_H
17 # include "config.h"
18 #endif
20 #include "attributes.h"
21 #include "svg/svg.h"
22 #include "sp-fetile.h"
23 #include "xml/repr.h"
26 /* FeTile base class */
28 static void sp_feTile_class_init(SPFeTileClass *klass);
29 static void sp_feTile_init(SPFeTile *feTile);
31 static void sp_feTile_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr);
32 static void sp_feTile_release(SPObject *object);
33 static void sp_feTile_set(SPObject *object, unsigned int key, gchar const *value);
34 static void sp_feTile_update(SPObject *object, SPCtx *ctx, guint flags);
35 static Inkscape::XML::Node *sp_feTile_write(SPObject *object, Inkscape::XML::Node *repr, guint flags);
37 static SPFilterPrimitiveClass *feTile_parent_class;
39 GType
40 sp_feTile_get_type()
41 {
42 static GType feTile_type = 0;
44 if (!feTile_type) {
45 GTypeInfo feTile_info = {
46 sizeof(SPFeTileClass),
47 NULL, NULL,
48 (GClassInitFunc) sp_feTile_class_init,
49 NULL, NULL,
50 sizeof(SPFeTile),
51 16,
52 (GInstanceInitFunc) sp_feTile_init,
53 NULL, /* value_table */
54 };
55 feTile_type = g_type_register_static(SP_TYPE_FILTER_PRIMITIVE, "SPFeTile", &feTile_info, (GTypeFlags)0);
56 }
57 return feTile_type;
58 }
60 static void
61 sp_feTile_class_init(SPFeTileClass *klass)
62 {
63 SPObjectClass *sp_object_class = (SPObjectClass *)klass;
65 feTile_parent_class = (SPFilterPrimitiveClass*)g_type_class_peek_parent(klass);
67 sp_object_class->build = sp_feTile_build;
68 sp_object_class->release = sp_feTile_release;
69 sp_object_class->write = sp_feTile_write;
70 sp_object_class->set = sp_feTile_set;
71 sp_object_class->update = sp_feTile_update;
72 }
74 static void
75 sp_feTile_init(SPFeTile *feTile)
76 {
77 }
79 /**
80 * Reads the Inkscape::XML::Node, and initializes SPFeTile variables. For this to get called,
81 * our name must be associated with a repr via "sp_object_type_register". Best done through
82 * sp-object-repr.cpp's repr_name_entries array.
83 */
84 static void
85 sp_feTile_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr)
86 {
87 if (((SPObjectClass *) feTile_parent_class)->build) {
88 ((SPObjectClass *) feTile_parent_class)->build(object, document, repr);
89 }
91 /*LOAD ATTRIBUTES FROM REPR HERE*/
92 }
94 /**
95 * Drops any allocated memory.
96 */
97 static void
98 sp_feTile_release(SPObject *object)
99 {
100 if (((SPObjectClass *) feTile_parent_class)->release)
101 ((SPObjectClass *) feTile_parent_class)->release(object);
102 }
104 /**
105 * Sets a specific value in the SPFeTile.
106 */
107 static void
108 sp_feTile_set(SPObject *object, unsigned int key, gchar const *value)
109 {
110 SPFeTile *feTile = SP_FETILE(object);
111 (void)feTile;
113 switch(key) {
114 /*DEAL WITH SETTING ATTRIBUTES HERE*/
115 default:
116 if (((SPObjectClass *) feTile_parent_class)->set)
117 ((SPObjectClass *) feTile_parent_class)->set(object, key, value);
118 break;
119 }
121 }
123 /**
124 * Receives update notifications.
125 */
126 static void
127 sp_feTile_update(SPObject *object, SPCtx *ctx, guint flags)
128 {
129 if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG |
130 SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) {
132 /* do something to trigger redisplay, updates? */
134 }
136 if (((SPObjectClass *) feTile_parent_class)->update) {
137 ((SPObjectClass *) feTile_parent_class)->update(object, ctx, flags);
138 }
139 }
141 /**
142 * Writes its settings to an incoming repr object, if any.
143 */
144 static Inkscape::XML::Node *
145 sp_feTile_write(SPObject *object, Inkscape::XML::Node *repr, guint flags)
146 {
147 // Inkscape-only object, not copied during an "plain SVG" dump:
148 if (flags & SP_OBJECT_WRITE_EXT) {
149 if (repr) {
150 // is this sane?
151 repr->mergeFrom(SP_OBJECT_REPR(object), "id");
152 } else {
153 repr = SP_OBJECT_REPR(object)->duplicate(NULL); // FIXME
154 }
155 }
157 if (((SPObjectClass *) feTile_parent_class)->write) {
158 ((SPObjectClass *) feTile_parent_class)->write(object, repr, flags);
159 }
161 return repr;
162 }
165 /*
166 Local Variables:
167 mode:c++
168 c-file-style:"stroustrup"
169 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
170 indent-tabs-mode:nil
171 fill-column:99
172 End:
173 */
174 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :