~ubuntu-branches/ubuntu/precise/inkscape/precise-updates

« back to all changes in this revision

Viewing changes to src/ui/tool/event-utils.h

  • Committer: Bazaar Package Importer
  • Author(s): Alex Valavanis
  • Date: 2010-09-12 19:44:58 UTC
  • mfrom: (1.1.12 upstream) (45.1.3 maverick)
  • Revision ID: james.westby@ubuntu.com-20100912194458-4sjwmbl7dlsrk5dc
Tags: 0.48.0-1ubuntu1
* Merge with Debian unstable (LP: #628048, LP: #401567, LP: #456248, 
  LP: #463602, LP: #591986)
* debian/control: 
  - Ubuntu maintainers
  - Promote python-lxml, python-numpy, python-uniconvertor to Recommends.
  - Demote pstoedit to Suggests (universe package).
  - Suggests ttf-dejavu instead of ttf-bitstream-vera (LP: #513319)
* debian/rules:
  - Run intltool-update on build (Ubuntu-specific).
  - Add translation domain to .desktop files (Ubuntu-specific).
* debian/dirs:
  - Add usr/share/pixmaps.  Allow inkscape.xpm installation
* drop 50-poppler-API.dpatch (now upstream)
* drop 51-paste-in-unwritable-directory.dpatch (now upstream) 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/** @file
 
2
 * Collection of shorthands to deal with GDK events.
 
3
 */
 
4
/* Authors:
 
5
 *   Krzysztof Kosiński <tweenk.pl@gmail.com>
 
6
 *
 
7
 * Copyright (C) 2009 Authors
 
8
 * Released under GNU GPL, read the file 'COPYING' for more information
 
9
 */
 
10
 
 
11
#ifndef SEEN_UI_TOOL_EVENT_UTILS_H
 
12
#define SEEN_UI_TOOL_EVENT_UTILS_H
 
13
 
 
14
#include <gdk/gdk.h>
 
15
#include <2geom/point.h>
 
16
 
 
17
struct SPCanvas;
 
18
 
 
19
namespace Inkscape {
 
20
namespace UI {
 
21
 
 
22
inline bool state_held_shift(unsigned state) {
 
23
    return state & GDK_SHIFT_MASK;
 
24
}
 
25
inline bool state_held_control(unsigned state) {
 
26
    return state & GDK_CONTROL_MASK;
 
27
}
 
28
inline bool state_held_alt(unsigned state) {
 
29
    return state & GDK_MOD1_MASK;
 
30
}
 
31
inline bool state_held_only_shift(unsigned state) {
 
32
    return (state & GDK_SHIFT_MASK) && !(state & (GDK_CONTROL_MASK | GDK_MOD1_MASK));
 
33
}
 
34
inline bool state_held_only_control(unsigned state) {
 
35
    return (state & GDK_CONTROL_MASK) && !(state & (GDK_SHIFT_MASK | GDK_MOD1_MASK));
 
36
}
 
37
inline bool state_held_only_alt(unsigned state) {
 
38
    return (state & GDK_MOD1_MASK) && !(state & (GDK_SHIFT_MASK | GDK_CONTROL_MASK));
 
39
}
 
40
inline bool state_held_any_modifiers(unsigned state) {
 
41
    return state & (GDK_SHIFT_MASK | GDK_CONTROL_MASK | GDK_MOD1_MASK);
 
42
}
 
43
inline bool state_held_no_modifiers(unsigned state) {
 
44
    return !state_held_any_modifiers(state);
 
45
}
 
46
template <unsigned button>
 
47
inline bool state_held_button(unsigned state) {
 
48
    return (button == 0 || button > 5) ? false : state & (GDK_BUTTON1_MASK << (button-1));
 
49
}
 
50
 
 
51
 
 
52
/** Checks whether Shift was held when the event was generated. */
 
53
template <typename E>
 
54
inline bool held_shift(E const &event) {
 
55
    return state_held_shift(event.state);
 
56
}
 
57
 
 
58
/** Checks whether Control was held when the event was generated. */
 
59
template <typename E>
 
60
inline bool held_control(E const &event) {
 
61
    return state_held_control(event.state);
 
62
}
 
63
 
 
64
/** Checks whether Alt was held when the event was generated. */
 
65
template <typename E>
 
66
inline bool held_alt(E const &event) {
 
67
    return state_held_alt(event.state);
 
68
}
 
69
 
 
70
/** True if from the set of Ctrl, Shift and Alt only Ctrl was held when the event
 
71
 * was generated. */
 
72
template <typename E>
 
73
inline bool held_only_control(E const &event) {
 
74
    return state_held_only_control(event.state);
 
75
}
 
76
 
 
77
/** True if from the set of Ctrl, Shift and Alt only Shift was held when the event
 
78
 * was generated. */
 
79
template <typename E>
 
80
inline bool held_only_shift(E const &event) {
 
81
    return state_held_only_shift(event.state);
 
82
}
 
83
 
 
84
/** True if from the set of Ctrl, Shift and Alt only Alt was held when the event
 
85
 * was generated. */
 
86
template <typename E>
 
87
inline bool held_only_alt(E const &event) {
 
88
    return state_held_only_alt(event.state);
 
89
}
 
90
 
 
91
template <typename E>
 
92
inline bool held_no_modifiers(E const &event) {
 
93
    return state_held_no_modifiers(event.state);
 
94
}
 
95
 
 
96
template <typename E>
 
97
inline bool held_any_modifiers(E const &event) {
 
98
    return state_held_any_modifiers(event.state);
 
99
}
 
100
 
 
101
template <typename E>
 
102
inline Geom::Point event_point(E const &event) {
 
103
    return Geom::Point(event.x, event.y);
 
104
}
 
105
 
 
106
/** Use like this:
 
107
 * @code if (held_button<2>(event->motion)) { ... @endcode */
 
108
template <unsigned button, typename E>
 
109
inline bool held_button(E const &event) {
 
110
    return state_held_button<button>(event.state);
 
111
}
 
112
 
 
113
guint shortcut_key(GdkEventKey const &event);
 
114
unsigned combine_key_events(guint keyval, gint mask);
 
115
unsigned combine_motion_events(SPCanvas *canvas, GdkEventMotion &event, gint mask);
 
116
unsigned state_after_event(GdkEvent *event);
 
117
 
 
118
} // namespace UI
 
119
} // namespace Inkscape
 
120
 
 
121
#endif
 
122
 
 
123
/*
 
124
  Local Variables:
 
125
  mode:c++
 
126
  c-file-style:"stroustrup"
 
127
  c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
 
128
  indent-tabs-mode:nil
 
129
  fill-column:99
 
130
  End:
 
131
*/
 
132
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :