]> Pileus Git - ~andy/gtk/blob - gdk/gdkprivate.h
use gdk_cursor_unref instead of destroy
[~andy/gtk] / gdk / gdkprivate.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 Library 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  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library 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-1999.  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 #ifndef __GDK_PRIVATE_H__
28 #define __GDK_PRIVATE_H__
29
30 #include <gdk/gdktypes.h>
31 #include <gdk/gdkevents.h>
32 #include <gdk/gdkfont.h>
33 #include <gdk/gdkgc.h>
34 #include <gdk/gdkim.h>
35 #include <gdk/gdkimage.h>
36 #include <gdk/gdkregion.h>
37 #include <gdk/gdkvisual.h>
38 #include <gdk/gdkwindow.h>
39
40 #ifdef __cplusplus
41 extern "C" {
42 #endif /* __cplusplus */
43
44 #define GDK_DRAWABLE_TYPE(d) (((GdkDrawablePrivate *)d)->window_type)
45 #define GDK_IS_WINDOW(d) (GDK_DRAWABLE_TYPE(d) <= GDK_WINDOW_TEMP || \
46                           GDK_DRAWABLE_TYPE(d) == GDK_WINDOW_FOREIGN)
47 #define GDK_IS_PIXMAP(d) (GDK_DRAWABLE_TYPE(d) == GDK_DRAWABLE_PIXMAP)
48 #define GDK_DRAWABLE_DESTROYED(d) (((GdkDrawablePrivate *)d)->destroyed)
49
50 #define gdk_window_lookup(xid)     ((GdkWindow*) gdk_xid_table_lookup (xid))
51 #define gdk_pixmap_lookup(xid)     ((GdkPixmap*) gdk_xid_table_lookup (xid))
52 #define gdk_font_lookup(xid)       ((GdkFont*) gdk_xid_table_lookup (xid))
53
54 typedef struct _GdkDrawablePrivate     GdkDrawablePrivate;
55 /* typedef struct _GdkDrawablePrivate     GdkPixmapPrivate; */
56 typedef struct _GdkWindowPrivate       GdkWindowPrivate;
57 typedef struct _GdkImageClass          GdkImageClass;
58 typedef struct _GdkImagePrivate        GdkImagePrivate;
59 typedef struct _GdkGCPrivate           GdkGCPrivate;
60 typedef struct _GdkColormapPrivate     GdkColormapPrivate;
61 typedef struct _GdkColorInfo           GdkColorInfo;
62 typedef struct _GdkFontPrivate         GdkFontPrivate;
63 typedef struct _GdkEventFilter         GdkEventFilter;
64 typedef struct _GdkClientFilter        GdkClientFilter;
65
66 struct _GdkDrawablePrivate
67 {
68   GdkDrawable drawable;
69   GdkDrawableClass *klass;
70   gpointer klass_data;
71
72   guint8 window_type;
73   guint ref_count;
74
75   guint16 width;
76   guint16 height;
77
78   GdkColormap *colormap;
79
80   guint destroyed : 2;
81 };
82
83 struct _GdkWindowPrivate
84 {
85   GdkDrawablePrivate drawable;
86   
87   GdkWindow *parent;
88   gint16 x;
89   gint16 y;
90   guint8 resize_count;
91   guint mapped : 1;
92   guint guffaw_gravity : 1;
93
94   gint extension_events;
95
96   GList *filters;
97   GList *children;
98 };
99
100 struct _GdkImageClass 
101 {
102   void (*destroy)   (GdkImage    *image);
103   void (*image_put) (GdkImage    *image,
104                      GdkDrawable *window,
105                      GdkGC       *gc,
106                      gint         xsrc,
107                      gint         ysrc,
108                      gint         xdest,
109                      gint         ydest,
110                      gint         width,
111                      gint         height);
112 };
113
114 struct _GdkImagePrivate
115 {
116   GdkImage image;
117
118   guint ref_count;
119   GdkImageClass *klass;
120 };
121
122 struct _GdkFontPrivate
123 {
124   GdkFont font;
125   guint ref_count;
126 };
127
128 struct _GdkGCPrivate
129 {
130   guint ref_count;
131   GdkGCClass *klass;
132   gpointer klass_data;
133 };
134
135 typedef enum {
136   GDK_COLOR_WRITEABLE = 1 << 0
137 } GdkColorInfoFlags;
138
139 struct _GdkColorInfo
140 {
141   GdkColorInfoFlags flags;
142   guint ref_count;
143 };
144
145 struct _GdkColormapPrivate
146 {
147   GdkColormap colormap;
148   GdkVisual *visual;
149
150   guint ref_count;
151 };
152
153 struct _GdkEventFilter {
154   GdkFilterFunc function;
155   gpointer data;
156 };
157
158 struct _GdkClientFilter {
159   GdkAtom       type;
160   GdkFilterFunc function;
161   gpointer      data;
162 };
163
164 typedef enum 
165 {
166   GDK_ARG_STRING,
167   GDK_ARG_INT,
168   GDK_ARG_BOOL,
169   GDK_ARG_NOBOOL,
170   GDK_ARG_CALLBACK
171 } GdkArgType;
172
173
174 typedef struct _GdkArgContext GdkArgContext;
175 typedef struct _GdkArgDesc GdkArgDesc;
176
177 typedef void (*GdkArgFunc) (const char *name, const char *arg, gpointer data);
178
179 struct _GdkArgContext
180 {
181   GPtrArray *tables;
182   gpointer cb_data;
183 };
184
185 struct _GdkArgDesc
186 {
187   const char *name;
188   GdkArgType type;
189   gpointer location;
190   GdkArgFunc callback;
191 };
192
193
194 typedef enum {
195   GDK_DEBUG_MISC          = 1 << 0,
196   GDK_DEBUG_EVENTS        = 1 << 1,
197   GDK_DEBUG_DND           = 1 << 2,
198   GDK_DEBUG_COLOR_CONTEXT = 1 << 3,
199   GDK_DEBUG_XIM           = 1 << 4
200 } GdkDebugFlag;
201
202 void gdk_event_button_generate (GdkEvent *event);
203
204 /* FIFO's for event queue, and for events put back using
205  * gdk_event_put().
206  */
207 extern GList *gdk_queued_events;
208 extern GList *gdk_queued_tail;
209
210 extern GdkEventFunc   gdk_event_func;    /* Callback for events */
211 extern gpointer       gdk_event_data;
212 extern GDestroyNotify gdk_event_notify;
213
214 GdkEvent* gdk_event_new (void);
215
216 void      gdk_events_init   (void);
217 void      gdk_events_queue  (void);
218 GdkEvent* gdk_event_unqueue (void);
219
220 GList* gdk_event_queue_find_first  (void);
221 void   gdk_event_queue_remove_link (GList    *node);
222 void   gdk_event_queue_append      (GdkEvent *event);
223
224 void gdk_window_init (void);
225 void gdk_visual_init (void);
226 void gdk_dnd_init    (void);
227
228 void gdk_image_init  (void);
229 void gdk_image_exit  (void);
230
231 void gdk_input_init  (void);
232 void gdk_input_exit  (void);
233
234 void gdk_windowing_exit (void);
235
236 void gdk_window_add_colormap_windows (GdkWindow *window);
237 void gdk_window_destroy_notify       (GdkWindow *window);
238
239 /* If you pass x = y = -1, it queries the pointer
240    to find out where it currently is.
241    If you pass x = y = -2, it does anything necessary
242    to know that the drag is ending.
243 */
244 void gdk_dnd_display_drag_cursor(gint x,
245                                  gint y,
246                                  gboolean drag_ok,
247                                  gboolean change_made);
248
249 extern gint              gdk_debug_level;
250 extern gboolean          gdk_show_events;
251 extern gint              gdk_screen;
252 GDKVAR GdkWindow        *gdk_parent_root;
253 GDKVAR gint              gdk_error_code;
254 GDKVAR gint              gdk_error_warnings;
255 extern GList            *gdk_default_filters;
256
257 GdkWindow* _gdk_window_alloc (void);
258
259 /* Font/string functions implemented in module-specific code */
260 gint _gdk_font_strlen (GdkFont *font, const char *str);
261 void _gdk_font_destroy (GdkFont *font);
262
263 void _gdk_colormap_real_destroy (GdkColormap *colormap);
264
265 void _gdk_cursor_destroy (GdkCursor *cursor);
266
267 /* Initialization */
268
269 extern GdkArgDesc _gdk_windowing_args[];
270 gboolean _gdk_windowing_init_check (int argc, char **argv);
271
272 #ifdef USE_XIM
273 /* XIM support */
274 gint   gdk_im_open               (void);
275 void   gdk_im_close              (void);
276 void   gdk_ic_cleanup            (void);
277 #endif /* USE_XIM */
278
279 /* Debugging support */
280
281 #ifdef G_ENABLE_DEBUG
282
283 #define GDK_NOTE(type,action)                G_STMT_START { \
284     if (gdk_debug_flags & GDK_DEBUG_##type)                 \
285        { action; };                          } G_STMT_END
286
287 #else /* !G_ENABLE_DEBUG */
288
289 #define GDK_NOTE(type,action)
290       
291 #endif /* G_ENABLE_DEBUG */
292
293 GDKVAR guint gdk_debug_flags;
294
295
296 #ifdef __cplusplus
297 }
298 #endif /* __cplusplus */
299
300
301 #endif /* __GDK_PRIVATE_H__ */