Code

Yet mor in c++ification
authorAbhishek Sharma public <spyzerdotabhishek0at-signgmaildotcom>
Sat, 24 Jul 2010 15:28:27 +0000 (20:58 +0530)
committerAbhishek Sharma public <spyzerdotabhishek0at-signgmaildotcom>
Sat, 24 Jul 2010 15:28:27 +0000 (20:58 +0530)
14 files changed:
src/filter-chemistry.cpp
src/flood-context.cpp
src/satisfied-guide-cns.cpp
src/sp-defs.cpp
src/sp-defs.h
src/sp-guide.cpp
src/sp-guide.h
src/sp-item-rm-unsatisfied-cns.cpp
src/sp-line.cpp
src/sp-namedview.cpp
src/sp-object-group.cpp
src/sp-object-group.h
src/sp-object.cpp
src/sp-object.h

index 1f4e91c3bffca0a18d06c10d8abaed5a612b6139..9e0ee8383767f47ff5bf9346a70ada2a6190f81e 100644 (file)
@@ -101,7 +101,8 @@ SPFilter *new_filter(SPDocument *document)
     repr = xml_doc->createElement("svg:filter");
 
     // Append the new filter node to defs
-    SP_OBJECT_REPR(defs)->appendChild(repr);
+    //SP_OBJECT_REPR(defs)->appendChild(repr);
+       defs->appendChild(repr);
     Inkscape::GC::release(repr);
 
     // get corresponding object
