~valavanisalex/ubuntu/precise/inkscape/fix-943984

« back to all changes in this revision

Viewing changes to inkscape-0.47pre1/src/event-context.h

  • Committer: Bazaar Package Importer
  • Author(s): Bryce Harrington
  • Date: 2009-07-02 17:09:45 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: james.westby@ubuntu.com-20090702170945-nn6d6zswovbwju1t
Tags: 0.47~pre1-0ubuntu1
* New upstream release.
  - Don't constrain maximization on small resolution devices (pre0)
    (LP: #348842)
  - Fixes segfault on startup (pre0)
    (LP: #391149)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef __SP_EVENT_CONTEXT_H__
 
2
#define __SP_EVENT_CONTEXT_H__
 
3
 
 
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
 */
 
19
 
 
20
#include <glib-object.h>
 
21
#include <gdk/gdktypes.h>
 
22
#include <gdk/gdkevents.h>
 
23
#include "knot.h"
 
24
 
 
25
#include "2geom/forward.h"
 
26
#include "preferences.h"
 
27
 
 
28
struct GrDrag;
 
29
struct SPDesktop;
 
30
struct SPItem;
 
31
class ShapeEditor;
 
32
struct SPEventContext;
 
33
 
 
34
namespace Inkscape {
 
35
    class MessageContext;
 
36
    class SelCue;
 
37
    namespace XML {
 
38
        class Node;
 
39
    }
 
40
}
 
41
 
 
42
gboolean sp_event_context_snap_watchdog_callback(gpointer data);
 
43
void sp_event_context_snap_window_open(SPEventContext *ec, bool show_debug_warnings = true);
 
44
void sp_event_context_snap_window_closed(SPEventContext *ec, bool show_debug_warnings = true);
 
45
 
 
46
class DelayedSnapEvent
 
47
{
 
48
public:
 
49
        enum DelayedSnapEventOrigin {
 
50
                UNDEFINED_HANDLER = 0,
 
51
                EVENTCONTEXT_ROOT_HANDLER,
 
52
                EVENTCONTEXT_ITEM_HANDLER,
 
53
                KNOT_HANDLER
 
54
        };
 
55
 
 
56
        DelayedSnapEvent(SPEventContext *event_context, SPItem* const item, SPKnot* knot, GdkEventMotion const *event, DelayedSnapEvent::DelayedSnapEventOrigin const origin)
 
57
        : _timer_id(0), _event(NULL), _item(item), _knot(knot), _origin(origin), _event_context(event_context)
 
58
        {
 
59
                Inkscape::Preferences *prefs = Inkscape::Preferences::get();
 
60
                double value = prefs->getDoubleLimited("/options/snapdelay/value", 0, 0, 1000);
 
61
                _timer_id = g_timeout_add(value, &sp_event_context_snap_watchdog_callback, this);
 
62
                _event = gdk_event_copy((GdkEvent*) event);
 
63
                ((GdkEventMotion *)_event)->time = GDK_CURRENT_TIME;
 
64
        }
 
65
 
 
66
        ~DelayedSnapEvent()     {
 
67
                if (_timer_id > 0) g_source_remove(_timer_id); // Kill the watchdog
 
68
                if (_event != NULL) gdk_event_free(_event); // Remove the copy of the original event
 
69
        }
 
70
 
 
71
        SPEventContext* getEventContext() {return _event_context;}
 
72
        DelayedSnapEventOrigin getOrigin() {return _origin;}
 
73
        GdkEvent* getEvent() {return _event;}
 
74
        SPItem* getItem() {return _item;}
 
75
        SPKnot* getKnot() {return _knot;}
 
76
 
 
77
private:
 
78
        guint _timer_id;
 
79
        GdkEvent* _event;
 
80
        SPItem* _item;
 
81
        SPKnot* _knot;
 
82
        DelayedSnapEventOrigin _origin;
 
83
        SPEventContext* _event_context;
 
84
};
 
85
 
 
86
void sp_event_context_snap_delay_handler(SPEventContext *ec, SPItem* const item, SPKnot* const knot, GdkEventMotion *event, DelayedSnapEvent::DelayedSnapEventOrigin origin);
 
87
 
 
88
/**
 
89
 * Base class for Event processors.
 
90
 */
 
91
struct SPEventContext : public GObject {
 
92
    void enableSelectionCue (bool enable=true);
 
93
    void enableGrDrag (bool enable=true);
 
94
 
 
95
    /// Desktop eventcontext stack
 
96
    SPEventContext *next;
 
97
    unsigned key;
 
98
    SPDesktop *desktop;
 
99
    Inkscape::Preferences::Observer *pref_observer;
 
100
    gchar const *const *cursor_shape;
 
101
    gint hot_x, hot_y; ///< indicates the cursor's hot spot
 
102
    GdkCursor *cursor;
 
103
 
 
104
    gint xp, yp;           ///< where drag started
 
105
    gint tolerance;
 
106
    bool within_tolerance;  ///< are we still within tolerance of origin
 
107
 
 
108
    SPItem *item_to_select; ///< the item where mouse_press occurred, to
 
109
                            ///< be selected if this is a click not drag
 
110
 
 
111
    Inkscape::MessageContext *defaultMessageContext() {
 
112
        return _message_context;
 
113
    }
 
114
 
 
115
    Inkscape::MessageContext *_message_context;
 
116
 
 
117
    Inkscape::SelCue *_selcue;
 
118
 
 
119
    GrDrag *_grdrag;
 
120
    GrDrag *get_drag () {return _grdrag;}
 
121
 
 
122
    ShapeEditor* shape_editor;
 
123
 
 
124
    bool space_panning;
 
125
 
 
126
    bool _snap_window_open;
 
127
    DelayedSnapEvent *_delayed_snap_event;
 
128
};
 
129
 
 
130
/**
 
131
 * The SPEvent vtable.
 
132
 */
 
133
struct SPEventContextClass : public GObjectClass {
 
134
    void (* setup)(SPEventContext *ec);
 
135
    void (* finish)(SPEventContext *ec);
 
136
    void (* set)(SPEventContext *ec, Inkscape::Preferences::Entry *val);
 
137
    void (* activate)(SPEventContext *ec);
 
138
    void (* deactivate)(SPEventContext *ec);
 
139
    gint (* root_handler)(SPEventContext *ec, GdkEvent *event);
 
140
    gint (* item_handler)(SPEventContext *ec, SPItem *item, GdkEvent *event);
 
141
};
 
142
 
 
143
#define SP_EVENT_CONTEXT_DESKTOP(e) (SP_EVENT_CONTEXT(e)->desktop)
 
144
#define SP_EVENT_CONTEXT_DOCUMENT(e) ((SP_EVENT_CONTEXT_DESKTOP(e))->doc())
 
145
 
 
146
#define SP_EVENT_CONTEXT_STATIC 0
 
147
 
 
148
SPEventContext *sp_event_context_new(GType type, SPDesktop *desktop, gchar const *pref_path, unsigned key);
 
149
void sp_event_context_finish(SPEventContext *ec);
 
150
void sp_event_context_read(SPEventContext *ec, gchar const *key);
 
151
void sp_event_context_activate(SPEventContext *ec);
 
152
void sp_event_context_deactivate(SPEventContext *ec);
 
153
 
 
154
gint sp_event_context_root_handler(SPEventContext *ec, GdkEvent *event);
 
155
gint sp_event_context_virtual_root_handler(SPEventContext *ec, GdkEvent *event);
 
156
gint sp_event_context_item_handler(SPEventContext *ec, SPItem *item, GdkEvent *event);
 
157
gint sp_event_context_virtual_item_handler(SPEventContext *ec, SPItem *item, GdkEvent *event);
 
158
 
 
159
void sp_event_root_menu_popup(SPDesktop *desktop, SPItem *item, GdkEvent *event);
 
160
 
 
161
gint gobble_key_events(guint keyval, gint mask);
 
162
gint gobble_motion_events(gint mask);
 
163
 
 
164
void sp_event_context_update_cursor(SPEventContext *ec);
 
165
 
 
166
void sp_event_show_modifier_tip(Inkscape::MessageContext *message_context, GdkEvent *event,
 
167
                                gchar const *ctrl_tip, gchar const *shift_tip, gchar const *alt_tip);
 
168
 
 
169
guint get_group0_keyval(GdkEventKey *event);
 
170
 
 
171
SPItem *sp_event_context_find_item (SPDesktop *desktop, Geom::Point const &p, bool select_under, bool into_groups);
 
172
SPItem *sp_event_context_over_item (SPDesktop *desktop, SPItem *item, Geom::Point const &p);
 
173
 
 
174
ShapeEditor *sp_event_context_get_shape_editor (SPEventContext *ec);
 
175
 
 
176
void ec_shape_event_attr_changed(Inkscape::XML::Node *shape_repr,
 
177
                                     gchar const *name, gchar const *old_value, gchar const *new_value,
 
178
                                 bool const is_interactive, gpointer const data);
 
179
 
 
180
void event_context_print_event_info(GdkEvent *event, bool print_return = true);
 
181
 
 
182
#endif
 
183
 
 
184
 
 
185
/*
 
186
  Local Variables:
 
187
  mode:c++
 
188
  c-file-style:"stroustrup"
 
189
  c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
 
190
  indent-tabs-mode:nil
 
191
  fill-column:99
 
192
  End:
 
193
*/
 
194
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :