fbffc40656332b635292fcf6bda52d91e9070b9f
1 #ifndef __SP_EVENT_CONTEXT_H__
2 #define __SP_EVENT_CONTEXT_H__
4 /** \file
5 * SPEventContext: base class for event processors
6 *
7 * This is per desktop object, which (its derivatives) implements
8 * different actions bound to mouse events.
9 *
10 * Authors:
11 * Lauris Kaplinski <lauris@kaplinski.com>
12 * Frank Felfe <innerspace@iname.com>
13 *
14 * Copyright (C) 1999-2002 authors
15 * Copyright (C) 2001-2002 Ximian, Inc.
16 *
17 * Released under GNU GPL, read the file 'COPYING' for more information
18 */
20 #include <glib-object.h>
21 #include <gdk/gdktypes.h>
22 #include <gdk/gdkevents.h>
24 #include <2geom/forward.h>
26 struct GrDrag;
27 struct SPDesktop;
28 struct SPItem;
29 class KnotHolder;
30 class ShapeEditor;
32 namespace Inkscape {
33 class MessageContext;
34 class SelCue;
35 namespace XML {
36 class Node;
37 }
38 }
40 /**
41 * Base class for Event processors.
42 */
43 struct SPEventContext : public GObject {
44 void enableSelectionCue (bool enable=true);
45 void enableGrDrag (bool enable=true);
47 /// Desktop eventcontext stack
48 SPEventContext *next;
49 unsigned key;
50 SPDesktop *desktop;
51 Inkscape::XML::Node *prefs_repr;
52 gchar const *const *cursor_shape;
53 gint hot_x, hot_y; ///< indicates the cursor's hot spot
54 GdkCursor *cursor;
56 gint xp, yp; ///< where drag started
57 gint tolerance;
58 bool within_tolerance; ///< are we still within tolerance of origin
60 SPItem *item_to_select; ///< the item where mouse_press occurred, to
61 ///< be selected if this is a click not drag
63 Inkscape::MessageContext *defaultMessageContext() {
64 return _message_context;
65 }
67 Inkscape::MessageContext *_message_context;
69 Inkscape::SelCue *_selcue;
71 GrDrag *_grdrag;
72 GrDrag *get_drag () {return _grdrag;}
74 KnotHolder *shape_knot_holder;
75 Inkscape::XML::Node *shape_repr;
77 bool space_panning;
78 };
80 /**
81 * The SPEvent vtable.
82 */
83 struct SPEventContextClass : public GObjectClass {
84 void (* setup)(SPEventContext *ec);
85 void (* finish)(SPEventContext *ec);
86 void (* set)(SPEventContext *ec, gchar const *key, gchar const *val);
87 void (* activate)(SPEventContext *ec);
88 void (* deactivate)(SPEventContext *ec);
89 gint (* root_handler)(SPEventContext *ec, GdkEvent *event);
90 gint (* item_handler)(SPEventContext *ec, SPItem *item, GdkEvent *event);
91 };
93 #define SP_EVENT_CONTEXT_DESKTOP(e) (SP_EVENT_CONTEXT(e)->desktop)
94 #define SP_EVENT_CONTEXT_DOCUMENT(e) ((SP_EVENT_CONTEXT_DESKTOP(e))->doc())
96 #define SP_EVENT_CONTEXT_STATIC 0
98 SPEventContext *sp_event_context_new(GType type, SPDesktop *desktop, Inkscape::XML::Node *prefs_repr, unsigned key);
99 void sp_event_context_finish(SPEventContext *ec);
100 void sp_event_context_read(SPEventContext *ec, gchar const *key);
101 void sp_event_context_activate(SPEventContext *ec);
102 void sp_event_context_deactivate(SPEventContext *ec);
104 gint sp_event_context_root_handler(SPEventContext *ec, GdkEvent *event);
105 gint sp_event_context_item_handler(SPEventContext *ec, SPItem *item, GdkEvent *event);
107 void sp_event_root_menu_popup(SPDesktop *desktop, SPItem *item, GdkEvent *event);
109 gint gobble_key_events(guint keyval, gint mask);
110 gint gobble_motion_events(gint mask);
112 void sp_event_context_update_cursor(SPEventContext *ec);
114 void sp_event_show_modifier_tip(Inkscape::MessageContext *message_context, GdkEvent *event,
115 gchar const *ctrl_tip, gchar const *shift_tip, gchar const *alt_tip);
117 guint get_group0_keyval(GdkEventKey *event);
119 SPItem *sp_event_context_find_item (SPDesktop *desktop, Geom::Point const &p, bool select_under, bool into_groups);
120 SPItem *sp_event_context_over_item (SPDesktop *desktop, SPItem *item, Geom::Point const &p);
122 ShapeEditor *sp_event_context_get_shape_editor (SPEventContext *ec);
124 void ec_shape_event_attr_changed(Inkscape::XML::Node *shape_repr,
125 gchar const *name, gchar const *old_value, gchar const *new_value,
126 bool const is_interactive, gpointer const data);
128 void event_context_print_event_info(GdkEvent *event, bool print_return = true);
130 #endif
133 /*
134 Local Variables:
135 mode:c++
136 c-file-style:"stroustrup"
137 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
138 indent-tabs-mode:nil
139 fill-column:99
140 End:
141 */
142 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :