]> Pileus Git - ~andy/gtk/blob - gdk/gdkinternals.h
Add a draw-border style property to allow themes to draw outside the
[~andy/gtk] / gdk / gdkinternals.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 /* Uninstalled header defining types and functions internal to GDK */
28
29 #include <gdk/gdktypes.h>
30 #include <gdk/gdkwindow.h>
31 #include <gdk/gdkprivate.h>
32
33 #ifndef __GDK_INTERNALS_H__
34 #define __GDK_INTERNALS_H__
35
36 /**********************
37  * General Facilities * 
38  **********************/
39
40 /* Debugging support */
41
42 typedef struct _GdkColorInfo           GdkColorInfo;
43 typedef struct _GdkEventFilter         GdkEventFilter;
44 typedef struct _GdkClientFilter        GdkClientFilter;
45
46 typedef enum {
47   GDK_COLOR_WRITEABLE = 1 << 0
48 } GdkColorInfoFlags;
49
50 struct _GdkColorInfo
51 {
52   GdkColorInfoFlags flags;
53   guint ref_count;
54 };
55
56 struct _GdkEventFilter {
57   GdkFilterFunc function;
58   gpointer data;
59 };
60
61 struct _GdkClientFilter {
62   GdkAtom       type;
63   GdkFilterFunc function;
64   gpointer      data;
65 };
66
67 typedef enum {
68   GDK_DEBUG_MISC          = 1 << 0,
69   GDK_DEBUG_EVENTS        = 1 << 1,
70   GDK_DEBUG_DND           = 1 << 2,
71   GDK_DEBUG_XIM           = 1 << 3,
72   GDK_DEBUG_NOGRABS       = 1 << 4,
73   GDK_DEBUG_COLORMAP      = 1 << 5,
74   GDK_DEBUG_GDKRGB        = 1 << 6,
75   GDK_DEBUG_GC            = 1 << 7,
76   GDK_DEBUG_PIXMAP        = 1 << 8,
77   GDK_DEBUG_IMAGE         = 1 << 9,
78   GDK_DEBUG_INPUT         = 1 <<10,
79   GDK_DEBUG_CURSOR        = 1 <<11,
80   GDK_DEBUG_MULTIHEAD     = 1 <<12,
81   GDK_DEBUG_XINERAMA      = 1 <<13
82 } GdkDebugFlag;
83
84 #ifndef GDK_DISABLE_DEPRECATED
85
86 typedef struct _GdkFontPrivate         GdkFontPrivate;
87
88 struct _GdkFontPrivate
89 {
90   GdkFont font;
91   guint ref_count;
92 };
93
94 #endif /* GDK_DISABLE_DEPRECATED */
95
96 extern GList            *_gdk_default_filters;
97 extern GdkWindow        *_gdk_parent_root;
98 extern gint              _gdk_error_code;
99 extern gint              _gdk_error_warnings;
100
101 extern guint _gdk_debug_flags;
102
103 #ifdef G_ENABLE_DEBUG
104
105 #define GDK_NOTE(type,action)                G_STMT_START { \
106     if (_gdk_debug_flags & GDK_DEBUG_##type)                \
107        { action; };                          } G_STMT_END
108
109 #else /* !G_ENABLE_DEBUG */
110
111 #define GDK_NOTE(type,action)
112
113 #endif /* G_ENABLE_DEBUG */
114
115 /* Arg parsing */
116
117 typedef enum 
118 {
119   GDK_ARG_STRING,
120   GDK_ARG_INT,
121   GDK_ARG_BOOL,
122   GDK_ARG_NOBOOL,
123   GDK_ARG_CALLBACK
124 } GdkArgType;
125
126 typedef struct _GdkArgContext GdkArgContext;
127 typedef struct _GdkArgDesc GdkArgDesc;
128
129 typedef void (*GdkArgFunc) (const char *name, const char *arg, gpointer data);
130
131 struct _GdkArgContext
132 {
133   GPtrArray *tables;
134   gpointer cb_data;
135 };
136
137 struct _GdkArgDesc
138 {
139   const char *name;
140   GdkArgType type;
141   gpointer location;
142   GdkArgFunc callback;
143 };
144
145 /* Event handling */
146
147 typedef struct _GdkEventPrivate GdkEventPrivate;
148
149 typedef enum
150 {
151   /* Following flag is set for events on the event queue during
152    * translation and cleared afterwards.
153    */
154   GDK_EVENT_PENDING = 1 << 0
155 } GdkEventFlags;
156
157 struct _GdkEventPrivate
158 {
159   GdkEvent   event;
160   guint      flags;
161   GdkScreen *screen;
162 };
163
164 extern GdkEventFunc   _gdk_event_func;    /* Callback for events */
165 extern gpointer       _gdk_event_data;
166 extern GDestroyNotify _gdk_event_notify;
167
168 extern GSList    *_gdk_displays;
169 extern gchar     *_gdk_display_name;
170 extern gint       _gdk_screen_number;
171 extern gchar     *_gdk_display_arg_name;
172
173 void      _gdk_events_queue  (GdkDisplay *display);
174 GdkEvent* _gdk_event_unqueue (GdkDisplay *display);
175
176 GList* _gdk_event_queue_find_first  (GdkDisplay *display);
177 void   _gdk_event_queue_remove_link (GdkDisplay *display,
178                                      GList      *node);
179 GList*  _gdk_event_queue_append     (GdkDisplay *display,
180                                      GdkEvent   *event);
181 void _gdk_event_button_generate     (GdkDisplay *display,
182                                      GdkEvent   *event);
183
184 void gdk_synthesize_window_state (GdkWindow     *window,
185                                   GdkWindowState unset_flags,
186                                   GdkWindowState set_flags);
187
188 #define GDK_SCRATCH_IMAGE_WIDTH 256
189 #define GDK_SCRATCH_IMAGE_HEIGHT 64
190
191 GdkImage* _gdk_image_new_for_depth (GdkScreen    *screen,
192                                     GdkImageType  type,
193                                     GdkVisual    *visual,
194                                     gint          width,
195                                     gint          height,
196                                     gint          depth);
197 GdkImage *_gdk_image_get_scratch (GdkScreen *screen,
198                                   gint       width,
199                                   gint       height,
200                                   gint       depth,
201                                   gint      *x,
202                                   gint      *y);
203
204 GdkImage *_gdk_drawable_copy_to_image (GdkDrawable  *drawable,
205                                        GdkImage     *image,
206                                        gint          src_x,
207                                        gint          src_y,
208                                        gint          dest_x,
209                                        gint          dest_y,
210                                        gint          width,
211                                        gint          height);
212
213 cairo_surface_t *_gdk_drawable_ref_cairo_surface (GdkDrawable *drawable);
214
215 /* GC caching */
216 GdkGC *_gdk_drawable_get_scratch_gc (GdkDrawable *drawable,
217                                      gboolean     graphics_exposures);
218
219 void _gdk_gc_update_context (GdkGC     *gc,
220                              cairo_t   *cr,
221                              GdkColor  *override_foreground,
222                              GdkBitmap *override_stipple);
223
224 /*************************************
225  * Interfaces used by windowing code *
226  *************************************/
227
228 void       _gdk_window_destroy           (GdkWindow   *window,
229                                           gboolean     foreign_destroy);
230 void       _gdk_window_clear_update_area (GdkWindow   *window);
231
232 void       _gdk_screen_close             (GdkScreen   *screen);
233
234 const char *_gdk_get_sm_client_id (void);
235
236 void _gdk_gc_init (GdkGC           *gc,
237                    GdkDrawable     *drawable,
238                    GdkGCValues     *values,
239                    GdkGCValuesMask  values_mask);
240
241 GdkRegion *_gdk_gc_get_clip_region (GdkGC *gc);
242 GdkFill    _gdk_gc_get_fill        (GdkGC *gc);
243 GdkPixmap *_gdk_gc_get_tile        (GdkGC *gc);
244 GdkBitmap *_gdk_gc_get_stipple     (GdkGC *gc);
245 guint32    _gdk_gc_get_fg_pixel    (GdkGC *gc);
246 guint32    _gdk_gc_get_bg_pixel    (GdkGC *gc);
247
248 /*****************************************
249  * Interfaces provided by windowing code *
250  *****************************************/
251
252 /* Font/string functions implemented in module-specific code */
253 gint _gdk_font_strlen (GdkFont *font, const char *str);
254 void _gdk_font_destroy (GdkFont *font);
255
256 void _gdk_colormap_real_destroy (GdkColormap *colormap);
257
258 void _gdk_cursor_destroy (GdkCursor *cursor);
259
260 void     _gdk_windowing_init                    (void);
261
262 extern GOptionEntry _gdk_windowing_args[];
263 void     _gdk_windowing_set_default_display     (GdkDisplay *display);
264
265 gchar *_gdk_windowing_substitute_screen_number (const gchar *display_name,
266                                                 gint         screen_number);
267
268 void     _gdk_windowing_window_get_offsets      (GdkWindow  *window,
269                                                  gint       *x_offset,
270                                                  gint       *y_offset);
271 void     _gdk_windowing_window_clear_area       (GdkWindow  *window,
272                                                  gint        x,
273                                                  gint        y,
274                                                  gint        width,
275                                                  gint        height);
276 void     _gdk_windowing_window_clear_area_e     (GdkWindow  *window,
277                                                  gint        x,
278                                                  gint        y,
279                                                  gint        width,
280                                                  gint        height);
281
282 void       _gdk_windowing_get_pointer        (GdkDisplay       *display,
283                                               GdkScreen       **screen,
284                                               gint             *x,
285                                               gint             *y,
286                                               GdkModifierType  *mask);
287 GdkWindow* _gdk_windowing_window_get_pointer (GdkDisplay       *display,
288                                               GdkWindow        *window,
289                                               gint             *x,
290                                               gint             *y,
291                                               GdkModifierType  *mask);
292 GdkWindow* _gdk_windowing_window_at_pointer  (GdkDisplay       *display,
293                                               gint             *win_x,
294                                               gint             *win_y);
295
296 /* Return the number of bits-per-pixel for images of the specified depth. */
297 gint _gdk_windowing_get_bits_for_depth (GdkDisplay *display,
298                                         gint        depth);
299
300 #define GDK_WINDOW_IS_MAPPED(window) ((((GdkWindowObject*)window)->state & GDK_WINDOW_STATE_WITHDRAWN) == 0)
301
302 /* Called before processing updates for a window. This gives the windowing
303  * layer a chance to save the region for later use in avoiding duplicate
304  * exposes. The return value indicates whether the function has a saved
305  * the region; if the result is TRUE, then the windowing layer is responsible
306  * for destroying the region later.
307  */
308 gboolean _gdk_windowing_window_queue_antiexpose (GdkWindow  *window,
309                                                  GdkRegion  *area);
310
311 /* Called to do the windowing system specific part of gdk_window_destroy(),
312  *
313  * window: The window being destroyed
314  * recursing: If TRUE, then this is being called because a parent
315  *            was destroyed. This generally means that the call to the windowing system
316  *            to destroy the window can be omitted, since it will be destroyed as a result
317  *            of the parent being destroyed. Unless @foreign_destroy
318  *            
319  * foreign_destroy: If TRUE, the window or a parent was destroyed by some external 
320  *            agency. The window has already been destroyed and no windowing
321  *            system calls should be made. (This may never happen for some
322  *            windowing systems.)
323  */
324 void _gdk_windowing_window_destroy (GdkWindow *window,
325                                     gboolean   recursing,
326                                     gboolean   foreign_destroy);
327
328 /* Called when gdk_window_destroy() is called on a foreign window
329  * or an ancestor of the foreign window. It should generally reparent
330  * the window out of it's current heirarchy, hide it, and then
331  * send a message to the owner requesting that the window be destroyed.
332  */
333 void _gdk_windowing_window_destroy_foreign (GdkWindow *window);
334
335 void _gdk_windowing_display_set_sm_client_id (GdkDisplay  *display,
336                                               const gchar *sm_client_id);
337
338 /* Implementation types */
339 GType _gdk_window_impl_get_type (void) G_GNUC_CONST;
340 GType _gdk_pixmap_impl_get_type (void) G_GNUC_CONST;
341
342
343 /**
344  * _gdk_windowing_gc_set_clip_region:
345  * @gc: a #GdkGC
346  * @region: the new clip region
347  * 
348  * Do any window-system specific processing necessary
349  * for a change in clip region. Since the clip origin
350  * will likely change before the GC is used with the
351  * new clip, frequently this function will only set a flag and
352  * do the real processing later.
353  *
354  * When this function is called, _gdk_gc_get_clip_region
355  * will already return the new region.
356  **/
357 void _gdk_windowing_gc_set_clip_region (GdkGC     *gc,
358                                         GdkRegion *region);
359
360 /**
361  * _gdk_windowing_gc_copy:
362  * @dst_gc: a #GdkGC from the GDK backend
363  * @src_gc: a #GdkGC from the GDK backend
364  * 
365  * Copies backend specific state from @src_gc to @dst_gc.
366  * This is called before the generic state is copied, so
367  * the old generic state is still available from @dst_gc
368  **/
369 void _gdk_windowing_gc_copy (GdkGC *dst_gc,
370                              GdkGC *src_gc);
371      
372 /* Queries the current foreground color of a GdkGC */
373 void _gdk_windowing_gc_get_foreground (GdkGC    *gc,
374                                        GdkColor *color);
375 /* Queries the current background color of a GdkGC */
376 void _gdk_windowing_gc_get_background (GdkGC    *gc,
377                                        GdkColor *color);
378
379 /************************************
380  * Initialization and exit routines *
381  ************************************/
382
383 void _gdk_image_exit  (void);
384 void _gdk_windowing_exit (void);
385
386 #ifdef __cplusplus
387 }
388 #endif /* __cplusplus */
389
390 #endif /* __GDK_INTERNALS_H__ */