70
75
double pressure; /**< The tablet pen pressure when the knot is being dragged. */
74
sigc::signal<void, Geom::Point const &, Geom::Point const &, guint> _moved_signal;
75
sigc::signal<void, guint> _click_signal;
76
sigc::signal<Geom::Point> _ungrabbed_signal;
77
sigc::signal<void, SPKnot *, guint> _click_signal;
78
sigc::signal<void, SPKnot*, guint> _doubleclicked_signal;
79
sigc::signal<void, SPKnot*, guint> _grabbed_signal;
80
sigc::signal<void, SPKnot *, guint> _ungrabbed_signal;
78
81
sigc::signal<void, SPKnot *, Geom::Point const &, guint> _moved_signal;
79
sigc::signal<void, SPKnot *, guint> _click_signal;
80
sigc::signal<void, SPKnot *> _ungrabbed_signal;
82
sigc::signal<bool, SPKnot*, GdkEvent*> _event_signal;
84
sigc::signal<bool, SPKnot*, Geom::Point*, guint> _request_signal;
82
87
//TODO: all the members above should eventualle become private, accessible via setters/getters
83
inline void setSize (guint i) {size = i;}
84
inline void setShape (guint i) {shape = (SPKnotShapeType) i;}
85
inline void setAnchor (guint i) {anchor = (SPAnchorType) i;}
86
inline void setMode (guint i) {mode = (SPKnotModeType) i;}
87
inline void setPixbuf (gpointer p) {pixbuf = p;}
88
inline void setFill (guint32 normal, guint32 mouseover, guint32 dragging) {
89
fill[SP_KNOT_STATE_NORMAL] = normal;
90
fill[SP_KNOT_STATE_MOUSEOVER] = mouseover;
91
fill[SP_KNOT_STATE_DRAGGING] = dragging;
93
inline void setStroke (guint32 normal, guint32 mouseover, guint32 dragging) {
94
stroke[SP_KNOT_STATE_NORMAL] = normal;
95
stroke[SP_KNOT_STATE_MOUSEOVER] = mouseover;
96
stroke[SP_KNOT_STATE_DRAGGING] = dragging;
98
inline void setImage (guchar* normal, guchar* mouseover, guchar* dragging) {
99
image[SP_KNOT_STATE_NORMAL] = normal;
100
image[SP_KNOT_STATE_MOUSEOVER] = mouseover;
101
image[SP_KNOT_STATE_DRAGGING] = dragging;
103
inline void setCursor (GdkCursor* normal, GdkCursor* mouseover, GdkCursor* dragging) {
104
if (cursor[SP_KNOT_STATE_NORMAL]) {
105
#if GTK_CHECK_VERSION(3,0,0)
106
g_object_unref(cursor[SP_KNOT_STATE_NORMAL]);
108
gdk_cursor_unref(cursor[SP_KNOT_STATE_NORMAL]);
111
cursor[SP_KNOT_STATE_NORMAL] = normal;
113
#if GTK_CHECK_VERSION(3,0,0)
114
g_object_ref(normal);
116
gdk_cursor_ref(normal);
120
if (cursor[SP_KNOT_STATE_MOUSEOVER]) {
121
#if GTK_CHECK_VERSION(3,0,0)
122
g_object_unref(cursor[SP_KNOT_STATE_MOUSEOVER]);
124
gdk_cursor_unref(cursor[SP_KNOT_STATE_MOUSEOVER]);
127
cursor[SP_KNOT_STATE_MOUSEOVER] = mouseover;
129
#if GTK_CHECK_VERSION(3,0,0)
130
g_object_ref(mouseover);
132
gdk_cursor_ref(mouseover);
136
if (cursor[SP_KNOT_STATE_DRAGGING]) {
137
#if GTK_CHECK_VERSION(3,0,0)
138
g_object_unref(cursor[SP_KNOT_STATE_DRAGGING]);
140
gdk_cursor_unref(cursor[SP_KNOT_STATE_DRAGGING]);
143
cursor[SP_KNOT_STATE_DRAGGING] = dragging;
145
#if GTK_CHECK_VERSION(3,0,0)
146
g_object_ref(dragging);
148
gdk_cursor_ref(dragging);
155
/// The SPKnot vtable.
157
GObjectClass parent_class;
158
gint (* event) (SPKnot *knot, GdkEvent *event);
161
* These are unconditional.
164
void (* clicked) (SPKnot *knot, guint state);
165
void (* doubleclicked) (SPKnot *knot, guint state);
166
void (* grabbed) (SPKnot *knot, guint state);
167
void (* ungrabbed) (SPKnot *knot, guint state);
168
void (* moved) (SPKnot *knot, Geom::Point const &position, guint state);
169
void (* stamped) (SPKnot *know, guint state);
171
/** Request knot to move to absolute position. */
172
bool (* request) (SPKnot *knot, Geom::Point const &pos, guint state);
174
/** Find complex distance from knot to point. */
175
gdouble (* distance) (SPKnot *knot, Geom::Point const &pos, guint state);
179
* Registers SPKnot class and returns its type number.
181
GType sp_knot_get_type();
184
* Return new knot object.
186
SPKnot *sp_knot_new(SPDesktop *desktop, gchar const *tip = NULL);
88
void setSize(guint i);
89
void setShape(guint i);
90
void setAnchor(guint i);
91
void setMode(guint i);
92
void setPixbuf(gpointer p);
94
void setFill(guint32 normal, guint32 mouseover, guint32 dragging);
95
void setStroke(guint32 normal, guint32 mouseover, guint32 dragging);
96
void setImage(guchar* normal, guchar* mouseover, guchar* dragging);
98
void setCursor(GdkCursor* normal, GdkCursor* mouseover, GdkCursor* dragging);
101
* Show knot on its canvas.
106
* Hide knot on its canvas.
111
* Set flag in knot, with side effects.
113
void set_flag(guint flag, bool set);
116
* Update knot's pixbuf and set its control state.
121
* Request or set new position for knot.
123
void request_position(Geom::Point const &pos, guint state);
126
* Update knot for dragging and tell canvas an item was grabbed.
128
void start_dragging(Geom::Point const &p, gint x, gint y, guint32 etime);
131
* Move knot to new position and emits "moved" signal.
133
void set_position(Geom::Point const &p, guint state);
136
* Move knot to new position, without emitting a MOVED signal.
138
void moveto(Geom::Point const &p);
141
* Returns position of knot.
143
Geom::Point position() const;
146
SPKnot(const SPKnot&);
147
SPKnot& operator=(const SPKnot&);
150
* Set knot control state (dragging/mouseover/normal).
152
void set_ctrl_state();
155
void knot_ref(SPKnot* knot);
156
void knot_unref(SPKnot* knot);
188
158
#define SP_KNOT_IS_VISIBLE(k) ((k->flags & SP_KNOT_VISIBLE) != 0)
189
159
#define SP_KNOT_IS_MOUSEOVER(k) ((k->flags & SP_KNOT_MOUSEOVER) != 0)
190
160
#define SP_KNOT_IS_DRAGGING(k) ((k->flags & SP_KNOT_DRAGGING) != 0)
191
161
#define SP_KNOT_IS_GRABBED(k) ((k->flags & SP_KNOT_GRABBED) != 0)
194
* Show knot on its canvas.
196
void sp_knot_show(SPKnot *knot);
199
* Hide knot on its canvas.
201
void sp_knot_hide(SPKnot *knot);
204
* Set flag in knot, with side effects.
206
void sp_knot_set_flag(SPKnot *knot, guint flag, bool set);
209
* Update knot's pixbuf and set its control state.
211
void sp_knot_update_ctrl(SPKnot *knot);
214
* Request or set new position for knot.
216
void sp_knot_request_position(SPKnot *knot, Geom::Point const &pos, guint state);
219
* Return distance of point to knot's position; unused.
221
gdouble sp_knot_distance(SPKnot *knot, Geom::Point const &p, guint state);
224
* Update knot for dragging and tell canvas an item was grabbed.
226
void sp_knot_start_dragging(SPKnot *knot, Geom::Point const &p, gint x, gint y, guint32 etime);
229
* Move knot to new position and emits "moved" signal.
231
void sp_knot_set_position(SPKnot *knot, Geom::Point const &p, guint state);
234
* Move knot to new position, without emitting a MOVED signal.
236
void sp_knot_moveto(SPKnot *knot, Geom::Point const &p);
238
163
void sp_knot_handler_request_position(GdkEvent *event, SPKnot *knot);
241
* Returns position of knot.
243
Geom::Point sp_knot_position(SPKnot const *knot);
246
165
#endif // SEEN_SP_KNOT_H