]> Pileus Git - ~andy/gtk/blob - gdk/gdktypes.h
Merge branch 'master' into broadway
[~andy/gtk] / gdk / gdktypes.h
1 /* GDK - The GIMP Drawing Kit
2  * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
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 /*
21  * Modified by the GTK+ Team and others 1997-2000.  See the AUTHORS
22  * file for a list of people on the GTK+ Team.  See the ChangeLog
23  * files for a list of changes.  These files are distributed with
24  * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
25  */
26
27 #if !defined (__GDK_H_INSIDE__) && !defined (GDK_COMPILATION)
28 #error "Only <gdk/gdk.h> can be included directly."
29 #endif
30
31 #ifndef __GDK_TYPES_H__
32 #define __GDK_TYPES_H__
33
34 /* GDK uses "glib". (And so does GTK).
35  */
36 #include <glib.h>
37 #include <pango/pango.h>
38 #include <glib-object.h>
39 #include <cairo.h>
40
41 /* The system specific file gdkconfig.h contains such configuration
42  * settings that are needed not only when compiling GDK (or GTK)
43  * itself, but also occasionally when compiling programs that use GDK
44  * (or GTK). One such setting is what windowing API backend is in use.
45  */
46 #include <gdkconfig.h>
47
48 /* some common magic values */
49
50 /**
51  * GDK_CURRENT_TIME:
52  *
53  * Represents the current time, and can be used anywhere a time is expected.
54  */
55 #define GDK_CURRENT_TIME     0L
56
57 /**
58  * GDK_PARENT_RELATIVE:
59  *
60  * A special value, indicating that the background
61  * for a window should be inherited from the parent window.
62  */
63 #define GDK_PARENT_RELATIVE  1L
64
65
66
67 G_BEGIN_DECLS
68
69
70 /* Type definitions for the basic structures.
71  */
72 typedef struct _GdkPoint              GdkPoint;
73
74 /**
75  * GdkRectangle:
76  *
77  * Defines the position and size of a rectangle. It is identical to
78  * #cairo_rectangle_int_t.
79  */
80 typedef cairo_rectangle_int_t         GdkRectangle;
81
82 /**
83  * GdkAtom:
84  *
85  * An opaque type representing a string as an index into a table
86  * of strings on the X server.
87  */
88 typedef struct _GdkAtom            *GdkAtom;
89
90 /**
91  * GDK_ATOM_TO_POINTER:
92  * @atom: a #GdkAtom.
93  *
94  * Converts a #GdkAtom into a pointer type.
95  */
96 #define GDK_ATOM_TO_POINTER(atom) (atom)
97
98 /**
99  * GDK_POINTER_TO_ATOM:
100  * @ptr: a pointer containing a #GdkAtom.
101  *
102  * Extracts a #GdkAtom from a pointer. The #GdkAtom must have been
103  * stored in the pointer with GDK_ATOM_TO_POINTER().
104  */
105 #define GDK_POINTER_TO_ATOM(ptr)  ((GdkAtom)(ptr))
106
107 #ifdef GDK_NATIVE_WINDOW_POINTER
108 #define GDK_GPOINTER_TO_NATIVE_WINDOW(p) ((GdkNativeWindow) (p))
109 #else
110 #define GDK_GPOINTER_TO_NATIVE_WINDOW(p) GPOINTER_TO_UINT(p)
111 #endif
112
113 #define _GDK_MAKE_ATOM(val) ((GdkAtom)GUINT_TO_POINTER(val))
114
115 /**
116  * GDK_NONE:
117  *
118  * A null value for #GdkAtom, used in a similar way as
119  * <literal>None</literal> in the Xlib API.
120  */
121 #define GDK_NONE            _GDK_MAKE_ATOM (0)
122
123 /**
124  * GdkNativeWindow:
125  *
126  * Used to represent native windows (<type>Window</type>s for the X11
127  * backend, <type>HWND</type>s for Win32).
128  */
129 #ifdef GDK_NATIVE_WINDOW_POINTER
130 typedef gpointer GdkNativeWindow;
131 #else
132 typedef guint32 GdkNativeWindow;
133 #endif
134  
135 /* Forward declarations of commonly used types
136  */
137 typedef struct _GdkColor              GdkColor;
138 typedef struct _GdkRGBA               GdkRGBA;
139 typedef struct _GdkCursor             GdkCursor;
140 typedef struct _GdkVisual             GdkVisual;
141
142 /**
143  * GdkWindow:
144  *
145  * An opaque structure representing an onscreen drawable.
146  */
147 typedef struct _GdkWindow             GdkWindow;
148 typedef struct _GdkDisplay            GdkDisplay;
149 typedef struct _GdkScreen             GdkScreen;
150
151 /**
152  * GdkByteOrder:
153  * @GDK_LSB_FIRST: The values are stored with the least-significant byte
154  *   first. For instance, the 32-bit value 0xffeecc would be stored
155  *   in memory as 0xcc, 0xee, 0xff, 0x00.
156  * @GDK_MSB_FIRST: The values are stored with the most-significant byte
157  *   first. For instance, the 32-bit value 0xffeecc would be stored
158  *   in memory as 0x00, 0xcc, 0xee, 0xff.
159  *
160  * A set of values describing the possible byte-orders
161  * for storing pixel values in memory.
162  */
163 typedef enum
164 {
165   GDK_LSB_FIRST,
166   GDK_MSB_FIRST
167 } GdkByteOrder;
168
169 /* Types of modifiers.
170  */
171 /**
172  * GdkModifierType:
173  * @GDK_SHIFT_MASK: the Shift key.
174  * @GDK_LOCK_MASK: a Lock key (depending on the modifier mapping of the
175  *  X server this may either be CapsLock or ShiftLock).
176  * @GDK_CONTROL_MASK: the Control key.
177  * @GDK_MOD1_MASK: the fourth modifier key (it depends on the modifier
178  *  mapping of the X server which key is interpreted as this modifier, but
179  *  normally it is the Alt key).
180  * @GDK_MOD2_MASK: the fifth modifier key (it depends on the modifier
181  *  mapping of the X server which key is interpreted as this modifier).
182  * @GDK_MOD3_MASK: the sixth modifier key (it depends on the modifier
183  *  mapping of the X server which key is interpreted as this modifier).
184  * @GDK_MOD4_MASK: the seventh modifier key (it depends on the modifier
185  *  mapping of the X server which key is interpreted as this modifier).
186  * @GDK_MOD5_MASK: the eighth modifier key (it depends on the modifier
187  *  mapping of the X server which key is interpreted as this modifier).
188  * @GDK_BUTTON1_MASK: the first mouse button.
189  * @GDK_BUTTON2_MASK: the second mouse button.
190  * @GDK_BUTTON3_MASK: the third mouse button.
191  * @GDK_BUTTON4_MASK: the fourth mouse button.
192  * @GDK_BUTTON5_MASK: the fifth mouse button.
193  * @GDK_SUPER_MASK: the Super modifier. Since 2.10
194  * @GDK_HYPER_MASK: the Hyper modifier. Since 2.10
195  * @GDK_META_MASK: the Meta modifier. Since 2.10
196  * @GDK_RELEASE_MASK: not used in GDK itself. GTK+ uses it to differentiate
197  *  between (keyval, modifiers) pairs from key press and release events.
198  * @GDK_MODIFIER_MASK: a mask covering all modifier types.
199  *
200  * A set of bit-flags to indicate the state of modifier keys and mouse buttons
201  * in various event types. Typical modifier keys are Shift, Control, Meta,
202  * Super, Hyper, Alt, Compose, Apple, CapsLock or ShiftLock.
203  *
204  * Like the X Window System, GDK supports 8 modifier keys and 5 mouse buttons.
205  *
206  * Since 2.10, GDK recognizes which of the Meta, Super or Hyper keys are mapped
207  * to Mod2 - Mod5, and indicates this by setting %GDK_SUPER_MASK,
208  * %GDK_HYPER_MASK or %GDK_META_MASK in the state field of key events.
209  */
210 typedef enum
211 {
212   GDK_SHIFT_MASK    = 1 << 0,
213   GDK_LOCK_MASK     = 1 << 1,
214   GDK_CONTROL_MASK  = 1 << 2,
215   GDK_MOD1_MASK     = 1 << 3,
216   GDK_MOD2_MASK     = 1 << 4,
217   GDK_MOD3_MASK     = 1 << 5,
218   GDK_MOD4_MASK     = 1 << 6,
219   GDK_MOD5_MASK     = 1 << 7,
220   GDK_BUTTON1_MASK  = 1 << 8,
221   GDK_BUTTON2_MASK  = 1 << 9,
222   GDK_BUTTON3_MASK  = 1 << 10,
223   GDK_BUTTON4_MASK  = 1 << 11,
224   GDK_BUTTON5_MASK  = 1 << 12,
225
226   /* The next few modifiers are used by XKB, so we skip to the end.
227    * Bits 15 - 25 are currently unused. Bit 29 is used internally.
228    */
229   
230   GDK_SUPER_MASK    = 1 << 26,
231   GDK_HYPER_MASK    = 1 << 27,
232   GDK_META_MASK     = 1 << 28,
233   
234   GDK_RELEASE_MASK  = 1 << 30,
235
236   GDK_MODIFIER_MASK = 0x5c001fff
237 } GdkModifierType;
238
239 typedef enum
240 {
241   GDK_OK          = 0,
242   GDK_ERROR       = -1,
243   GDK_ERROR_PARAM = -2,
244   GDK_ERROR_FILE  = -3,
245   GDK_ERROR_MEM   = -4
246 } GdkStatus;
247
248 /**
249  * GdkGrabStatus:
250  * @GDK_GRAB_SUCCESS: the resource was successfully grabbed.
251  * @GDK_GRAB_ALREADY_GRABBED: the resource is actively grabbed by another client.
252  * @GDK_GRAB_INVALID_TIME: the resource was grabbed more recently than the
253  *  specified time.
254  * @GDK_GRAB_NOT_VIEWABLE: the grab window or the @confine_to window are not
255  *  viewable.
256  * @GDK_GRAB_FROZEN: the resource is frozen by an active grab of another client.
257  *
258  * Returned by gdk_pointer_grab() and gdk_keyboard_grab() to indicate
259  * success or the reason for the failure of the grab attempt.
260  */
261 typedef enum
262 {
263   GDK_GRAB_SUCCESS         = 0,
264   GDK_GRAB_ALREADY_GRABBED = 1,
265   GDK_GRAB_INVALID_TIME    = 2,
266   GDK_GRAB_NOT_VIEWABLE    = 3,
267   GDK_GRAB_FROZEN          = 4
268 } GdkGrabStatus;
269
270 /**
271  * GdkGrabOwnership:
272  * @GDK_OWNERSHIP_NONE: All other devices' events are allowed.
273  * @GDK_OWNERSHIP_WINDOW: Other devices' events are blocked for the grab window.
274  * @GDK_OWNERSHIP_APPLICATION: Other devices' events are blocked for the whole application.
275  *
276  * Defines how device grabs interact with other devices.
277  */
278 typedef enum
279 {
280   GDK_OWNERSHIP_NONE,
281   GDK_OWNERSHIP_WINDOW,
282   GDK_OWNERSHIP_APPLICATION
283 } GdkGrabOwnership;
284
285 /**
286  * GdkEventMask:
287  * @GDK_EXPOSURE_MASK: receive expose events
288  * @GDK_POINTER_MOTION_MASK: receive all pointer motion events
289  * @GDK_POINTER_MOTION_HINT_MASK: see the explanation above
290  * @GDK_BUTTON_MOTION_MASK: receive pointer motion events while any button is pressed
291  * @GDK_BUTTON1_MOTION_MASK: receive pointer motion events while 1 button is pressed
292  * @GDK_BUTTON2_MOTION_MASK: receive pointer motion events while 2 button is pressed
293  * @GDK_BUTTON3_MOTION_MASK: receive pointer motion events while 3 button is pressed
294  * @GDK_BUTTON_PRESS_MASK: receive button press events
295  * @GDK_BUTTON_RELEASE_MASK: receive button release events
296  * @GDK_KEY_PRESS_MASK: receive key press events
297  * @GDK_KEY_RELEASE_MASK: receive key release events
298  * @GDK_ENTER_NOTIFY_MASK: receive window enter events
299  * @GDK_LEAVE_NOTIFY_MASK: receive window leave events
300  * @GDK_FOCUS_CHANGE_MASK: receive focus change events
301  * @GDK_STRUCTURE_MASK: receive events about window configuration change
302  * @GDK_PROPERTY_CHANGE_MASK: receive property change events
303  * @GDK_VISIBILITY_NOTIFY_MASK: receive visibility change events
304  * @GDK_PROXIMITY_IN_MASK: receive proximity in events
305  * @GDK_PROXIMITY_OUT_MASK: receive proximity out events
306  * @GDK_SUBSTRUCTURE_MASK: receive events about window configuration changes of
307  *   child windows
308  * @GDK_SCROLL_MASK: receive scroll events
309  * @GDK_ALL_EVENTS_MASK: the combination of all the above event masks.
310  *
311  * A set of bit-flags to indicate which events a window is to receive.
312  * Most of these masks map onto one or more of the #GdkEventType event types
313  * above.
314  *
315  * %GDK_POINTER_MOTION_HINT_MASK is a special mask which is used to reduce the
316  * number of %GDK_MOTION_NOTIFY events received. Normally a %GDK_MOTION_NOTIFY
317  * event is received each time the mouse moves. However, if the application
318  * spends a lot of time processing the event (updating the display, for example),
319  * it can lag behind the position of the mouse. When using
320  * %GDK_POINTER_MOTION_HINT_MASK, fewer %GDK_MOTION_NOTIFY events will be sent,
321  * some of which are marked as a hint (the is_hint member is %TRUE).
322  * To receive more motion events after a motion hint event, the application
323  * needs to asks for more, by calling gdk_event_request_motions().
324  */
325 typedef enum
326 {
327   GDK_EXPOSURE_MASK             = 1 << 1,
328   GDK_POINTER_MOTION_MASK       = 1 << 2,
329   GDK_POINTER_MOTION_HINT_MASK  = 1 << 3,
330   GDK_BUTTON_MOTION_MASK        = 1 << 4,
331   GDK_BUTTON1_MOTION_MASK       = 1 << 5,
332   GDK_BUTTON2_MOTION_MASK       = 1 << 6,
333   GDK_BUTTON3_MOTION_MASK       = 1 << 7,
334   GDK_BUTTON_PRESS_MASK         = 1 << 8,
335   GDK_BUTTON_RELEASE_MASK       = 1 << 9,
336   GDK_KEY_PRESS_MASK            = 1 << 10,
337   GDK_KEY_RELEASE_MASK          = 1 << 11,
338   GDK_ENTER_NOTIFY_MASK         = 1 << 12,
339   GDK_LEAVE_NOTIFY_MASK         = 1 << 13,
340   GDK_FOCUS_CHANGE_MASK         = 1 << 14,
341   GDK_STRUCTURE_MASK            = 1 << 15,
342   GDK_PROPERTY_CHANGE_MASK      = 1 << 16,
343   GDK_VISIBILITY_NOTIFY_MASK    = 1 << 17,
344   GDK_PROXIMITY_IN_MASK         = 1 << 18,
345   GDK_PROXIMITY_OUT_MASK        = 1 << 19,
346   GDK_SUBSTRUCTURE_MASK         = 1 << 20,
347   GDK_SCROLL_MASK               = 1 << 21,
348   GDK_ALL_EVENTS_MASK           = 0x3FFFFE
349 } GdkEventMask;
350
351 /**
352  * GdkPoint:
353  * @x: the x coordinate of the point.
354  * @y: the y coordinate of the point.
355  *
356  * Defines the x and y coordinates of a point.
357  */
358 struct _GdkPoint
359 {
360   gint x;
361   gint y;
362 };
363
364
365 G_END_DECLS
366
367
368 #endif /* __GDK_TYPES_H__ */