summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 61a2c98)
raw | patch | inline | side by side (parent: 61a2c98)
author | JucaBlues <JucaBlues@users.sourceforge.net> | |
Thu, 28 Feb 2008 15:54:34 +0000 (15:54 +0000) | ||
committer | JucaBlues <JucaBlues@users.sourceforge.net> | |
Thu, 28 Feb 2008 15:54:34 +0000 (15:54 +0000) |
src/sp-font.cpp | patch | blob | history | |
src/sp-glyph.cpp | patch | blob | history | |
src/sp-missing-glyph.cpp | patch | blob | history |
diff --git a/src/sp-font.cpp b/src/sp-font.cpp
index b96b3785863cdd55a59cc12ef81d940dbda75615..82bc1978c9830dc7ce3a7f53c91918eb25cf53ff 100644 (file)
--- a/src/sp-font.cpp
+++ b/src/sp-font.cpp
#include "xml/repr.h"
#include "attributes.h"
#include "sp-font.h"
+#include "sp-glyph.h"
+#include "sp-missing-glyph.h"
#include "document.h"
#include "helper-fns.h"
static void sp_font_set(SPObject *object, unsigned int key, const gchar *value);
static Inkscape::XML::Node *sp_font_write(SPObject *object, Inkscape::XML::Node *repr, guint flags);
+static void sp_font_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref);
+static void sp_font_remove_child(SPObject *object, Inkscape::XML::Node *child);
+static void sp_font_update(SPObject *object, SPCtx *ctx, guint flags);
+
// static gchar *sp_font_description(SPItem *item);
static SPObjectClass *parent_class;
sp_object_class->release = sp_font_release;
sp_object_class->set = sp_font_set;
sp_object_class->write = sp_font_write;
+ sp_object_class->child_added = sp_font_child_added;
+ sp_object_class->remove_child = sp_font_remove_child;
+ sp_object_class->update = sp_font_update;
}
static void sp_font_init(SPFont *font)
sp_object_read_attr(object, "vert-adv-y");
}
+
+static void sp_font_children_modified(SPFont *sp_font)
+{
+ SPObject* node = sp_font->children;
+ for(;node;node=node->next){
+ if (SP_IS_GLYPH(node)){
+ g_warning("We have a <glyph> childnode:\n\td=%s\n\tvert-origin-x=%f\n\tvert-origin-y=%f\n\tvert-adv-y=%f", ((SPGlyph*)node)->d, ((SPGlyph*)node)->vert_origin_x, ((SPGlyph*)node)->vert_origin_y, ((SPGlyph*)node)->vert_adv_y );
+
+ }
+ if (SP_IS_MISSING_GLYPH(node)){
+g_warning("We have a <missing-glyph> childnode:\n\td=%s\n\thoriz-origin-x=%f\n\thoriz-origin-y=%f\n\thoriz-adv-x=%f", ((SPMissingGlyph*)node)->d, ((SPMissingGlyph*)node)->vert_origin_x, ((SPMissingGlyph*)node)->vert_origin_y, ((SPMissingGlyph*)node)->vert_adv_y );
+ }
+// if (SP_IS_FONT_FACE_SRC(node)){
+// }
+ }
+}
+
+/**
+ * Callback for child_added event.
+ */
+static void
+sp_font_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref)
+{
+ SPFont *f = SP_FONT(object);
+
+ if (((SPObjectClass *) parent_class)->child_added)
+ (* ((SPObjectClass *) parent_class)->child_added)(object, child, ref);
+
+ sp_font_children_modified(f);
+ object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
+}
+
+
+/**
+ * Callback for remove_child event.
+ */
+static void
+sp_font_remove_child(SPObject *object, Inkscape::XML::Node *child)
+{
+ SPFont *f = SP_FONT(object);
+
+ if (((SPObjectClass *) parent_class)->remove_child)
+ (* ((SPObjectClass *) parent_class)->remove_child)(object, child);
+
+ sp_font_children_modified(f);
+ object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
+}
+
static void sp_font_release(SPObject *object)
{
//SPFont *font = SP_FONT(object);
}
}
+/**
+ * Receives update notifications.
+ */
+static void
+sp_font_update(SPObject *object, SPCtx *ctx, guint flags)
+{
+ if (flags & (SP_OBJECT_MODIFIED_FLAG)) {
+ sp_object_read_attr(object, "horiz-origin-x");
+ sp_object_read_attr(object, "horiz-origin-y");
+ sp_object_read_attr(object, "horiz-adv-x");
+ sp_object_read_attr(object, "vert-origin-x");
+ sp_object_read_attr(object, "vert-origin-y");
+ sp_object_read_attr(object, "vert-adv-y");
+ }
+
+ if (((SPObjectClass *) parent_class)->update) {
+ ((SPObjectClass *) parent_class)->update(object, ctx, flags);
+ }
+}
+
#define COPY_ATTR(rd,rs,key) (rd)->setAttribute((key), rs->attribute(key));
static Inkscape::XML::Node *sp_font_write(SPObject *object, Inkscape::XML::Node *repr, guint flags)
diff --git a/src/sp-glyph.cpp b/src/sp-glyph.cpp
index cbddb2192454be8fd0b550466e903c1e1272f3d7..b0dd06b32c46d4c24be6082c122df64516b41362 100644 (file)
--- a/src/sp-glyph.cpp
+++ b/src/sp-glyph.cpp
static void sp_glyph_release(SPObject *object);
static void sp_glyph_set(SPObject *object, unsigned int key, const gchar *value);
static Inkscape::XML::Node *sp_glyph_write(SPObject *object, Inkscape::XML::Node *repr, guint flags);
+static void sp_glyph_update(SPObject *object, SPCtx *ctx, guint flags);
static SPObjectClass *parent_class;
{
SPObjectClass *sp_object_class = (SPObjectClass *) gc;
- parent_class = (SPObjectClass *) g_type_class_ref(SP_TYPE_OBJECT);
+ parent_class = (SPObjectClass*)g_type_class_peek_parent(gc);
sp_object_class->build = sp_glyph_build;
sp_object_class->release = sp_glyph_release;
sp_object_class->set = sp_glyph_set;
sp_object_class->write = sp_glyph_write;
+ sp_object_class->update = sp_glyph_update;
}
static void sp_glyph_init(SPGlyph *glyph)
}
}
+/**
+ * * Receives update notifications.
+ * */
+static void
+sp_glyph_update(SPObject *object, SPCtx *ctx, guint flags)
+{
+ SPGlyph *glyph = SP_GLYPH(object);
+ (void)glyph;
+
+ if (flags & SP_OBJECT_MODIFIED_FLAG) {
+ /* do something to trigger redisplay, updates? */
+ sp_object_read_attr(object, "unicode");
+ sp_object_read_attr(object, "glyph-name");
+ sp_object_read_attr(object, "d");
+ sp_object_read_attr(object, "orientation");
+ sp_object_read_attr(object, "arabic-form");
+ sp_object_read_attr(object, "lang");
+ sp_object_read_attr(object, "horiz-adv-x");
+ sp_object_read_attr(object, "vert-origin-x");
+ sp_object_read_attr(object, "vert-origin-y");
+ sp_object_read_attr(object, "vert-adv-y");
+ }
+
+ if (((SPObjectClass *) parent_class)->update) {
+ ((SPObjectClass *) parent_class)->update(object, ctx, flags);
+ }
+}
+
#define COPY_ATTR(rd,rs,key) (rd)->setAttribute((key), rs->attribute(key));
static Inkscape::XML::Node *sp_glyph_write(SPObject *object, Inkscape::XML::Node *repr, guint flags)
index 4f3329b7cf56e58af0a58d539aa864321e322859..02a94176ce96f4cb0a7e20259ee4129886a74012 100644 (file)
--- a/src/sp-missing-glyph.cpp
+++ b/src/sp-missing-glyph.cpp
{
SPObjectClass *sp_object_class = (SPObjectClass *) gc;
- parent_class = (SPObjectClass *) g_type_class_ref(SP_TYPE_OBJECT);
+ parent_class = (SPObjectClass*)g_type_class_peek_parent(gc);
sp_object_class->build = sp_missing_glyph_build;
sp_object_class->release = sp_missing_glyph_release;