From fbdc8b84ff670c684dafc7d7d403ed01e7077e70 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Sat, 13 Apr 2013 18:13:17 +0200 Subject: Replaced casting macros for EventContext tree; added contructors. (bzr r11608.1.96) --- src/zoom-context.cpp | 44 ++++++++++++++++---------------------------- 1 file changed, 16 insertions(+), 28 deletions(-) (limited to 'src/zoom-context.cpp') diff --git a/src/zoom-context.cpp b/src/zoom-context.cpp index 92c50b148..8e5f4753d 100644 --- a/src/zoom-context.cpp +++ b/src/zoom-context.cpp @@ -26,17 +26,25 @@ #include "zoom-context.h" -static void sp_zoom_context_setup(SPEventContext *ec); -static void sp_zoom_context_finish (SPEventContext *ec); - -static gint sp_zoom_context_root_handler(SPEventContext *event_context, GdkEvent *event); -static gint sp_zoom_context_item_handler(SPEventContext *event_context, SPItem *item, GdkEvent *event); - static gint xp = 0, yp = 0; // where drag started static gint tolerance = 0; static bool within_tolerance = false; static bool escaped; +#include "sp-factory.h" + +namespace { + SPEventContext* createZoomContext() { + return new SPZoomContext(); + } + + bool zoomContextRegistered = ToolFactory::instance().registerObject("/tools/zoom", createZoomContext); +} + +const std::string& CZoomContext::getPrefsPath() { + return SPZoomContext::prefsPath; +} + const std::string SPZoomContext::prefsPath = "/tools/zoom"; G_DEFINE_TYPE(SPZoomContext, sp_zoom_context, SP_TYPE_EVENT_CONTEXT); @@ -62,6 +70,7 @@ SPZoomContext::SPZoomContext() : SPEventContext() { zoom_context->czoomcontext = new CZoomContext(zoom_context); delete zoom_context->ceventcontext; zoom_context->ceventcontext = zoom_context->czoomcontext; + types.insert(typeid(SPZoomContext)); zoom_context->grabbed = 0; @@ -77,12 +86,6 @@ static void sp_zoom_context_init (SPZoomContext *zoom_context) new (zoom_context) SPZoomContext(); } -static void -sp_zoom_context_finish (SPEventContext *ec) -{ - ec->ceventcontext->finish(); -} - void CZoomContext::finish() { SPEventContext* ec = this->speventcontext; @@ -96,11 +99,6 @@ void CZoomContext::finish() { } } -static void sp_zoom_context_setup(SPEventContext *ec) -{ - ec->ceventcontext->setup(); -} - void CZoomContext::setup() { SPEventContext* ec = this->speventcontext; @@ -118,11 +116,6 @@ void CZoomContext::setup() { CEventContext::setup(); } -static gint sp_zoom_context_item_handler(SPEventContext *event_context, SPItem *item, GdkEvent *event) -{ - return event_context->ceventcontext->item_handler(item, event); -} - gint CZoomContext::item_handler(SPItem* item, GdkEvent* event) { SPEventContext* event_context = this->speventcontext; @@ -136,11 +129,6 @@ gint CZoomContext::item_handler(SPItem* item, GdkEvent* event) { return ret; } -static gint sp_zoom_context_root_handler(SPEventContext *event_context, GdkEvent *event) -{ - return event_context->ceventcontext->root_handler(event); -} - gint CZoomContext::root_handler(GdkEvent* event) { SPEventContext* event_context = this->speventcontext; @@ -186,7 +174,7 @@ gint CZoomContext::root_handler(GdkEvent* event) { } case GDK_MOTION_NOTIFY: - if (event->motion.state & GDK_BUTTON1_MASK && !event_context->space_panning) { + if ((event->motion.state & GDK_BUTTON1_MASK) && !event_context->space_panning) { ret = TRUE; if ( within_tolerance -- cgit v1.2.3