sp-fecomposite.cpp revision 1ed1764f573921b7f9d210a3fcca322234c36480
390N/A#define __SP_FECOMPOSITE_CPP__
390N/A
390N/A/** \file
390N/A * SVG <feComposite> implementation.
390N/A *
390N/A */
390N/A/*
390N/A * Authors:
390N/A * hugo Rodrigues <haa.rodrigues@gmail.com>
390N/A *
390N/A * Copyright (C) 2006 Hugo Rodrigues
390N/A *
390N/A * Released under GNU GPL, read the file 'COPYING' for more information
390N/A */
390N/A
390N/A#ifdef HAVE_CONFIG_H
390N/A# include "config.h"
390N/A#endif
390N/A
390N/A#include "attributes.h"
390N/A#include "svg/svg.h"
390N/A#include "sp-fecomposite.h"
390N/A#include "xml/repr.h"
390N/A
390N/A
390N/A/* FeComposite base class */
390N/A
390N/Astatic void sp_feComposite_class_init(SPFeCompositeClass *klass);
390N/Astatic void sp_feComposite_init(SPFeComposite *feComposite);
390N/A
390N/Astatic void sp_feComposite_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr);
390N/Astatic void sp_feComposite_release(SPObject *object);
390N/Astatic void sp_feComposite_set(SPObject *object, unsigned int key, gchar const *value);
390N/Astatic void sp_feComposite_update(SPObject *object, SPCtx *ctx, guint flags);
390N/Astatic Inkscape::XML::Node *sp_feComposite_write(SPObject *object, Inkscape::XML::Node *repr, guint flags);
390N/A
390N/Astatic SPFilterPrimitiveClass *feComposite_parent_class;
2736N/A
390N/AGType
390N/Asp_feComposite_get_type()
390N/A{
390N/A static GType feComposite_type = 0;
390N/A
390N/A if (!feComposite_type) {
390N/A GTypeInfo feComposite_info = {
390N/A sizeof(SPFeCompositeClass),
390N/A NULL, NULL,
390N/A (GClassInitFunc) sp_feComposite_class_init,
390N/A NULL, NULL,
390N/A sizeof(SPFeComposite),
390N/A 16,
390N/A (GInstanceInitFunc) sp_feComposite_init,
390N/A NULL, /* value_table */
390N/A };
390N/A feComposite_type = g_type_register_static(SP_TYPE_FILTER_PRIMITIVE, "SPFeComposite", &feComposite_info, (GTypeFlags)0);
390N/A }
390N/A return feComposite_type;
390N/A}
390N/A
390N/Astatic void
390N/Asp_feComposite_class_init(SPFeCompositeClass *klass)
390N/A{
390N/A SPObjectClass *sp_object_class = (SPObjectClass *)klass;
390N/A
390N/A feComposite_parent_class = (SPFilterPrimitiveClass*)g_type_class_peek_parent(klass);
390N/A
390N/A sp_object_class->build = sp_feComposite_build;
390N/A sp_object_class->release = sp_feComposite_release;
390N/A sp_object_class->write = sp_feComposite_write;
390N/A sp_object_class->set = sp_feComposite_set;
390N/A sp_object_class->update = sp_feComposite_update;
390N/A}
390N/A
390N/Astatic void
390N/Asp_feComposite_init(SPFeComposite *feComposite)
390N/A{
390N/A}
390N/A
390N/A/**
390N/A * Reads the Inkscape::XML::Node, and initializes SPFeComposite variables. For this to get called,
390N/A * our name must be associated with a repr via "sp_object_type_register". Best done through
390N/A * sp-object-repr.cpp's repr_name_entries array.
390N/A */
390N/Astatic void
390N/Asp_feComposite_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr)
390N/A{
390N/A if (((SPObjectClass *) feComposite_parent_class)->build) {
390N/A ((SPObjectClass *) feComposite_parent_class)->build(object, document, repr);
390N/A }
390N/A
390N/A /*LOAD ATTRIBUTES FROM REPR HERE*/
390N/A}
2736N/A
390N/A/**
390N/A * Drops any allocated memory.
390N/A */
390N/Astatic void
390N/Asp_feComposite_release(SPObject *object)
390N/A{
2736N/A if (((SPObjectClass *) feComposite_parent_class)->release)
390N/A ((SPObjectClass *) feComposite_parent_class)->release(object);
390N/A}
390N/A
390N/A/**
390N/A * Sets a specific value in the SPFeComposite.
390N/A */
2736N/Astatic void
390N/Asp_feComposite_set(SPObject *object, unsigned int key, gchar const *value)
390N/A{
390N/A SPFeComposite *feComposite = SP_FECOMPOSITE(object);
390N/A (void)feComposite;
390N/A
390N/A switch(key) {
390N/A /*DEAL WITH SETTING ATTRIBUTES HERE*/
390N/A default:
390N/A if (((SPObjectClass *) feComposite_parent_class)->set)
390N/A ((SPObjectClass *) feComposite_parent_class)->set(object, key, value);
390N/A break;
390N/A }
390N/A
390N/A}
2736N/A
390N/A/**
390N/A * Receives update notifications.
2736N/A */
390N/Astatic void
390N/Asp_feComposite_update(SPObject *object, SPCtx *ctx, guint flags)
390N/A{
390N/A if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG |
390N/A SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) {
390N/A
390N/A /* do something to trigger redisplay, updates? */
390N/A
390N/A }
390N/A
390N/A if (((SPObjectClass *) feComposite_parent_class)->update) {
2736N/A ((SPObjectClass *) feComposite_parent_class)->update(object, ctx, flags);
390N/A }
390N/A}
390N/A
390N/A/**
390N/A * Writes its settings to an incoming repr object, if any.
*/
static Inkscape::XML::Node *
sp_feComposite_write(SPObject *object, Inkscape::XML::Node *repr, guint flags)
{
// Inkscape-only object, not copied during an "plain SVG" dump:
if (flags & SP_OBJECT_WRITE_EXT) {
if (repr) {
// is this sane?
repr->mergeFrom(SP_OBJECT_REPR(object), "id");
} else {
repr = SP_OBJECT_REPR(object)->duplicate(NULL); // FIXME
}
}
if (((SPObjectClass *) feComposite_parent_class)->write) {
((SPObjectClass *) feComposite_parent_class)->write(object, repr, flags);
}
return repr;
}
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :