]> Pileus Git - ~andy/gtk/blob - gdk/gdkdevice.h
Consistently hide class structs
[~andy/gtk] / gdk / gdkdevice.h
1 /* GDK - The GIMP Drawing Kit
2  * Copyright (C) 2009 Carlos Garnacho <carlosg@gnome.org>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20 #if !defined (__GDK_H_INSIDE__) && !defined (GDK_COMPILATION)
21 #error "Only <gdk/gdk.h> can be included directly."
22 #endif
23
24 #ifndef __GDK_DEVICE_H__
25 #define __GDK_DEVICE_H__
26
27 #include <gdk/gdktypes.h>
28
29
30 G_BEGIN_DECLS
31
32 #define GDK_TYPE_DEVICE         (gdk_device_get_type ())
33 #define GDK_DEVICE(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), GDK_TYPE_DEVICE, GdkDevice))
34 #define GDK_IS_DEVICE(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), GDK_TYPE_DEVICE))
35
36 typedef struct _GdkTimeCoord GdkTimeCoord;
37
38 /**
39  * GdkExtensionMode:
40  * @GDK_EXTENSION_EVENTS_NONE: no extension events are desired.
41  * @GDK_EXTENSION_EVENTS_ALL: all extension events are desired.
42  * @GDK_EXTENSION_EVENTS_CURSOR: extension events are desired only if a cursor
43  *                               will be displayed for the device.
44  *
45  * An enumeration used to specify which extension events
46  * are desired for a particular widget.
47  */
48 typedef enum
49 {
50   GDK_EXTENSION_EVENTS_NONE,
51   GDK_EXTENSION_EVENTS_ALL,
52   GDK_EXTENSION_EVENTS_CURSOR
53 } GdkExtensionMode;
54
55 /**
56  * GdkInputSource:
57  * @GDK_SOURCE_MOUSE: the device is a mouse. (This will be reported for the core
58  *                    pointer, even if it is something else, such as a trackball.)
59  * @GDK_SOURCE_PEN: the device is a stylus of a graphics tablet or similar device.
60  * @GDK_SOURCE_ERASER: the device is an eraser. Typically, this would be the other end
61  *                     of a stylus on a graphics tablet.
62  * @GDK_SOURCE_CURSOR: the device is a graphics tablet "puck" or similar device.
63  * @GDK_SOURCE_KEYBOARD: the device is a keyboard.
64  *
65  * An enumeration describing the type of an input device in general terms.
66  */
67 typedef enum
68 {
69   GDK_SOURCE_MOUSE,
70   GDK_SOURCE_PEN,
71   GDK_SOURCE_ERASER,
72   GDK_SOURCE_CURSOR,
73   GDK_SOURCE_KEYBOARD
74 } GdkInputSource;
75
76 /**
77  * GdkInputMode:
78  * @GDK_MODE_DISABLED: the device is disabled and will not report any events.
79  * @GDK_MODE_SCREEN: the device is enabled. The device's coordinate space
80  *                   maps to the entire screen.
81  * @GDK_MODE_WINDOW: the device is enabled. The device's coordinate space
82  *                   is mapped to a single window. The manner in which this window
83  *                   is chosen is undefined, but it will typically be the same
84  *                   way in which the focus window for key events is determined.
85  *
86  * An enumeration that describes the mode of an input device.
87  */
88 typedef enum
89 {
90   GDK_MODE_DISABLED,
91   GDK_MODE_SCREEN,
92   GDK_MODE_WINDOW
93 } GdkInputMode;
94
95 /**
96  * GdkAxisUse:
97  * @GDK_AXIS_IGNORE: the axis is ignored.
98  * @GDK_AXIS_X: the axis is used as the x axis.
99  * @GDK_AXIS_Y: the axis is used as the y axis.
100  * @GDK_AXIS_PRESSURE: the axis is used for pressure information.
101  * @GDK_AXIS_XTILT: the axis is used for x tilt information.
102  * @GDK_AXIS_YTILT: the axis is used for x tilt information.
103  * @GDK_AXIS_WHEEL: the axis is used for wheel information.
104  * @GDK_AXIS_LAST: a constant equal to the numerically highest axis value.
105  *
106  * An enumeration describing the way in which a device
107  * axis (valuator) maps onto the predefined valuator
108  * types that GTK+ understands.
109  */
110 typedef enum
111 {
112   GDK_AXIS_IGNORE,
113   GDK_AXIS_X,
114   GDK_AXIS_Y,
115   GDK_AXIS_PRESSURE,
116   GDK_AXIS_XTILT,
117   GDK_AXIS_YTILT,
118   GDK_AXIS_WHEEL,
119   GDK_AXIS_LAST
120 } GdkAxisUse;
121
122 /**
123  * GdkDeviceType:
124  * @GDK_DEVICE_TYPE_MASTER: Device is a master (or virtual) device. There will
125  *                          be an associated focus indicator on the screen.
126  * @GDK_DEVICE_TYPE_SLAVE: Device is a slave (or physical) device.
127  * @GDK_DEVICE_TYPE_FLOATING: Device is a physical device, currently not attached to
128  *                            any virtual device.
129  *
130  * Indicates the device type. See <link linkend="GdkDeviceManager.description">above</link>
131  * for more information about the meaning of these device types.
132  */
133 typedef enum {
134   GDK_DEVICE_TYPE_MASTER,
135   GDK_DEVICE_TYPE_SLAVE,
136   GDK_DEVICE_TYPE_FLOATING
137 } GdkDeviceType;
138
139 /* We don't allocate each coordinate this big, but we use it to
140  * be ANSI compliant and avoid accessing past the defined limits.
141  */
142 #define GDK_MAX_TIMECOORD_AXES 128
143
144 /**
145  * GdkTimeCoord:
146  * @time: The timestamp for this event.
147  * @axes: the values of the device's axes.
148  *
149  * The #GdkTimeCoord structure stores a single event in a motion history.
150  */
151 struct _GdkTimeCoord
152 {
153   guint32 time;
154   gdouble axes[GDK_MAX_TIMECOORD_AXES];
155 };
156
157 GType                 gdk_device_get_type       (void) G_GNUC_CONST;
158
159 G_CONST_RETURN gchar *gdk_device_get_name       (GdkDevice *device);
160 gboolean              gdk_device_get_has_cursor (GdkDevice *device);
161
162 /* Functions to configure a device */
163 GdkInputSource gdk_device_get_source    (GdkDevice      *device);
164 void           gdk_device_set_source    (GdkDevice      *device,
165                                          GdkInputSource  source);
166
167 GdkInputMode   gdk_device_get_mode      (GdkDevice      *device);
168 gboolean       gdk_device_set_mode      (GdkDevice      *device,
169                                          GdkInputMode    mode);
170
171 gint           gdk_device_get_n_keys    (GdkDevice       *device);
172 gboolean       gdk_device_get_key       (GdkDevice       *device,
173                                          guint            index_,
174                                          guint           *keyval,
175                                          GdkModifierType *modifiers);
176 void           gdk_device_set_key       (GdkDevice      *device,
177                                          guint           index_,
178                                          guint           keyval,
179                                          GdkModifierType modifiers);
180
181 GdkAxisUse     gdk_device_get_axis_use  (GdkDevice         *device,
182                                          guint              index_);
183 void           gdk_device_set_axis_use  (GdkDevice         *device,
184                                          guint              index_,
185                                          GdkAxisUse         use);
186
187
188 void     gdk_device_get_state    (GdkDevice         *device,
189                                   GdkWindow         *window,
190                                   gdouble           *axes,
191                                   GdkModifierType   *mask);
192 gboolean gdk_device_get_history  (GdkDevice         *device,
193                                   GdkWindow         *window,
194                                   guint32            start,
195                                   guint32            stop,
196                                   GdkTimeCoord    ***events,
197                                   gint              *n_events);
198 void     gdk_device_free_history (GdkTimeCoord     **events,
199                                   gint               n_events);
200
201 gint     gdk_device_get_n_axes     (GdkDevice       *device);
202 GList *  gdk_device_list_axes      (GdkDevice       *device);
203 gboolean gdk_device_get_axis_value (GdkDevice       *device,
204                                     gdouble         *axes,
205                                     GdkAtom          axis_label,
206                                     gdouble         *value);
207
208 gboolean gdk_device_get_axis     (GdkDevice         *device,
209                                   gdouble           *axes,
210                                   GdkAxisUse         use,
211                                   gdouble           *value);
212 GdkDisplay * gdk_device_get_display (GdkDevice      *device);
213
214 GdkDevice  * gdk_device_get_associated_device (GdkDevice     *device);
215 GList *      gdk_device_list_slave_devices    (GdkDevice     *device);
216
217 GdkDeviceType gdk_device_get_device_type (GdkDevice *device);
218
219 GdkGrabStatus gdk_device_grab        (GdkDevice        *device,
220                                       GdkWindow        *window,
221                                       GdkGrabOwnership  grab_ownership,
222                                       gboolean          owner_events,
223                                       GdkEventMask      event_mask,
224                                       GdkCursor        *cursor,
225                                       guint32           time_);
226
227 void          gdk_device_ungrab      (GdkDevice        *device,
228                                       guint32           time_);
229
230 void          gdk_device_warp        (GdkDevice        *device,
231                                       GdkScreen        *screen,
232                                       gint              x,
233                                       gint              y);
234
235 gboolean gdk_device_grab_info_libgtk_only (GdkDisplay  *display,
236                                            GdkDevice   *device,
237                                            GdkWindow  **grab_window,
238                                            gboolean    *owner_events);
239
240
241 G_END_DECLS
242
243 #endif /* __GDK_DEVICE_H__ */