From 42cbda336acf8dff794bc284e8e6d0c474e3e2e5 Mon Sep 17 00:00:00 2001 From: joncruz Date: Tue, 20 May 2008 07:21:30 +0000 Subject: [PATCH] Refactoring begining --- src/dyna-draw-context.cpp | 19 ++++++++++--------- src/dyna-draw-context.h | 8 ++++---- src/eraser-context.cpp | 33 +++++++++++++++++---------------- src/eraser-context.h | 17 ++++++++--------- 4 files changed, 39 insertions(+), 38 deletions(-) diff --git a/src/dyna-draw-context.cpp b/src/dyna-draw-context.cpp index cc79dfd2e..9574d2cad 100644 --- a/src/dyna-draw-context.cpp +++ b/src/dyna-draw-context.cpp @@ -119,22 +119,23 @@ static void draw_temporary_box(SPDynaDrawContext *dc); static SPEventContextClass *parent_class; -GtkType -sp_dyna_draw_context_get_type(void) +GType sp_dyna_draw_context_get_type(void) { static GType type = 0; if (!type) { GTypeInfo info = { sizeof(SPDynaDrawContextClass), - NULL, NULL, - (GClassInitFunc) sp_dyna_draw_context_class_init, - NULL, NULL, + 0, // base_init + 0, // base_finalize + (GClassInitFunc)sp_dyna_draw_context_class_init, + 0, // class_finalize + 0, // class_data sizeof(SPDynaDrawContext), - 4, - (GInstanceInitFunc) sp_dyna_draw_context_init, - NULL, /* value_table */ + 0, // n_preallocs + (GInstanceInitFunc)sp_dyna_draw_context_init, + 0 // value_table }; - type = g_type_register_static(SP_TYPE_EVENT_CONTEXT, "SPDynaDrawContext", &info, (GTypeFlags)0); + type = g_type_register_static(SP_TYPE_EVENT_CONTEXT, "SPDynaDrawContext", &info, static_cast(0)); } return type; } diff --git a/src/dyna-draw-context.h b/src/dyna-draw-context.h index 40e6c6376..0e83f6b50 100644 --- a/src/dyna-draw-context.h +++ b/src/dyna-draw-context.h @@ -1,5 +1,5 @@ -#ifndef __SP_DYNA_DRAW_CONTEXT_H__ -#define __SP_DYNA_DRAW_CONTEXT_H__ +#ifndef SP_DYNA_DRAW_CONTEXT_H_SEEN +#define SP_DYNA_DRAW_CONTEXT_H_SEEN /* * Handwriting-like drawing mode @@ -125,9 +125,9 @@ struct SPDynaDrawContextClass SPEventContextClass parent_class; }; -GtkType sp_dyna_draw_context_get_type(void); +GType sp_dyna_draw_context_get_type(void); -#endif +#endif // SP_DYNA_DRAW_CONTEXT_H_SEEN /* Local Variables: diff --git a/src/eraser-context.cpp b/src/eraser-context.cpp index 3fe661f99..f30b004ea 100644 --- a/src/eraser-context.cpp +++ b/src/eraser-context.cpp @@ -104,24 +104,25 @@ static NR::Point sp_eraser_get_vpoint(SPEraserContext const *erc, NR::Point n); static void draw_temporary_box(SPEraserContext *dc); -static SPEventContextClass *parent_class; +static SPEventContextClass *eraser_parent_class = 0; -GtkType -sp_eraser_context_get_type(void) +GType sp_eraser_context_get_type(void) { static GType type = 0; if (!type) { GTypeInfo info = { sizeof(SPEraserContextClass), - NULL, NULL, - (GClassInitFunc) sp_eraser_context_class_init, - NULL, NULL, + 0, // base_init + 0, // base_finalize + (GClassInitFunc)sp_eraser_context_class_init, + 0, // class_finalize + 0, // class_data sizeof(SPEraserContext), - 4, - (GInstanceInitFunc) sp_eraser_context_init, - NULL, /* value_table */ + 0, // n_preallocs + (GInstanceInitFunc)sp_eraser_context_init, + 0 // value_table }; - type = g_type_register_static(SP_TYPE_EVENT_CONTEXT, "SPEraserContext", &info, (GTypeFlags)0); + type = g_type_register_static(SP_TYPE_EVENT_CONTEXT, "SPEraserContext", &info, static_cast(0)); } return type; } @@ -132,7 +133,7 @@ sp_eraser_context_class_init(SPEraserContextClass *klass) GObjectClass *object_class = (GObjectClass *) klass; SPEventContextClass *event_context_class = (SPEventContextClass *) klass; - parent_class = (SPEventContextClass*)g_type_class_peek_parent(klass); + eraser_parent_class = (SPEventContextClass*)g_type_class_peek_parent(klass); object_class->dispose = sp_eraser_context_dispose; @@ -212,7 +213,7 @@ sp_eraser_context_dispose(GObject *object) erc->_message_context = 0; } - G_OBJECT_CLASS(parent_class)->dispose(object); + G_OBJECT_CLASS(eraser_parent_class)->dispose(object); } static void @@ -220,8 +221,8 @@ sp_eraser_context_setup(SPEventContext *ec) { SPEraserContext *erc = SP_ERASER_CONTEXT(ec); - if (((SPEventContextClass *) parent_class)->setup) - ((SPEventContextClass *) parent_class)->setup(ec); + if (((SPEventContextClass *) eraser_parent_class)->setup) + ((SPEventContextClass *) eraser_parent_class)->setup(ec); erc->accumulated = new SPCurve(32); erc->currentcurve = new SPCurve(4); @@ -774,8 +775,8 @@ sp_eraser_context_root_handler(SPEventContext *event_context, } if (!ret) { - if (((SPEventContextClass *) parent_class)->root_handler) { - ret = ((SPEventContextClass *) parent_class)->root_handler(event_context, event); + if (((SPEventContextClass *) eraser_parent_class)->root_handler) { + ret = ((SPEventContextClass *) eraser_parent_class)->root_handler(event_context, event); } } diff --git a/src/eraser-context.h b/src/eraser-context.h index bc862012d..b47c21b57 100644 --- a/src/eraser-context.h +++ b/src/eraser-context.h @@ -43,10 +43,7 @@ class SPEraserContextClass; #define ERC_MAX_TILT 1.0 #define ERC_DEFAULT_TILT 0.0 -struct SPEraserContext -{ - SPEventContext event_context; - +struct SPEraserContext : public SPEventContext { /** accumulated shape which ultimately goes in svg:path */ SPCurve *accumulated; @@ -60,13 +57,16 @@ struct SPEraserContext /** left edge of the stroke; combined to get accumulated */ SPCurve *cal1; + /** right edge of the stroke; combined to get accumulated */ SPCurve *cal2; /** left edge points for this segment */ NR::Point point1[SAMPLING_SIZE]; + /** right edge points for this segment */ NR::Point point2[SAMPLING_SIZE]; + /** number of edge points for this segment */ gint npoints; @@ -81,10 +81,12 @@ struct SPEraserContext NR::Point ang; NR::Point last; NR::Point del; + /* extended input data */ gdouble pressure; gdouble xtilt; gdouble ytilt; + /* attributes */ guint dragging : 1; /* mouse state: mouse is dragging */ guint usepressure : 1; @@ -106,12 +108,9 @@ struct SPEraserContext bool abs_width; }; -struct SPEraserContextClass -{ - SPEventContextClass parent_class; -}; +struct SPEraserContextClass : public SPEventContextClass{}; -GtkType sp_eraser_context_get_type(void); +GType sp_eraser_context_get_type(void); #endif // SP_ERASER_CONTEXT_H_SEEN -- 2.30.2