knot.cpp revision 142443659db257ea5a031ce428d53e80452b0098
#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 "prefs-utils.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 {
};
enum {
};
static void sp_knot_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
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.
*/
{
/* Huh :) */
0,
0xffffffff,
0xff000000,
0,
0xffffffff,
0xff000000,
0,
0xffffffff,
0xff000000,
0,
0xffffffff,
0xff000000,
0,
0xffffffff,
0x01000000,
0,
0xffffffff,
0x01000000,
0,
0xffffffff,
0x01000000,
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.
*/
{
}
/**
* Called before SPKnot destruction.
*/
{
// This happens e.g. when deleting a node in node tool while dragging it
}
}
for (gint i = 0; i < SP_KNOT_VISIBLE_STATES; i++) {
}
}
}
}
}
/**
* Callback to set property.
*/
static void sp_knot_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
{
switch (prop_id) {
case PROP_SIZE:
break;
case PROP_ANCHOR:
break;
case PROP_SHAPE:
break;
case PROP_MODE:
break;
case PROP_FILL:
break;
case PROP_FILL_MOUSEOVER:
break;
case PROP_FILL_DRAGGING:
break;
case PROP_STROKE:
break;
case PROP_STROKE_MOUSEOVER:
break;
case PROP_STROKE_DRAGGING:
break;
case PROP_IMAGE:
break;
case PROP_IMAGE_MOUSEOVER:
break;
case PROP_IMAGE_DRAGGING:
break;
case PROP_CURSOR:
for (gint i = 0; i < SP_KNOT_VISIBLE_STATES; i++) {
}
if (cursor) {
}
}
break;
case PROP_CURSOR_MOUSEOVER:
}
if (cursor) {
}
break;
case PROP_CURSOR_DRAGGING:
}
if (cursor) {
}
break;
case PROP_PIXBUF:
break;
case PROP_TIP:
break;
default:
break;
}
}
/// Not reached.
{
}
/**
* 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 (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 (grabbed) {
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;
if (!moved) {
knot_signals[GRABBED], 0,
TRUE);
}
}
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;
}
/**
* 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. We can't be sure this artificial
* move has moved the knot from under cursor, but it seems likely, so we clear SP_KNOT_MOUSEOVER.
*/
{
}
}
/**
* 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 :