knot.cpp revision ed02d9080768df7e31df52038fb9cccee6bf3286
#define __SP_KNOT_C__
/** \file
* SPKnot implementation
*
* Authors:
* Lauris Kaplinski <lauris@kaplinski.com>
* bulia byak <buliabyak@users.sf.net>
*
* Copyright (C) 1999-2005 authors
* Copyright (C) 2001-2002 Ximian, Inc.
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <gdk/gdkkeysyms.h>
#include "helper/sp-marshal.h"
#include "display/sodipodi-ctrl.h"
#include "desktop.h"
#include "desktop-handles.h"
#include "knot.h"
#include "document.h"
#include "preferences.h"
#include "message-stack.h"
#include "message-context.h"
#include "event-context.h"
static bool nograb = false;
static bool within_tolerance = false;
static bool transform_escaped = false; // true iff resize or rotate was cancelled by esc.
enum {
};
static GObjectClass *parent_class;
/**
* Registers SPKnot class and returns its type number.
*/
{
if (!type) {
sizeof(SPKnotClass),
NULL, /* base_init */
NULL, /* base_finalize */
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (SPKnot),
16, /* n_preallocs */
};
}
return type;
}
/**
* SPKnot vtable initialization.
*/
{
G_TYPE_BOOLEAN, 1,
G_TYPE_NONE, 1,
G_TYPE_NONE, 1,
G_TYPE_NONE, 1,
G_TYPE_NONE, 1,
G_TYPE_NONE, 2,
G_TYPE_BOOLEAN, 2,
G_TYPE_DOUBLE, 2,
}
/**
* Callback for SPKnot initialization.
*/
{
knot->_event_handler_id = 0;
}
/**
* Called before SPKnot destruction.
*/
{
// This happens e.g. when deleting a node in node tool while dragging it
}
if (knot->_event_handler_id > 0)
{
knot->_event_handler_id = 0;
}
}
for (gint i = 0; i < SP_KNOT_VISIBLE_STATES; i++) {
}
}
}
if (parent_class->dispose) {
}
}
/**
* Update knot for dragging and tell canvas an item was grabbed.
*/
{
// save drag origin
xp = x;
yp = y;
within_tolerance = true;
if (!nograb) {
etime);
}
}
/**
* Called to handle events on knots.
*/
{
/* Run client universal event handler, if present */
if (consumed) {
return TRUE;
}
case GDK_2BUTTON_PRESS:
}
break;
case GDK_BUTTON_PRESS:
sp_knot_start_dragging(knot, p, (gint) event->button.x, (gint) event->button.y, event->button.time);
}
break;
case GDK_BUTTON_RELEASE:
// If we have any pending snap event, then invoke it now
}
if (transform_escaped) {
transform_escaped = false;
} else {
if (!nograb) {
}
if (moved) {
FALSE);
knot_signals[UNGRABBED], 0,
} else {
knot_signals[CLICKED], 0,
}
}
}
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;
else
if (!moved) {
knot_signals[GRABBED], 0,
TRUE);
}
sp_event_context_snap_delay_handler(knot->desktop->event_context, NULL, (gpointer) knot, (GdkEventMotion *)event, DelayedSnapEvent::KNOT_HANDLER);
}
break;
case GDK_ENTER_NOTIFY:
}
break;
case GDK_LEAVE_NOTIFY:
}
break;
case GDK_KEY_PRESS: // keybindings for knot
case GDK_Escape:
if (!nograb) {
}
if (moved) {
FALSE);
knot_signals[UNGRABBED], 0,
transform_escaped = true;
}
break;
default:
break;
}
break;
default:
break;
}
return consumed;
}
{
knot->desktop->set_coordinate_status(knot->pos); // display the coordinate of knot, not cursor - they may be different!
}
/**
* Return new knot object.
*/
{
if (tip) {
}
"anchor", GTK_ANCHOR_CENTER,
"size", 8.0,
"filled", TRUE,
"fill_color", 0xffffff00,
"stroked", TRUE,
"stroke_color", 0x01000000,
"mode", SP_KNOT_MODE_XOR,
NULL);
return knot;
}
/**
* Show knot on its canvas.
*/
{
}
/**
* Hide knot on its canvas.
*/
{
}
/**
* Request or set new position for knot.
*/
{
knot_signals[REQUEST], 0,
&p,
&done);
/* If user did not complete, we simply move knot to new position */
if (!done) {
}
}
/**
* Return distance of point to knot's position; unused.
*/
{
knot_signals[DISTANCE], 0,
&p,
&distance);
return distance;
}
/**
* Move knot to new position.
*/
{
}
knot_signals[MOVED], 0,
&p,
state);
}
/**
* Move knot to new position, without emitting a MOVED signal.
*/
{
}
}
/**
* Returns position of knot.
*/
{
}
/**
* Set flag in knot, with side effects.
*/
{
if (set) {
} else {
}
switch (flag) {
case SP_KNOT_VISIBLE:
if (set) {
} else {
}
break;
case SP_KNOT_MOUSEOVER:
case SP_KNOT_DRAGGING:
break;
case SP_KNOT_GRABBED:
break;
default:
break;
}
}
/**
* Update knot's pixbuf and set its control state.
*/
{
return;
}
}
}
/**
*/
{
"fill_color",
NULL);
"stroke_color",
NULL);
"fill_color",
NULL);
"stroke_color",
NULL);
} else {
"fill_color",
NULL);
"stroke_color",
NULL);
}
}
/*
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 :