Code

4fe25d48ace54cdc2a6fbcdc02c63c462ca073c0
[inkscape.git] / src / sp-fespecularlighting.cpp
1 #define __SP_FESPECULARLIGHTING_CPP__
3 /** \file
4  * SVG <feSpecularLighting> 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-fespecularlighting.h"
23 #include "xml/repr.h"
25 //#define SP_MACROS_SILENT
26 //#include "macros.h"
28 #define DEBUG_FESPECULARLIGHTING
29 #ifdef DEBUG_FESPECULARLIGHTING
30 # define debug(f, a...) { g_print("%s(%d) %s:", \
31                                   __FILE__,__LINE__,__FUNCTION__); \
32                           g_print(f, ## a); \
33                           g_print("\n"); \
34                         }
35 #else
36 # define debug(f, a...) /**/
37 #endif
39 /* FeSpecularLighting base class */
41 static void sp_feSpecularLighting_class_init(SPFeSpecularLightingClass *klass);
42 static void sp_feSpecularLighting_init(SPFeSpecularLighting *feSpecularLighting);
44 static void sp_feSpecularLighting_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr);
45 static void sp_feSpecularLighting_release(SPObject *object);
46 static void sp_feSpecularLighting_set(SPObject *object, unsigned int key, gchar const *value);
47 static void sp_feSpecularLighting_update(SPObject *object, SPCtx *ctx, guint flags);
48 static Inkscape::XML::Node *sp_feSpecularLighting_write(SPObject *object, Inkscape::XML::Node *repr, guint flags);
50 static SPObjectClass *feSpecularLighting_parent_class;
52 GType
53 sp_feSpecularLighting_get_type()
54 {
55     static GType feSpecularLighting_type = 0;
57     if (!feSpecularLighting_type) {
58         GTypeInfo feSpecularLighting_info = {
59             sizeof(SPFeSpecularLightingClass),
60             NULL, NULL,
61             (GClassInitFunc) sp_feSpecularLighting_class_init,
62             NULL, NULL,
63             sizeof(SPFeSpecularLighting),
64             16,
65             (GInstanceInitFunc) sp_feSpecularLighting_init,
66             NULL,    /* value_table */
67         };
68         feSpecularLighting_type = g_type_register_static(SP_TYPE_OBJECT, "SPFeSpecularLighting", &feSpecularLighting_info, (GTypeFlags)0);
69     }
70     return feSpecularLighting_type;
71 }
73 static void
74 sp_feSpecularLighting_class_init(SPFeSpecularLightingClass *klass)
75 {
76     SPObjectClass *sp_object_class = (SPObjectClass *)klass;
78     feSpecularLighting_parent_class = (SPObjectClass*)g_type_class_peek_parent(klass);
80     sp_object_class->build = sp_feSpecularLighting_build;
81     sp_object_class->release = sp_feSpecularLighting_release;
82     sp_object_class->write = sp_feSpecularLighting_write;
83     sp_object_class->set = sp_feSpecularLighting_set;
84     sp_object_class->update = sp_feSpecularLighting_update;
85 }
87 static void
88 sp_feSpecularLighting_init(SPFeSpecularLighting *feSpecularLighting)
89 {
90     debug("0x%p",feSpecularLighting);
91 }
93 /**
94  * Reads the Inkscape::XML::Node, and initializes SPFeSpecularLighting variables.  For this to get called,
95  * our name must be associated with a repr via "sp_object_type_register".  Best done through
96  * sp-object-repr.cpp's repr_name_entries array.
97  */
98 static void
99 sp_feSpecularLighting_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr)
101     debug("0x%p",object);
102     if (((SPObjectClass *) feSpecularLighting_parent_class)->build) {
103         ((SPObjectClass *) feSpecularLighting_parent_class)->build(object, document, repr);
104     }
106     /*LOAD ATTRIBUTES FROM REPR HERE*/
109 /**
110  * Drops any allocated memory.
111  */
112 static void
113 sp_feSpecularLighting_release(SPObject *object)
115     debug("0x%p",object);
117     if (((SPObjectClass *) feSpecularLighting_parent_class)->release)
118         ((SPObjectClass *) feSpecularLighting_parent_class)->release(object);
121 /**
122  * Sets a specific value in the SPFeSpecularLighting.
123  */
124 static void
125 sp_feSpecularLighting_set(SPObject *object, unsigned int key, gchar const *value)
127     debug("0x%p %s(%u): '%s'",object,
128             sp_attribute_name(key),key,value);
129     SPFeSpecularLighting *feSpecularLighting = SP_FESPECULARLIGHTING(object);
131     switch(key) {\r
132         /*DEAL WITH SETTING ATTRIBUTES HERE*/
133         default:
134             if (((SPObjectClass *) feSpecularLighting_parent_class)->set)
135                 ((SPObjectClass *) feSpecularLighting_parent_class)->set(object, key, value);
136             break;
137     }
141 /**
142  * Receives update notifications.
143  */
144 static void
145 sp_feSpecularLighting_update(SPObject *object, SPCtx *ctx, guint flags)
147     debug("0x%p",object);
149     if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG |
150                  SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) {
152         /* do something to trigger redisplay, updates? */
154     }
156     if (((SPObjectClass *) feSpecularLighting_parent_class)->update) {
157         ((SPObjectClass *) feSpecularLighting_parent_class)->update(object, ctx, flags);
158     }
161 /**
162  * Writes its settings to an incoming repr object, if any.
163  */
164 static Inkscape::XML::Node *
165 sp_feSpecularLighting_write(SPObject *object, Inkscape::XML::Node *repr, guint flags)
167     debug("0x%p",object);
169     // Inkscape-only object, not copied during an "plain SVG" dump:
170     if (flags & SP_OBJECT_WRITE_EXT) {
171         if (repr) {
172             // is this sane?
173             repr->mergeFrom(SP_OBJECT_REPR(object), "id");
174         } else {
175             repr = SP_OBJECT_REPR(object)->duplicate();
176         }
177     }
179     if (((SPObjectClass *) feSpecularLighting_parent_class)->write) {
180         ((SPObjectClass *) feSpecularLighting_parent_class)->write(object, repr, flags);
181     }
183     return repr;
187 /*
188   Local Variables:
189   mode:c++
190   c-file-style:"stroustrup"
191   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
192   indent-tabs-mode:nil
193   fill-column:99
194   End:
195 */
196 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :