Code

First dependency on ziptool
[inkscape.git] / src / knot.h
index 02c0f19addeb4177361b0b5a8454884f47d64664..ceeca0169b28294f82c26c593035907083d55e9e 100644 (file)
@@ -36,8 +36,7 @@ class SPKnotClass;
  * A knot is a draggable object, with callbacks to change something by
  * dragging it, visuably represented by a canvas item (mostly square).
  */
-struct SPKnot {
-    GObject object;
+struct SPKnot : GObject {
     SPDesktop *desktop;   /**< Desktop we are on. */
     SPCanvasItem *item;   /**< Our CanvasItem. */
     guint flags;
@@ -61,12 +60,61 @@ struct SPKnot {
     gpointer pixbuf;
 
     gchar *tip;
+
+    gulong _event_handler_id;
+
+    //TODO: all the members above should eventualle become private, accessible via setters/getters
+    inline void setSize (guint i) {size = i;}
+    inline void setShape (guint i) {shape = (SPKnotShapeType) i;}
+    inline void setAnchor (guint i) {anchor = (GtkAnchorType) i;}
+    inline void setMode (guint i) {mode = (SPKnotModeType) i;}
+    inline void setPixbuf (gpointer p) {pixbuf = p;}
+    inline void setFill (guint32 normal, guint32 mouseover, guint32 dragging) {
+        fill[SP_KNOT_STATE_NORMAL] = normal;
+        fill[SP_KNOT_STATE_MOUSEOVER] = mouseover;
+        fill[SP_KNOT_STATE_DRAGGING] = dragging;
+    }
+    inline void setStroke (guint32 normal, guint32 mouseover, guint32 dragging) {
+        stroke[SP_KNOT_STATE_NORMAL] = normal;
+        stroke[SP_KNOT_STATE_MOUSEOVER] = mouseover;
+        stroke[SP_KNOT_STATE_DRAGGING] = dragging;
+    }
+    inline void setImage (guchar* normal, guchar* mouseover, guchar* dragging) {
+        image[SP_KNOT_STATE_NORMAL] = normal;
+        image[SP_KNOT_STATE_MOUSEOVER] = mouseover;
+        image[SP_KNOT_STATE_DRAGGING] = dragging;
+    }
+    inline void setCursor (GdkCursor* normal, GdkCursor* mouseover, GdkCursor* dragging) {
+        if (cursor[SP_KNOT_STATE_NORMAL]) {
+            gdk_cursor_unref(cursor[SP_KNOT_STATE_NORMAL]);
+        }
+        cursor[SP_KNOT_STATE_NORMAL] = normal;
+        if (normal) {
+            gdk_cursor_ref(normal);
+        }
+
+        if (cursor[SP_KNOT_STATE_MOUSEOVER]) {
+            gdk_cursor_unref(cursor[SP_KNOT_STATE_MOUSEOVER]);
+        }
+        cursor[SP_KNOT_STATE_MOUSEOVER] = mouseover;
+        if (mouseover) {
+            gdk_cursor_ref(mouseover);
+        }
+
+        if (cursor[SP_KNOT_STATE_DRAGGING]) {
+            gdk_cursor_unref(cursor[SP_KNOT_STATE_DRAGGING]);
+        }
+        cursor[SP_KNOT_STATE_DRAGGING] = dragging;
+        if (dragging) {
+            gdk_cursor_ref(dragging);
+        }
+    }
+
 };
 
 /// The SPKnot vtable.
 struct SPKnotClass {
     GObjectClass parent_class;
-
     gint (* event) (SPKnot *knot, GdkEvent *event);
 
     /*
@@ -99,6 +147,8 @@ SPKnot *sp_knot_new(SPDesktop *desktop, gchar const *tip = NULL);
 void sp_knot_show(SPKnot *knot);
 void sp_knot_hide(SPKnot *knot);
 
+void sp_knot_update_ctrl(SPKnot *knot);
+
 void sp_knot_request_position(SPKnot *knot, NR::Point *pos, guint state);
 gdouble sp_knot_distance(SPKnot *knot, NR::Point *p, guint state);