zoom-context.cpp revision 1137482ecab2928952d08127515e9d0fc31a29d4
/*
* Handy zooming tool
*
* Authors:
* Lauris Kaplinski <lauris@kaplinski.com>
* Frank Felfe <innerspace@iname.com>
* bulia byak <buliabyak@users.sf.net>
*
* Copyright (C) 1999-2002 Authors
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#include <gdk/gdkkeysyms.h>
#include "macros.h"
#include "rubberband.h"
#include "display/sp-canvas-item.h"
#include "display/sp-canvas-util.h"
#include "desktop.h"
#include "pixmaps/cursor-zoom.xpm"
#include "pixmaps/cursor-zoom-out.xpm"
#include "preferences.h"
#include "selection-chemistry.h"
#include "zoom-context.h"
static bool within_tolerance = false;
static bool escaped;
#include "tool-factory.h"
namespace {
return new SPZoomContext();
}
bool zoomContextRegistered = ToolFactory::instance().registerObject("/tools/zoom", createZoomContext);
}
return SPZoomContext::prefsPath;
}
SPZoomContext* zoom_context = this;
zoom_context->grabbed = 0;
}
SPZoomContext::~SPZoomContext() {
}
void SPZoomContext::finish() {
SPEventContext* ec = this;
ec->enableGrDrag(false);
}
}
void SPZoomContext::setup() {
SPEventContext* ec = this;
ec->enableSelectionCue();
}
ec->enableGrDrag();
}
// if ((SP_EVENT_CONTEXT_CLASS(sp_zoom_context_parent_class))->setup) {
// (SP_EVENT_CONTEXT_CLASS(sp_zoom_context_parent_class))->setup(ec);
// }
SPEventContext::setup();
}
SPEventContext* event_context = this;
// if ((SP_EVENT_CONTEXT_CLASS(sp_zoom_context_parent_class))->item_handler) {
// ret = (SP_EVENT_CONTEXT_CLASS(sp_zoom_context_parent_class))->item_handler (event_context, item, event);
// }
return ret;
}
SPEventContext* event_context = this;
case GDK_BUTTON_PRESS:
{
// save drag origin
within_tolerance = true;
escaped = false;
? zoom_inc
: 1 / zoom_inc );
}
GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK,
break;
}
case GDK_MOTION_NOTIFY:
if ( within_tolerance
break; // do not drag if we're within tolerance from origin
}
// Once the user has moved farther than tolerance from the original location
// (indicating they intend to move the object, not click), then always process the
// motion notify coordinates as given (no snapping back to origin)
within_tolerance = false;
}
break;
case GDK_BUTTON_RELEASE:
{
if (b && !within_tolerance) {
} else if (!escaped) {
? 1 / zoom_inc
: zoom_inc );
}
}
}
escaped = false;
break;
}
case GDK_KEY_PRESS:
case GDK_KEY_Escape:
}
escaped = true;
break;
case GDK_KEY_Up:
case GDK_KEY_Down:
case GDK_KEY_KP_Up:
case GDK_KEY_KP_Down:
// prevent the zoom field from activation
if (!MOD__CTRL_ONLY)
break;
case GDK_KEY_Shift_L:
case GDK_KEY_Shift_R:
break;
case GDK_KEY_Delete:
case GDK_KEY_KP_Delete:
case GDK_KEY_BackSpace:
break;
default:
break;
}
break;
case GDK_KEY_RELEASE:
case GDK_KEY_Shift_L:
case GDK_KEY_Shift_R:
break;
default:
break;
}
break;
default:
break;
}
if (!ret) {
// if ((SP_EVENT_CONTEXT_CLASS(sp_zoom_context_parent_class))->root_handler) {
// ret = (SP_EVENT_CONTEXT_CLASS(sp_zoom_context_parent_class))->root_handler(event_context, event);
// }
}
return ret;
}
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :