diff options
| author | Markus Engel <markus.engel@tum.de> | 2012-08-19 01:11:45 +0000 |
|---|---|---|
| committer | Markus Engel <markus.engel@tum.de> | 2012-08-19 01:11:45 +0000 |
| commit | 25d3298c964cd227bcf31d09539899ac0e6b9060 (patch) | |
| tree | b4ccef3fc8f02aec47419d6aa05432761fa3598b /src | |
| parent | Added "virtual pad" to SPRoot. (diff) | |
| download | inkscape-25d3298c964cd227bcf31d09539899ac0e6b9060.tar.gz inkscape-25d3298c964cd227bcf31d09539899ac0e6b9060.zip | |
Added "virtual pad" to SPSymbol.
(bzr r11608.1.21)
Diffstat (limited to 'src')
| -rw-r--r-- | src/sp-symbol.cpp | 168 | ||||
| -rw-r--r-- | src/sp-symbol.h | 31 |
2 files changed, 142 insertions, 57 deletions
diff --git a/src/sp-symbol.cpp b/src/sp-symbol.cpp index 87cd210e4..bd8a0ea53 100644 --- a/src/sp-symbol.cpp +++ b/src/sp-symbol.cpp @@ -85,32 +85,53 @@ static void sp_symbol_class_init(SPSymbolClass *klass) sp_item_class->print = sp_symbol_print; } +CSymbol::CSymbol(SPSymbol* symbol) : CGroup(symbol) { + this->spsymbol = symbol; +} + +CSymbol::~CSymbol() { +} + static void sp_symbol_init(SPSymbol *symbol) { - symbol->viewBox_set = FALSE; + symbol->csymbol = new CSymbol(symbol); + symbol->cgroup = symbol->csymbol; + symbol->clpeitem = symbol->csymbol; + symbol->citem = symbol->csymbol; + symbol->cobject = symbol->csymbol; + symbol->viewBox_set = FALSE; symbol->c2p = Geom::identity(); } -static void sp_symbol_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) -{ +void CSymbol::onBuild(SPDocument *document, Inkscape::XML::Node *repr) { + SPSymbol* object = this->spsymbol; + object->readAttr( "viewBox" ); object->readAttr( "preserveAspectRatio" ); - if (((SPObjectClass *) parent_class)->build) { - ((SPObjectClass *) parent_class)->build (object, document, repr); - } + CGroup::onBuild(document, repr); } -static void sp_symbol_release(SPObject *object) +// CPPIFY: remove +static void sp_symbol_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { - if (((SPObjectClass *) parent_class)->release) { - ((SPObjectClass *) parent_class)->release (object); - } + ((SPSymbol*)object)->csymbol->onBuild(document, repr); } -static void sp_symbol_set(SPObject *object, unsigned int key, const gchar *value) +void CSymbol::onRelease() { + CGroup::onRelease(); +} + +// CPPIFY: remove +static void sp_symbol_release(SPObject *object) { + ((SPSymbol*)object)->csymbol->onRelease(); +} + +void CSymbol::onSet(unsigned int key, const gchar* value) { + SPSymbol* object = this->spsymbol; + SPSymbol *symbol = SP_SYMBOL(object); switch (key) { @@ -202,22 +223,31 @@ static void sp_symbol_set(SPObject *object, unsigned int key, const gchar *value } break; default: - if (((SPObjectClass *) parent_class)->set) - ((SPObjectClass *) parent_class)->set (object, key, value); + CGroup::onSet(key, value); break; } } -static void sp_symbol_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref) +// CPPIFY: remove +static void sp_symbol_set(SPObject *object, unsigned int key, const gchar *value) { - if (((SPObjectClass *) (parent_class))->child_added) { - ((SPObjectClass *) (parent_class))->child_added (object, child, ref); - } + ((SPSymbol*)object)->csymbol->onSet(key, value); } -static void sp_symbol_update(SPObject *object, SPCtx *ctx, guint flags) +void CSymbol::onChildAdded(Inkscape::XML::Node *child, Inkscape::XML::Node *ref) { + CGroup::onChildAdded(child, ref); +} + +// CPPIFY: remove +static void sp_symbol_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref) { - SPSymbol *symbol = SP_SYMBOL(object); + ((SPSymbol*)object)->csymbol->onChildAdded(child, ref); +} + +void CSymbol::onUpdate(SPCtx *ctx, guint flags) { + SPSymbol* object = this->spsymbol; + SPSymbol *symbol = object; + SPItemCtx *ictx = (SPItemCtx *) ctx; SPItemCtx rctx; @@ -315,9 +345,7 @@ static void sp_symbol_update(SPObject *object, SPCtx *ctx, guint flags) } // And invoke parent method - if (((SPObjectClass *) (parent_class))->update) { - ((SPObjectClass *) (parent_class))->update (object, (SPCtx *) &rctx, flags); - } + CGroup::onUpdate((SPCtx *) &rctx, flags); // As last step set additional transform of drawing group for (SPItemView *v = symbol->display; v != NULL; v = v->next) { @@ -326,24 +354,28 @@ static void sp_symbol_update(SPObject *object, SPCtx *ctx, guint flags) } } else { // No-op - if (((SPObjectClass *) (parent_class))->update) { - ((SPObjectClass *) (parent_class))->update (object, ctx, flags); - } + CGroup::onUpdate(ctx, flags); } } -static void sp_symbol_modified(SPObject *object, guint flags) +// CPPIFY: remove +static void sp_symbol_update(SPObject *object, SPCtx *ctx, guint flags) { - SP_SYMBOL(object); + ((SPSymbol*)object)->csymbol->onUpdate(ctx, flags); +} - if (((SPObjectClass *) (parent_class))->modified) { - (* ((SPObjectClass *) (parent_class))->modified) (object, flags); - } +void CSymbol::onModified(unsigned int flags) { + CGroup::onModified(flags); } -static Inkscape::XML::Node *sp_symbol_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) +// CPPIFY: remove +static void sp_symbol_modified(SPObject *object, guint flags) { - SP_SYMBOL(object); + ((SPSymbol*)object)->csymbol->onModified(flags); +} + +Inkscape::XML::Node* CSymbol::onWrite(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { + SPSymbol* object = this->spsymbol; if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { repr = xml_doc->createElement("svg:symbol"); @@ -355,72 +387,96 @@ static Inkscape::XML::Node *sp_symbol_write(SPObject *object, Inkscape::XML::Doc //XML Tree being used directly here while it shouldn't be. repr->setAttribute("preserveAspectRatio", object->getRepr()->attribute("preserveAspectRatio")); - if (((SPObjectClass *) (parent_class))->write) { - ((SPObjectClass *) (parent_class))->write (object, xml_doc, repr, flags); - } + CGroup::onWrite(xml_doc, repr, flags); return repr; } -static Inkscape::DrawingItem *sp_symbol_show(SPItem *item, Inkscape::Drawing &drawing, unsigned int key, unsigned int flags) +// CPPIFY: remove +static Inkscape::XML::Node *sp_symbol_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { + return ((SPSymbol*)object)->csymbol->onWrite(xml_doc, repr, flags); +} + +Inkscape::DrawingItem* CSymbol::onShow(Inkscape::Drawing &drawing, unsigned int key, unsigned int flags) { + SPSymbol* item = this->spsymbol; + SPSymbol *symbol = SP_SYMBOL(item); Inkscape::DrawingItem *ai = 0; if (symbol->cloned) { // Cloned <symbol> is actually renderable - if (((SPItemClass *) (parent_class))->show) { - ai = ((SPItemClass *) (parent_class))->show (item, drawing, key, flags); - Inkscape::DrawingGroup *g = dynamic_cast<Inkscape::DrawingGroup *>(ai); - if (g) { - g->setChildTransform(symbol->c2p); - } - } + ai = CGroup::onShow(drawing, key, flags); + Inkscape::DrawingGroup *g = dynamic_cast<Inkscape::DrawingGroup *>(ai); + if (g) { + g->setChildTransform(symbol->c2p); + } } return ai; } -static void sp_symbol_hide(SPItem *item, unsigned int key) +// CPPIFY: remove +static Inkscape::DrawingItem *sp_symbol_show(SPItem *item, Inkscape::Drawing &drawing, unsigned int key, unsigned int flags) { + return ((SPSymbol*)item)->csymbol->onShow(drawing, key, flags); +} + +void CSymbol::onHide(unsigned int key) { + SPSymbol* item = this->spsymbol; + SPSymbol *symbol = SP_SYMBOL(item); if (symbol->cloned) { /* Cloned <symbol> is actually renderable */ - if (((SPItemClass *) (parent_class))->hide) { - ((SPItemClass *) (parent_class))->hide (item, key); - } + CGroup::onHide(key); } } -static Geom::OptRect sp_symbol_bbox(SPItem const *item, Geom::Affine const &transform, SPItem::BBoxType type) +// CPPIFY: remove +static void sp_symbol_hide(SPItem *item, unsigned int key) { + ((SPSymbol*)item)->csymbol->onHide(key); +} + +Geom::OptRect CSymbol::onBbox(Geom::Affine const &transform, SPItem::BBoxType type) { + SPSymbol* item = this->spsymbol; + SPSymbol const *symbol = SP_SYMBOL(item); Geom::OptRect bbox; if (symbol->cloned) { // Cloned <symbol> is actually renderable + Geom::Affine const a( symbol->c2p * transform ); + bbox = CGroup::onBbox(a, type); - if (((SPItemClass *) (parent_class))->bbox) { - Geom::Affine const a( symbol->c2p * transform ); - bbox = ((SPItemClass *) (parent_class))->bbox(item, a, type); - } } return bbox; } -static void sp_symbol_print(SPItem *item, SPPrintContext *ctx) +// CPPIFY: remove +static Geom::OptRect sp_symbol_bbox(SPItem const *item, Geom::Affine const &transform, SPItem::BBoxType type) { + return ((SPSymbol*)item)->csymbol->onBbox(transform, type); +} + +void CSymbol::onPrint(SPPrintContext* ctx) { + SPSymbol* item = this->spsymbol; + SPSymbol *symbol = SP_SYMBOL(item); if (symbol->cloned) { // Cloned <symbol> is actually renderable sp_print_bind(ctx, symbol->c2p, 1.0); - if (((SPItemClass *) (parent_class))->print) { - ((SPItemClass *) (parent_class))->print (item, ctx); - } + CGroup::onPrint(ctx); sp_print_release (ctx); } } + +// CPPIFY: remove +static void sp_symbol_print(SPItem *item, SPPrintContext *ctx) +{ + ((SPSymbol*)item)->csymbol->onPrint(ctx); +} diff --git a/src/sp-symbol.h b/src/sp-symbol.h index 59f343285..82dd3ca9f 100644 --- a/src/sp-symbol.h +++ b/src/sp-symbol.h @@ -23,13 +23,17 @@ class SPSymbol; class SPSymbolClass; +class CSymbol; #include <2geom/affine.h> #include "svg/svg-length.h" #include "enums.h" #include "sp-item-group.h" -struct SPSymbol : public SPGroup { +class SPSymbol : public SPGroup { +public: + CSymbol* csymbol; + /* viewBox; */ unsigned int viewBox_set : 1; Geom::Rect viewBox; @@ -47,6 +51,31 @@ struct SPSymbolClass { SPGroupClass parent_class; }; + +class CSymbol : public CGroup { +public: + CSymbol(SPSymbol* symbol); + virtual ~CSymbol(); + + virtual void onBuild(SPDocument *document, Inkscape::XML::Node *repr); + virtual void onRelease(); + virtual void onSet(unsigned int key, gchar const* value); + virtual void onUpdate(SPCtx *ctx, guint flags); + virtual Inkscape::XML::Node* onWrite(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags); + + virtual void onModified(unsigned int flags); + virtual void onChildAdded(Inkscape::XML::Node* child, Inkscape::XML::Node* ref); + + virtual Inkscape::DrawingItem* onShow(Inkscape::Drawing &drawing, unsigned int key, unsigned int flags); + virtual void onPrint(SPPrintContext *ctx); + virtual Geom::OptRect onBbox(Geom::Affine const &transform, SPItem::BBoxType type); + virtual void onHide (unsigned int key); + +protected: + SPSymbol* spsymbol; +}; + + GType sp_symbol_get_type (void); #endif |