@@ -169,7 +170,8 @@ filter_add_primitive(SPFilter *filter, const Inkscape::Filters::FilterPrimitiveT
 
     //set primitive as child of filter node
        // XML tree being used directly while/where it shouldn't be...
-    filter->getRepr()->appendChild(repr);
+    //filter->getRepr()->appendChild(repr);
+       filter->appendChild(repr);
     Inkscape::GC::release(repr);
     
     // get corresponding object
@@ -218,7 +220,8 @@ new_filter_gaussian_blur (SPDocument *document, gdouble radius, double expansion
     Inkscape::GC::release(b_repr);
     
     // Append the new filter node to defs
-    SP_OBJECT_REPR(defs)->appendChild(repr);
+    //SP_OBJECT_REPR(defs)->appendChild(repr);
+       defs->appendChild(repr);
     Inkscape::GC::release(repr);
 
     // get corresponding object
@@ -254,7 +257,8 @@ new_filter_blend_gaussian_blur (SPDocument *document, const char *blendmode, gdo
     repr->setAttribute("inkscape:collect", "always");
 
     // Append the new filter node to defs
-    SP_OBJECT_REPR(defs)->appendChild(repr);
+    //SP_OBJECT_REPR(defs)->appendChild(repr);
+       defs->appendChild(repr);
     Inkscape::GC::release(repr);
  
     // get corresponding object
@@ -361,7 +365,8 @@ modify_filter_gaussian_blur_from_item(SPDocument *document, SPItem *item,
         Inkscape::XML::Node *repr;
         repr = SP_OBJECT_REPR(item->style->getFilter())->duplicate(xml_doc);
         SPDefs *defs = (SPDefs *) SP_DOCUMENT_DEFS(document);
-        SP_OBJECT_REPR(defs)->appendChild(repr);
+        //SP_OBJECT_REPR(defs)->appendChild(repr);
+               defs->appendChild(repr);
 
         filter = SP_FILTER( document->getObjectByRepr(repr) );
         Inkscape::GC::release(repr);
index 5181809dc3d85b45c6b8f8b6807df5ea3952612c..b9aaf902e39fd5fd075bb95a2f934484f02b3945 100644 (file)
@@ -418,7 +418,7 @@ static void do_trace(bitmap_coords_info bci, guchar *trace_px, SPDesktop *deskto
     gray_map->destroy(gray_map);
 
        //XML Tree being used here directly while it shouldn't be...."
-    Inkscape::XML::Node *layer_repr = SP_GROUP(desktop->currentLayer())->getRepr();
+    //Inkscape::XML::Node *layer_repr = SP_GROUP(desktop->currentLayer())->getRepr();
     Inkscape::XML::Document *xml_doc = sp_document_repr_doc(desktop->doc());
 
     long totalNodeCount = 0L;
@@ -482,7 +482,8 @@ static void do_trace(bitmap_coords_info bci, guchar *trace_px, SPDesktop *deskto
             g_free(str);
         }
 
-        layer_repr->addChild(pathRepr, NULL);
+        //layer_repr->addChild(pathRepr, NULL);
+               desktop->currentLayer()->addChild(pathRepr,NULL);
 
         SPObject *reprobj = document->getObjectByRepr(pathRepr);
         if (reprobj) {
@@ -1137,9 +1138,10 @@ static gint sp_flood_context_item_handler(SPEventContext *event_context, SPItem
             
             SPItem *item = sp_event_context_find_item (desktop, button_w, TRUE, TRUE);
             
-            Inkscape::XML::Node *pathRepr = SP_OBJECT_REPR(item);
+            //Inkscape::XML::Node *pathRepr = SP_OBJECT_REPR(item);
             /* Set style */
-            sp_desktop_apply_style_tool (desktop, pathRepr, "/tools/paintbucket", false);
+            //sp_desktop_apply_style_tool (desktop, pathRepr, "/tools/paintbucket", false);
+                       desktop->applyCurrentOrToolStyle(item, "/tools/paintbucket", false);
             SPDocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_PAINTBUCKET, _("Set style on object"));
             ret = TRUE;
         }
index dcf635989a14d363079704942ef17fec8a541124..f7f2bd7da2c718bc49439c7e8117c64ed17a3228 100644 (file)
@@ -13,7 +13,7 @@ void satisfied_guide_cns(SPDesktop const &desktop,
     for (GSList const *l = nv.guides; l != NULL; l = l->next) {
         SPGuide &g = *SP_GUIDE(l->data);
         for (unsigned int i = 0; i < snappoints.size(); ++i) {
-            if (approx_equal( sp_guide_distance_from_pt(&g, snappoints[i].getPoint()), 0) ) {
+            if (approx_equal( g.getDistanceFrom(snappoints[i].getPoint()), 0) ) {
                 cns.push_back(SPGuideConstraint(&g, i));
             }
         }
index 76cb2e1d9e71d6320f49ab763ebdb8a6d18e40d9..b523322e136eba709d3878078327a4a4592182a2 100644 (file)
@@ -20,7 +20,7 @@
 #include "xml/repr.h"
 #include "document.h"
 
-static void sp_defs_class_init(SPDefsClass *dc);
+/*static void sp_defs_class_init(SPDefsClass *dc);
 static void sp_defs_init(SPDefs *defs);
 
 static void sp_defs_release(SPObject *object);
@@ -28,9 +28,10 @@ static void sp_defs_update(SPObject *object, SPCtx *ctx, guint flags);
 static void sp_defs_modified(SPObject *object, guint flags);
 static Inkscape::XML::Node *sp_defs_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags);
 
-static SPObjectClass *parent_class;
+static SPObjectClass *parent_class;*/
+SPObjectClass * SPDefsClass::static_parent_class = 0;
 
-GType sp_defs_get_type(void)
+GType SPDefs::sp_defs_get_type(void)
 {
     static GType defs_type = 0;
 
@@ -39,7 +40,7 @@ GType sp_defs_get_type(void)
             sizeof(SPDefsClass),
             NULL,      /* base_init */
             NULL,      /* base_finalize */
-            (GClassInitFunc) sp_defs_class_init,
+            (GClassInitFunc) SPDefsClass::sp_defs_class_init,
             NULL,      /* class_finalize */
             NULL,      /* class_data */
             sizeof(SPDefs),
@@ -53,30 +54,30 @@ GType sp_defs_get_type(void)
     return defs_type;
 }
 
-static void sp_defs_class_init(SPDefsClass *dc)
+void SPDefsClass::sp_defs_class_init(SPDefsClass *dc)
 {
-    parent_class = (SPObjectClass *) g_type_class_ref(SP_TYPE_OBJECT);
+    static_parent_class = (SPObjectClass *) g_type_class_ref(SP_TYPE_OBJECT);
     SPObjectClass *sp_object_class = (SPObjectClass *) dc;
 
-    sp_object_class->release = sp_defs_release;
-    sp_object_class->update = sp_defs_update;
-    sp_object_class->modified = sp_defs_modified;
-    sp_object_class->write = sp_defs_write;
+    sp_object_class->release = SPDefs::sp_defs_release;
+    sp_object_class->update = SPDefs::sp_defs_update;
+    sp_object_class->modified = SPDefs::sp_defs_modified;
+    sp_object_class->write = SPDefs::sp_defs_write;
 }
 
-static void sp_defs_init(SPDefs */*defs*/)
+void SPDefs::sp_defs_init(SPDefs */*defs*/)
 {
 
 }
 
-static void sp_defs_release(SPObject *object)
+void SPDefs::sp_defs_release(SPObject *object)
 {
-    if (((SPObjectClass *) (parent_class))->release) {
-        ((SPObjectClass *) (parent_class))->release(object);
+    if (((SPObjectClass *) (SPDefsClass::static_parent_class))->release) {
+        ((SPObjectClass *) (SPDefsClass::static_parent_class))->release(object);
     }
 }
 
-static void sp_defs_update(SPObject *object, SPCtx *ctx, guint flags)
+void SPDefs::sp_defs_update(SPObject *object, SPCtx *ctx, guint flags)
 {
     if (flags & SP_OBJECT_MODIFIED_FLAG) {
         flags |= SP_OBJECT_PARENT_MODIFIED_FLAG;
@@ -95,7 +96,7 @@ static void sp_defs_update(SPObject *object, SPCtx *ctx, guint flags)
     }
 }
 
-static void sp_defs_modified(SPObject *object, guint flags)
+void SPDefs::sp_defs_modified(SPObject *object, guint flags)
 {
     if (flags & SP_OBJECT_MODIFIED_FLAG) {
         flags |= SP_OBJECT_PARENT_MODIFIED_FLAG;
@@ -121,7 +122,7 @@ static void sp_defs_modified(SPObject *object, guint flags)
     }
 }
 
-static Inkscape::XML::Node *sp_defs_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags)
+Inkscape::XML::Node * SPDefs::sp_defs_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags)
 {
     if (flags & SP_OBJECT_WRITE_BUILD) {
 
@@ -147,8 +148,8 @@ static Inkscape::XML::Node *sp_defs_write(SPObject *object, Inkscape::XML::Docum
         }
     }
 
-    if (((SPObjectClass *) (parent_class))->write) {
-        (* ((SPObjectClass *) (parent_class))->write)(object, xml_doc, repr, flags);
+    if (((SPObjectClass *) (SPDefsClass::static_parent_class))->write) {
+        (* ((SPObjectClass *) (SPDefsClass::static_parent_class))->write)(object, xml_doc, repr, flags);
     }
 
     return repr;
index 4b6f7a5b712b3c49bd6b059f00f5edf46a733bb0..c88aef81e61cf5ef824aa847eaee7bc0d3f3ea95 100644 (file)
 
 #include "sp-object.h"
 
-#define SP_TYPE_DEFS            (sp_defs_get_type())
+#define SP_TYPE_DEFS            (SPDefs::sp_defs_get_type())
 #define SP_DEFS(obj)            (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_DEFS, SPDefs))
 #define SP_DEFS_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass), SP_TYPE_DEFS, SPDefsClass))
 #define SP_IS_DEFS(obj)         (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_DEFS))
 #define SP_IS_DEFS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_DEFS))
 
-struct SPDefs : public SPObject {
+class SPDefs : public SPObject {
+       public:
+               static GType sp_defs_get_type(void);
+       
+       private:
+               static void sp_defs_init(SPDefs *defs);
+               static void sp_defs_release(SPObject *object);
+               static void sp_defs_update(SPObject *object, SPCtx *ctx, guint flags);
+               static void sp_defs_modified(SPObject *object, guint flags);
+               static Inkscape::XML::Node *sp_defs_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags);
+
+       friend class SPDefsClass;       
 };
 
-struct SPDefsClass {
-    SPObjectClass parent_class;
+class SPDefsClass {
+       public:
+               SPObjectClass parent_class;
+
+       private:
+               static void sp_defs_class_init(SPDefsClass *dc);
+               static SPObjectClass *static_parent_class;
+
+       friend class SPDefs;    
 };
 
-GType sp_defs_get_type(void);
+//GType sp_defs_get_type(void);
 
 
 #endif /* !SEEN_SP_DEFS_H */
index e43c3056d4ad635b5f2566b8e4e93ec5d65fd9b5..21b3504860c684b77114c7edae77846e60a35be9 100644 (file)
@@ -242,7 +242,7 @@ static void sp_guide_set(SPObject *object, unsigned int key, const gchar *value)
 }
 
 SPGuide *
-sp_guide_create(SPDesktop *desktop, Geom::Point const &pt1, Geom::Point const &pt2) {
+SPGuide::createSPGuide(SPDesktop *desktop, Geom::Point const &pt1, Geom::Point const &pt2) {
     SPDocument *doc=sp_desktop_document(desktop);
     Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc);
 
@@ -253,7 +253,8 @@ sp_guide_create(SPDesktop *desktop, Geom::Point const &pt1, Geom::Point const &p
     sp_repr_set_point(repr, "position", pt1);
     sp_repr_set_point(repr, "orientation", n);
 
-    SP_OBJECT_REPR(desktop->namedview)->appendChild(repr);
+    //SP_OBJECT_REPR(desktop->namedview)->appendChild(repr);
+    desktop->namedview->appendChild(repr);
     Inkscape::GC::release(repr);
 
     SPGuide *guide= SP_GUIDE(doc->getObjectByRepr(repr));
@@ -263,7 +264,7 @@ sp_guide_create(SPDesktop *desktop, Geom::Point const &pt1, Geom::Point const &p
 void
 sp_guide_pt_pairs_to_guides(SPDesktop *dt, std::list<std::pair<Geom::Point, Geom::Point> > &pts) {
     for (std::list<std::pair<Geom::Point, Geom::Point> >::iterator i = pts.begin(); i != pts.end(); ++i) {
-        sp_guide_create(dt, (*i).first, (*i).second);
+               SPGuide::createSPGuide(dt, (*i).first, (*i).second);
     }
 }
 
@@ -287,27 +288,27 @@ sp_guide_create_guides_around_page(SPDesktop *dt) {
     SPDocumentUndo::done (doc, SP_VERB_NONE, _("Guides Around Page"));
 }
 
-void sp_guide_show(SPGuide *guide, SPCanvasGroup *group, GCallback handler)
+void SPGuide::showSPGuide(SPCanvasGroup *group, GCallback handler)
 {
-    SPCanvasItem *item = sp_guideline_new(group, guide->point_on_line, guide->normal_to_line);
-    sp_guideline_set_color(SP_GUIDELINE(item), guide->color);
+    SPCanvasItem *item = sp_guideline_new(group, this->point_on_line, this->normal_to_line);
+    sp_guideline_set_color(SP_GUIDELINE(item), this->color);
 
-    g_signal_connect(G_OBJECT(item), "event", G_CALLBACK(handler), guide);
+    g_signal_connect(G_OBJECT(item), "event", G_CALLBACK(handler), this);
 
-    guide->views = g_slist_prepend(guide->views, item);
+    this->views = g_slist_prepend(this->views, item);
 }
 
-void sp_guide_hide(SPGuide *guide, SPCanvas *canvas)
+void SPGuide::hideSPGuide(SPCanvas *canvas)
 {
-    g_assert(guide != NULL);
-    g_assert(SP_IS_GUIDE(guide));
+    //g_assert(guide != NULL);
+    //g_assert(SP_IS_GUIDE(guide));
     g_assert(canvas != NULL);
     g_assert(SP_IS_CANVAS(canvas));
 
-    for (GSList *l = guide->views; l != NULL; l = l->next) {
+    for (GSList *l = this->views; l != NULL; l = l->next) {
         if (canvas == SP_CANVAS_ITEM(l->data)->canvas) {
             sp_guideline_delete(SP_GUIDELINE(l->data));
-            guide->views = g_slist_remove(guide->views, l->data);
+            this->views = g_slist_remove(this->views, l->data);
             return;
         }
     }
@@ -315,14 +316,14 @@ void sp_guide_hide(SPGuide *guide, SPCanvas *canvas)
     g_assert_not_reached();
 }
 
-void sp_guide_sensitize(SPGuide *guide, SPCanvas *canvas, gboolean sensitive)
+void SPGuide::sensitize(SPCanvas *canvas, gboolean sensitive)
 {
-    g_assert(guide != NULL);
-    g_assert(SP_IS_GUIDE(guide));
+    //g_assert(guide != NULL);
+    //g_assert(SP_IS_GUIDE(guide));
     g_assert(canvas != NULL);
     g_assert(SP_IS_CANVAS(canvas));
 
-    for (GSList *l = guide->views; l != NULL; l = l->next) {
+    for (GSList *l = this->views; l != NULL; l = l->next) {
         if (canvas == SP_CANVAS_ITEM(l->data)->canvas) {
             sp_guideline_set_sensitive(SP_GUIDELINE(l->data), sensitive);
             return;
@@ -332,14 +333,14 @@ void sp_guide_sensitize(SPGuide *guide, SPCanvas *canvas, gboolean sensitive)
     g_assert_not_reached();
 }
 
-Geom::Point sp_guide_position_from_pt(SPGuide const *guide, Geom::Point const &pt)
+Geom::Point SPGuide::getPositionFrom(Geom::Point const &pt) const
 {
-    return -(pt - guide->point_on_line);
+    return -(pt - this->point_on_line);
 }
 
-double sp_guide_distance_from_pt(SPGuide const *guide, Geom::Point const &pt)
+double SPGuide::getDistanceFrom(Geom::Point const &pt) const
 {
-    return Geom::dot(pt - guide->point_on_line, guide->normal_to_line);
+    return Geom::dot(pt - this->point_on_line, this->normal_to_line);
 }
 
 /**
index 6bf541cd1e562a32287fd87c9655a196011e2e6f..b5914e8905400db28694f46710c2293912389baa 100644 (file)
@@ -25,7 +25,8 @@
 #define SP_IS_GUIDE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_GUIDE))
 
 /* Represents the constraint on p that dot(g.direction, p) == g.position. */
-struct SPGuide : public SPObject {
+class SPGuide : public SPObject {
+       public:
     Geom::Point normal_to_line;
     Geom::Point point_on_line;
 
@@ -37,24 +38,31 @@ struct SPGuide : public SPObject {
     inline bool is_horizontal() const { return (normal_to_line[Geom::X] == 0.); };
     inline bool is_vertical() const { return (normal_to_line[Geom::Y] == 0.); };
     inline double angle() const { return std::atan2( - normal_to_line[Geom::X], normal_to_line[Geom::Y] ); };
+       static SPGuide *createSPGuide(SPDesktop *desktop, Geom::Point const &pt1, Geom::Point const &pt2);
+       void showSPGuide(SPCanvasGroup *group, GCallback handler);
+       void hideSPGuide(SPCanvas *canvas);
+       void sensitize(SPCanvas *canvas, gboolean sensitive);
+       Geom::Point getPositionFrom(Geom::Point const &pt) const;
+       double getDistanceFrom(Geom::Point const &pt) const;
 };
 
-struct SPGuideClass {
+class SPGuideClass {
+       public:
     SPObjectClass parent_class;
 };
 
 GType sp_guide_get_type();
 
-SPGuide *sp_guide_create(SPDesktop *desktop, Geom::Point const &pt1, Geom::Point const &pt2);
+//SPGuide *sp_guide_create(SPDesktop *desktop, Geom::Point const &pt1, Geom::Point const &pt2);
 void sp_guide_pt_pairs_to_guides(SPDesktop *dt, std::list<std::pair<Geom::Point, Geom::Point> > &pts);
 void sp_guide_create_guides_around_page(SPDesktop *dt);
 
-void sp_guide_show(SPGuide *guide, SPCanvasGroup *group, GCallback handler);
-void sp_guide_hide(SPGuide *guide, SPCanvas *canvas);
-void sp_guide_sensitize(SPGuide *guide, SPCanvas *canvas, gboolean sensitive);
+//void sp_guide_show(SPGuide *guide, SPCanvasGroup *group, GCallback handler);
+//void sp_guide_hide(SPGuide *guide, SPCanvas *canvas);
+//void sp_guide_sensitize(SPGuide *guide, SPCanvas *canvas, gboolean sensitive);
 
-Geom::Point sp_guide_position_from_pt(SPGuide const *guide, Geom::Point const &pt);
-double sp_guide_distance_from_pt(SPGuide const *guide, Geom::Point const &pt);
+//Geom::Point sp_guide_position_from_pt(SPGuide const *guide, Geom::Point const &pt);
+//double sp_guide_distance_from_pt(SPGuide const *guide, Geom::Point const &pt);
 void sp_guide_moveto(SPGuide const &guide, Geom::Point const point_on_line, bool const commit);
 void sp_guide_set_normal(SPGuide const &guide, Geom::Point const normal_to_line, bool const commit);
 void sp_guide_remove(SPGuide *guide);
index e92a573f1e11c76767758186b1ccfa593c0c5861..a7f29fb806d1c4bb72233d9d0df5649e4b6c3a67 100644 (file)
@@ -21,7 +21,7 @@ void sp_item_rm_unsatisfied_cns(SPItem &item)
         SPGuideConstraint const &cn = item.constraints[i];
         int const snappoint_ix = cn.snappoint_ix;
         g_assert( snappoint_ix < int(snappoints.size()) );
-        if (!approx_equal( sp_guide_distance_from_pt(cn.g, snappoints[snappoint_ix].getPoint()), 0) ) {
+        if (!approx_equal( cn.g->getDistanceFrom(snappoints[snappoint_ix].getPoint()), 0) ) {
             remove_last(cn.g->attached_items, SPGuideAttachment(&item, cn.snappoint_ix));
             g_assert( i < item.constraints.size() );
             vector<SPGuideConstraint>::iterator const ei(&item.constraints[i]);
index b29e51b5a5bc2e5607a8b205e2b8668e32246f0c..b71616c5b05fa68f35ee92e639bb96a88ae6860f 100644 (file)
@@ -207,7 +207,7 @@ SPLine::sp_line_convert_to_guides(SPItem *item)
        points[0] = Geom::Point(line->x1.computed, line->y1.computed)*i2d;
        points[1] = Geom::Point(line->x2.computed, line->y2.computed)*i2d;
 
-       sp_guide_create(inkscape_active_desktop(), points[0], points[1]);
+       SPGuide::createSPGuide(inkscape_active_desktop(), points[0], points[1]);
 }
 
 Geom::Matrix
index 7c974802ea0e90411e29e18db842ae25c92b40eb..c4ce6355b320c1ace8d770b0fd77b2305887fd25 100644 (file)
@@ -642,10 +642,9 @@ static void sp_namedview_child_added(SPObject *object, Inkscape::XML::Node *chil
             g_object_set(G_OBJECT(g), "color", nv->guidecolor, "hicolor", nv->guidehicolor, NULL);
             if (nv->editable) {
                 for (GSList *l = nv->views; l != NULL; l = l->next) {
-                    sp_guide_show(g, static_cast<SPDesktop*>(l->data)->guides, (GCallback) sp_dt_guide_event);
+                    g->SPGuide::showSPGuide(static_cast<SPDesktop*>(l->data)->guides, (GCallback) sp_dt_guide_event);
                     if (static_cast<SPDesktop*>(l->data)->guides_active)
-                        sp_guide_sensitize(g,
-                                           sp_desktop_canvas(static_cast<SPDesktop*> (l->data)),
+                        g->sensitize(sp_desktop_canvas(static_cast<SPDesktop*> (l->data)),
                                            TRUE);
                     sp_namedview_show_single_guide(SP_GUIDE(g), nv->showguides);
                 }
@@ -703,9 +702,9 @@ static Inkscape::XML::Node *sp_namedview_write(SPObject *object, Inkscape::XML::
 void SPNamedView::show(SPDesktop *desktop)
 {
     for (GSList *l = guides; l != NULL; l = l->next) {
-        sp_guide_show(SP_GUIDE(l->data), desktop->guides, (GCallback) sp_dt_guide_event);
+        SP_GUIDE(l->data)->showSPGuide( desktop->guides, (GCallback) sp_dt_guide_event);
         if (desktop->guides_active) {
-            sp_guide_sensitize(SP_GUIDE(l->data), sp_desktop_canvas(desktop), TRUE);
+            SP_GUIDE(l->data)->sensitize(sp_desktop_canvas(desktop), TRUE);
         }
         sp_namedview_show_single_guide(SP_GUIDE(l->data), showguides);
     }
@@ -841,7 +840,7 @@ void SPNamedView::hide(SPDesktop const *desktop)
     g_assert(g_slist_find(views, desktop));
 
     for (GSList *l = guides; l != NULL; l = l->next) {
-        sp_guide_hide(SP_GUIDE(l->data), sp_desktop_canvas(desktop));
+        SP_GUIDE(l->data)->hideSPGuide(sp_desktop_canvas(desktop));
     }
 
     views = g_slist_remove(views, desktop);
@@ -855,7 +854,7 @@ void SPNamedView::activateGuides(gpointer desktop, gboolean active)
     SPDesktop *dt = static_cast<SPDesktop*>(desktop);
 
     for (GSList *l = guides; l != NULL; l = l->next) {
-        sp_guide_sensitize(SP_GUIDE(l->data), sp_desktop_canvas(dt), active);
+        SP_GUIDE(l->data)->sensitize( sp_desktop_canvas(dt), active);
     }
 }
 
index 02ae5d29a22cdc3ebf447609cdd4f094fb7d2525..d0e5c01a7b19ead841016cf8bd021a2d9cd57507 100644 (file)
 #include "xml/repr.h"
 #include "document.h"
 
-static void sp_objectgroup_class_init (SPObjectGroupClass *klass);
+/*static void sp_objectgroup_class_init (SPObjectGroupClass *klass);
 static void sp_objectgroup_init (SPObjectGroup *objectgroup);
 
 static void sp_objectgroup_child_added (SPObject * object, Inkscape::XML::Node * child, Inkscape::XML::Node * ref);
 static void sp_objectgroup_remove_child (SPObject * object, Inkscape::XML::Node * child);
 static void sp_objectgroup_order_changed (SPObject * object, Inkscape::XML::Node * child, Inkscape::XML::Node * old_ref, Inkscape::XML::Node * new_ref);
-static Inkscape::XML::Node *sp_objectgroup_write (SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags);
+static Inkscape::XML::Node *sp_objectgroup_write (SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags);*/
 
-static SPObjectClass *parent_class;
+//static SPObjectClass *parent_class;
+
+SPObjectClass * SPObjectGroupClass::static_parent_class = 0;
 
 GType
-sp_objectgroup_get_type (void)
+SPObjectGroup::sp_objectgroup_get_type (void)
 {
        static GType objectgroup_type = 0;
        if (!objectgroup_type) {
@@ -35,7 +37,7 @@ sp_objectgroup_get_type (void)
                        sizeof (SPObjectGroupClass),
                        NULL,   /* base_init */
                        NULL,   /* base_finalize */
-                       (GClassInitFunc) sp_objectgroup_class_init,
+                       (GClassInitFunc) SPObjectGroupClass::sp_objectgroup_class_init,
                        NULL,   /* class_finalize */
                        NULL,   /* class_data */
                        sizeof (SPObjectGroup),
@@ -48,8 +50,8 @@ sp_objectgroup_get_type (void)
        return objectgroup_type;
 }
 
-static void
-sp_objectgroup_class_init (SPObjectGroupClass *klass)
+void
+SPObjectGroupClass::sp_objectgroup_class_init (SPObjectGroupClass *klass)
 {
        GObjectClass * object_class;
        SPObjectClass * sp_object_class;
@@ -57,48 +59,48 @@ sp_objectgroup_class_init (SPObjectGroupClass *klass)
        object_class = (GObjectClass *) klass;
        sp_object_class = (SPObjectClass *) klass;
 
-       parent_class = (SPObjectClass *)g_type_class_ref (SP_TYPE_OBJECT);
+       static_parent_class = (SPObjectClass *)g_type_class_ref (SP_TYPE_OBJECT);
 
-       sp_object_class->child_added = sp_objectgroup_child_added;
-       sp_object_class->remove_child = sp_objectgroup_remove_child;
-       sp_object_class->order_changed = sp_objectgroup_order_changed;
-       sp_object_class->write = sp_objectgroup_write;
+       sp_object_class->child_added = SPObjectGroup::sp_objectgroup_child_added;
+       sp_object_class->remove_child = SPObjectGroup::sp_objectgroup_remove_child;
+       sp_object_class->order_changed = SPObjectGroup::sp_objectgroup_order_changed;
+       sp_object_class->write = SPObjectGroup::sp_objectgroup_write;
 }
 
-static void
-sp_objectgroup_init (SPObjectGroup */*objectgroup*/)
+void
+SPObjectGroup::sp_objectgroup_init (SPObjectGroup */*objectgroup*/)
 {
 }
 
-static void
-sp_objectgroup_child_added (SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref)
+void
+SPObjectGroup::sp_objectgroup_child_added (SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref)
 {
-       if (((SPObjectClass *) (parent_class))->child_added)
-               (* ((SPObjectClass *) (parent_class))->child_added) (object, child, ref);
+       if (((SPObjectClass *) (SPObjectGroupClass::static_parent_class))->child_added)
+               (* ((SPObjectClass *) (SPObjectGroupClass::static_parent_class))->child_added) (object, child, ref);
 
        object->requestModified(SP_OBJECT_MODIFIED_FLAG);
 }
 
-static void
-sp_objectgroup_remove_child (SPObject *object, Inkscape::XML::Node *child)
+void
+SPObjectGroup::sp_objectgroup_remove_child (SPObject *object, Inkscape::XML::Node *child)
 {
-       if (((SPObjectClass *) (parent_class))->remove_child)
-               (* ((SPObjectClass *) (parent_class))->remove_child) (object, child);
+       if (((SPObjectClass *) (SPObjectGroupClass::static_parent_class))->remove_child)
+               (* ((SPObjectClass *) (SPObjectGroupClass::static_parent_class))->remove_child) (object, child);
 
        object->requestModified(SP_OBJECT_MODIFIED_FLAG);
 }
 
-static void
-sp_objectgroup_order_changed (SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *old_ref, Inkscape::XML::Node *new_ref)
+void
+SPObjectGroup::sp_objectgroup_order_changed (SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *old_ref, Inkscape::XML::Node *new_ref)
 {
-       if (((SPObjectClass *) (parent_class))->order_changed)
-               (* ((SPObjectClass *) (parent_class))->order_changed) (object, child, old_ref, new_ref);
+       if (((SPObjectClass *) (SPObjectGroupClass::static_parent_class))->order_changed)
+               (* ((SPObjectClass *) (SPObjectGroupClass::static_parent_class))->order_changed) (object, child, old_ref, new_ref);
 
        object->requestModified(SP_OBJECT_MODIFIED_FLAG);
 }
 
-static Inkscape::XML::Node *
-sp_objectgroup_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags)
+Inkscape::XML::Node *
+SPObjectGroup::sp_objectgroup_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags)
 {
        SPObjectGroup *group;
        SPObject *child;
@@ -127,8 +129,8 @@ sp_objectgroup_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inksca
                }
        }
 
-       if (((SPObjectClass *) (parent_class))->write)
-               ((SPObjectClass *) (parent_class))->write (object, xml_doc, repr, flags);
+       if (((SPObjectClass *) (SPObjectGroupClass::static_parent_class))->write)
+               ((SPObjectClass *) (SPObjectGroupClass::static_parent_class))->write (object, xml_doc, repr, flags);
 
        return repr;
 }
index 5d67df6fecea0518c615f1cec8b9c9a156f2ae44..7d35cfc178aebf270ab7401929c1908fd0a79aad 100644 (file)
 
 #include "sp-object.h"
 
-#define SP_TYPE_OBJECTGROUP (sp_objectgroup_get_type ())
+#define SP_TYPE_OBJECTGROUP (SPObjectGroup::sp_objectgroup_get_type ())
 #define SP_OBJECTGROUP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_OBJECTGROUP, SPObjectGroup))
 #define SP_OBJECTGROUP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SP_TYPE_OBJECTGROUP, SPObjectGroupClass))
 #define SP_IS_OBJECTGROUP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_OBJECTGROUP))
 #define SP_IS_OBJECTGROUP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_OBJECTGROUP))
 
-struct SPObjectGroup : public SPObject {
+class SPObjectGroup : public SPObject {
+       public:
+               static GType sp_objectgroup_get_type (void);
+
+       private:
+               static void sp_objectgroup_init (SPObjectGroup *objectgroup);
+
+               static void sp_objectgroup_child_added (SPObject * object, Inkscape::XML::Node * child, Inkscape::XML::Node * ref);
+               static void sp_objectgroup_remove_child (SPObject * object, Inkscape::XML::Node * child);
+               static void sp_objectgroup_order_changed (SPObject * object, Inkscape::XML::Node * child, Inkscape::XML::Node * old_ref, Inkscape::XML::Node * new_ref);
+               static Inkscape::XML::Node *sp_objectgroup_write (SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags);
+
+       friend class SPObjectGroupClass;        
 };
 
-struct SPObjectGroupClass {
-       SPObjectClass parent_class;
+class SPObjectGroupClass {
+       public:
+               SPObjectClass parent_class;
+
+       private:
+               static void sp_objectgroup_class_init (SPObjectGroupClass *klass);
+               static SPObjectClass *static_parent_class;
+
+       friend class SPObjectGroup;     
 };
 
-GType sp_objectgroup_get_type (void);
+//GType sp_objectgroup_get_type (void);
 
 #endif
index f23f374d47f030284bd43cd7231ff682a158807c..80f39db4ac9051f5fe223a71ad2ff8a8fa2ec06f 100644 (file)
@@ -937,6 +937,13 @@ void SPObject::appendChild(Inkscape::XML::Node *child) {
        repr->appendChild(child);
 }
 
+void SPObject::addChild(Inkscape::XML::Node *child, Inkscape::XML::Node * prev)
+{
+       g_assert(this->repr);
+
+       repr->addChild(child,prev);
+}
+
 void SPObject::releaseReferences() {
     g_assert(this->document);
     g_assert(this->repr);
index 61c69c3aa0177c875b40fdd99024b16e7d19d9ea..4856bdd06757fccb4e0937da7621f89778eb79ae 100644 (file)
@@ -532,6 +532,7 @@ public:
        unsigned getPosition();
        gchar const * getAttribute(gchar const *name,SPException *ex=0) const;
        void appendChild(Inkscape::XML::Node *child);
+       void addChild(Inkscape::XML::Node *child,Inkscape::XML::Node *prev=0);
        void setKeyValue(unsigned int key, gchar const *value);
        void setAttribute(gchar const *key, gchar const *value, SPException *ex=0);
        void readAttr(gchar const *key);