summaryrefslogtreecommitdiffstats
path: root/src/pencil-context.cpp
diff options
context:
space:
mode:
authorMarkus Engel <markus.engel@tum.de>2013-04-20 21:19:46 +0000
committerMarkus Engel <markus.engel@tum.de>2013-04-20 21:19:46 +0000
commit65ba6ad9a82f8f47974eb10665478fd783692bb5 (patch)
tree21ecad9197b19c636e7950503ea8f2a9a5366194 /src/pencil-context.cpp
parentFurther changes to EventContexts; they work without GObject (diff)
downloadinkscape-65ba6ad9a82f8f47974eb10665478fd783692bb5.tar.gz
inkscape-65ba6ad9a82f8f47974eb10665478fd783692bb5.zip
Merging of EventContext classes complete.
(bzr r11608.1.98)
Diffstat (limited to 'src/pencil-context.cpp')
-rw-r--r--src/pencil-context.cpp77
1 files changed, 8 insertions, 69 deletions
diff --git a/src/pencil-context.cpp b/src/pencil-context.cpp
index 3c2269bd2..e13e6985c 100644
--- a/src/pencil-context.cpp
+++ b/src/pencil-context.cpp
@@ -45,10 +45,6 @@
#include "display/curve.h"
#include "livarot/Path.h"
-static void sp_pencil_context_setup(SPEventContext *ec);
-static void sp_pencil_context_dispose(GObject *object);
-
-static gint sp_pencil_context_root_handler(SPEventContext *event_context, GdkEvent *event);
static gint pencil_handle_button_press(SPPencilContext *const pc, GdkEventButton const &bevent);
static gint pencil_handle_motion_notify(SPPencilContext *const pc, GdkEventMotion const &mevent);
static gint pencil_handle_button_release(SPPencilContext *const pc, GdkEventButton const &revent);
@@ -78,45 +74,15 @@ namespace {
bool pencilContextRegistered = ToolFactory::instance().registerObject("/tools/freehand/pencil", createPencilContext);
}
-const std::string& CPencilContext::getPrefsPath() {
+const std::string& SPPencilContext::getPrefsPath() {
return SPPencilContext::prefsPath;
}
const std::string SPPencilContext::prefsPath = "/tools/freehand/pencil";
-G_DEFINE_TYPE(SPPencilContext, sp_pencil_context, SP_TYPE_DRAW_CONTEXT);
-
-/**
- * Initialize SPPencilContext vtable.
- */
-static void
-sp_pencil_context_class_init(SPPencilContextClass *klass)
-{
- GObjectClass *object_class;
- SPEventContextClass *event_context_class;
-
- object_class = (GObjectClass *) klass;
- event_context_class = (SPEventContextClass *) klass;
-
- object_class->dispose = sp_pencil_context_dispose;
-
-// event_context_class->setup = sp_pencil_context_setup;
-// event_context_class->root_handler = sp_pencil_context_root_handler;
-}
-
-CPencilContext::CPencilContext(SPPencilContext* pencilcontext) : CDrawContext(pencilcontext) {
- this->sppencilcontext = pencilcontext;
-}
-
SPPencilContext::SPPencilContext() : SPDrawContext() {
SPPencilContext* pc = this;
- pc->cpencilcontext = new CPencilContext(pc);
- delete pc->cdrawcontext;
- pc->cdrawcontext = pc->cpencilcontext;
- pc->ceventcontext = pc->cpencilcontext;
- types.insert(typeid(SPPencilContext));
-
pc->is_drawing = false;
SPEventContext *event_context = SP_EVENT_CONTEXT(pc);
@@ -134,26 +100,8 @@ SPPencilContext::SPPencilContext() : SPDrawContext() {
pc->sketch_n = 0;
}
-/**
- * Callback to initialize SPPencilContext object.
- */
-static void
-sp_pencil_context_init(SPPencilContext *pc)
-{
- new (pc) SPPencilContext();
-}
-
-/**
- * Callback to setup SPPencilContext object.
- */
-static void
-sp_pencil_context_setup(SPEventContext *ec)
-{
- ec->ceventcontext->setup();
-}
-
-void CPencilContext::setup() {
- SPEventContext* ec = this->speventcontext;
+void SPPencilContext::setup() {
+ SPEventContext* ec = this;
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
if (prefs->getBool("/tools/freehand/pencil/selcue")) {
@@ -163,7 +111,7 @@ void CPencilContext::setup() {
// if (((SPEventContextClass *) sp_pencil_context_parent_class)->setup) {
// ((SPEventContextClass *) sp_pencil_context_parent_class)->setup(ec);
// }
- CDrawContext::setup();
+ SPDrawContext::setup();
SPPencilContext *const pc = SP_PENCIL_CONTEXT(ec);
pc->is_drawing = false;
@@ -171,10 +119,7 @@ void CPencilContext::setup() {
pc->anchor_statusbar = false;
}
-static void
-sp_pencil_context_dispose(GObject *object)
-{
- G_OBJECT_CLASS(sp_pencil_context_parent_class)->dispose(object);
+SPPencilContext::~SPPencilContext() {
}
/** Snaps new node relative to the previous node. */
@@ -198,14 +143,8 @@ spdc_endpoint_snap(SPPencilContext const *pc, Geom::Point &p, guint const state)
/**
* Callback for handling all pencil context events.
*/
-gint
-sp_pencil_context_root_handler(SPEventContext *const ec, GdkEvent *event)
-{
- return ec->ceventcontext->root_handler(event);
-}
-
-gint CPencilContext::root_handler(GdkEvent* event) {
- SPEventContext* ec = this->speventcontext;
+gint SPPencilContext::root_handler(GdkEvent* event) {
+ SPEventContext* ec = this;
SPPencilContext *const pc = SP_PENCIL_CONTEXT(ec);
@@ -242,7 +181,7 @@ gint CPencilContext::root_handler(GdkEvent* event) {
// if (parent_root_handler) {
// ret = parent_root_handler(ec, event);
// }
- ret = CDrawContext::root_handler(event);
+ ret = SPDrawContext::root_handler(event);
}
return ret;