diff options
| author | Markus Engel <markus.engel@tum.de> | 2013-03-29 23:52:42 +0000 |
|---|---|---|
| committer | Markus Engel <markus.engel@tum.de> | 2013-03-29 23:52:42 +0000 |
| commit | a168040d5a452544328a1e6ad35aaac351f94d44 (patch) | |
| tree | fae1ba829f543a473da281bd5fa6e4deabbf6912 /src/sp-text.cpp | |
| parent | Removed function pointers from SPObject and subclasses. (diff) | |
| parent | Dutch translation update (diff) | |
| download | inkscape-a168040d5a452544328a1e6ad35aaac351f94d44.tar.gz inkscape-a168040d5a452544328a1e6ad35aaac351f94d44.zip | |
merged from trunk
(bzr r11608.1.56)
Diffstat (limited to 'src/sp-text.cpp')
| -rw-r--r-- | src/sp-text.cpp | 161 |
1 files changed, 4 insertions, 157 deletions
diff --git a/src/sp-text.cpp b/src/sp-text.cpp index fe7138cbe..ed3792e66 100644 --- a/src/sp-text.cpp +++ b/src/sp-text.cpp @@ -61,75 +61,11 @@ /*##################################################### # SPTEXT #####################################################*/ - -static void sp_text_class_init (SPTextClass *classname); -static void sp_text_init (SPText *text); -static void sp_text_release (SPObject *object); - -static void sp_text_build (SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); -static void sp_text_set (SPObject *object, unsigned key, gchar const *value); -static void sp_text_child_added (SPObject *object, Inkscape::XML::Node *rch, Inkscape::XML::Node *ref); -static void sp_text_remove_child (SPObject *object, Inkscape::XML::Node *rch); -static void sp_text_update (SPObject *object, SPCtx *ctx, guint flags); -static void sp_text_modified (SPObject *object, guint flags); -static Inkscape::XML::Node *sp_text_write (SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); - -static Geom::OptRect sp_text_bbox(SPItem const *item, Geom::Affine const &transform, SPItem::BBoxType type); -static Inkscape::DrawingItem *sp_text_show (SPItem *item, Inkscape::Drawing &drawing, unsigned key, unsigned flags); -static void sp_text_hide (SPItem *item, unsigned key); -static char *sp_text_description (SPItem *item); -static void sp_text_snappoints(SPItem const *item, std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs); -static Geom::Affine sp_text_set_transform(SPItem *item, Geom::Affine const &xform); -static void sp_text_print (SPItem *item, SPPrintContext *gpc); - -static SPItemClass *text_parent_class; - -GType -sp_text_get_type () -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof (SPTextClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) sp_text_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (SPText), - 16, /* n_preallocs */ - (GInstanceInitFunc) sp_text_init, - NULL, /* value_table */ - }; - type = g_type_register_static (SP_TYPE_ITEM, "SPText", &info, (GTypeFlags)0); - } - return type; -} +G_DEFINE_TYPE(SPText, sp_text, SP_TYPE_ITEM); static void sp_text_class_init (SPTextClass *classname) { - SPObjectClass *sp_object_class = (SPObjectClass *) classname; - SPItemClass *item_class = (SPItemClass *) classname; - - text_parent_class = (SPItemClass*)g_type_class_ref (SP_TYPE_ITEM); - -// sp_object_class->release = sp_text_release; -// //sp_object_class->build = sp_text_build; -// sp_object_class->set = sp_text_set; -// sp_object_class->child_added = sp_text_child_added; -// sp_object_class->remove_child = sp_text_remove_child; -// sp_object_class->update = sp_text_update; -// sp_object_class->modified = sp_text_modified; -// sp_object_class->write = sp_text_write; - -// item_class->bbox = sp_text_bbox; -// item_class->show = sp_text_show; -// item_class->hide = sp_text_hide; -// item_class->description = sp_text_description; -// item_class->snappoints = sp_text_snappoints; -// item_class->set_transform = sp_text_set_transform; -// item_class->print = sp_text_print; } CText::CText(SPText* text) : CItem(text) { @@ -143,6 +79,8 @@ static void sp_text_init (SPText *text) { text->ctext = new CText(text); + + delete text->citem; text->citem = text->ctext; text->cobject = text->ctext; @@ -160,12 +98,6 @@ void CText::onRelease() { CItem::onRelease(); } -static void -sp_text_release (SPObject *object) -{ - ((SPText*)object)->ctext->onRelease(); -} - void CText::onBuild(SPDocument *doc, Inkscape::XML::Node *repr) { SPText* object = this->sptext; @@ -180,12 +112,6 @@ void CText::onBuild(SPDocument *doc, Inkscape::XML::Node *repr) { object->readAttr( "sodipodi:linespacing" ); // has to happen after the styles are read } -static void -sp_text_build (SPObject *object, SPDocument *doc, Inkscape::XML::Node *repr) -{ - ((SPText*)object)->ctext->onBuild(doc, repr); -} - void CText::onSet(unsigned int key, const gchar* value) { SPText* object = this->sptext; @@ -213,12 +139,6 @@ void CText::onSet(unsigned int key, const gchar* value) { } } -static void -sp_text_set(SPObject *object, unsigned key, gchar const *value) -{ - ((SPText*)object)->ctext->onSet(key, value); -} - void CText::onChildAdded(Inkscape::XML::Node *rch, Inkscape::XML::Node *ref) { SPText* object = this->sptext; @@ -229,12 +149,6 @@ void CText::onChildAdded(Inkscape::XML::Node *rch, Inkscape::XML::Node *ref) { text->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_TEXT_CONTENT_MODIFIED_FLAG | SP_TEXT_LAYOUT_MODIFIED_FLAG); } -static void -sp_text_child_added (SPObject *object, Inkscape::XML::Node *rch, Inkscape::XML::Node *ref) -{ - ((SPText*)object)->ctext->onChildAdded(rch, ref); -} - void CText::onRemoveChild(Inkscape::XML::Node *rch) { SPText* object = this->sptext; @@ -245,11 +159,6 @@ void CText::onRemoveChild(Inkscape::XML::Node *rch) { text->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_TEXT_CONTENT_MODIFIED_FLAG | SP_TEXT_LAYOUT_MODIFIED_FLAG); } -static void -sp_text_remove_child (SPObject *object, Inkscape::XML::Node *rch) -{ - ((SPText*)object)->ctext->onRemoveChild(rch); -} void CText::onUpdate(SPCtx *ctx, guint flags) { SPText* object = this->sptext; @@ -298,19 +207,9 @@ void CText::onUpdate(SPCtx *ctx, guint flags) { } } -static void sp_text_update(SPObject *object, SPCtx *ctx, guint flags) -{ - ((SPText*)object)->ctext->onUpdate(ctx, flags); -} - void CText::onModified(guint flags) { SPText* object = this->sptext; - // CPPIFY: This doesn't make no sense. - // CObject::onModified is pure and CItem doesn't override this method. What was the idea behind these lines? -// if (((SPObjectClass *) text_parent_class)->modified) { -// ((SPObjectClass *) text_parent_class)->modified (object, flags); -// } // CItem::onModified(flags); guint cflags = (flags & SP_OBJECT_MODIFIED_CASCADE); @@ -350,11 +249,6 @@ void CText::onModified(guint flags) { } } -static void sp_text_modified(SPObject *object, guint flags) -{ - ((SPText*)object)->ctext->onModified(flags); -} - Inkscape::XML::Node *CText::onWrite(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { SPText* object = this->sptext; @@ -413,11 +307,6 @@ Inkscape::XML::Node *CText::onWrite(Inkscape::XML::Document *xml_doc, Inkscape:: return repr; } -static Inkscape::XML::Node *sp_text_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) -{ - return ((SPText*)object)->ctext->onWrite(xml_doc, repr, flags); -} - Geom::OptRect CText::onBbox(Geom::Affine const &transform, SPItem::BBoxType type) { SPText* item = this->sptext; @@ -431,12 +320,6 @@ Geom::OptRect CText::onBbox(Geom::Affine const &transform, SPItem::BBoxType type return bbox; } -static Geom::OptRect -sp_text_bbox(SPItem const *item, Geom::Affine const &transform, SPItem::BBoxType type) -{ - return ((SPText*)item)->ctext->onBbox(transform, type); -} - Inkscape::DrawingItem* CText::onShow(Inkscape::Drawing &drawing, unsigned key, unsigned flags) { SPText* item = this->sptext; @@ -452,25 +335,11 @@ Inkscape::DrawingItem* CText::onShow(Inkscape::Drawing &drawing, unsigned key, u return flowed; } -static Inkscape::DrawingItem * -sp_text_show(SPItem *item, Inkscape::Drawing &drawing, unsigned key, unsigned flags) -{ - return ((SPText*)item)->ctext->onShow(drawing, key, flags); -} void CText::onHide(unsigned int key) { - // CPPIFY: This doesn't make no sense. - // CItem::onHide is pure and CLPEItem doesn't override it. What was the idea behind these lines? -// if (((SPItemClass *) text_parent_class)->hide) -// ((SPItemClass *) text_parent_class)->hide (item, key); // CItem::onHide(key); } -static void -sp_text_hide(SPItem *item, unsigned key) -{ - ((SPText*)item)->ctext->onHide(key); -} gchar* CText::onDescription() { SPText* item = this->sptext; @@ -483,7 +352,7 @@ gchar* CText::onDescription() { char name_buf[256]; char *n; if (tf) { - tf->Name(name_buf, sizeof(name_buf)); + tf->Family(name_buf, sizeof(name_buf)); n = xml_quote_strdup(name_buf); tf->Unref(); } else { @@ -506,11 +375,6 @@ gchar* CText::onDescription() { return ret; } -static char * sp_text_description(SPItem *item) -{ - return ((SPText*)item)->ctext->onDescription(); -} - void CText::onSnappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs) { SPText* item = this->sptext; @@ -527,11 +391,6 @@ void CText::onSnappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape: } } -static void sp_text_snappoints(SPItem const *item, std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs) -{ - ((SPText*)item)->ctext->onSnappoints(p, snapprefs); -} - Geom::Affine CText::onSetTransform(Geom::Affine const &xform) { SPText* item = this->sptext; @@ -581,12 +440,6 @@ Geom::Affine CText::onSetTransform(Geom::Affine const &xform) { return ret; } -static Geom::Affine -sp_text_set_transform (SPItem *item, Geom::Affine const &xform) -{ - return ((SPText*)item)->ctext->onSetTransform(xform); -} - void CText::onPrint(SPPrintContext *ctx) { SPText* item = this->sptext; @@ -601,12 +454,6 @@ void CText::onPrint(SPPrintContext *ctx) { group->layout.print(ctx,pbox,dbox,bbox,ctm); } -static void -sp_text_print (SPItem *item, SPPrintContext *ctx) -{ - ((SPText*)item)->ctext->onPrint(ctx); -} - /* * Member functions */ |
