]> Pileus Git - ~andy/gtk/blob - gdk/win32/gdkprivate-win32.h
Change GDK_WINDOWING_WIN32 usage to #ifdef also here.
[~andy/gtk] / gdk / win32 / gdkprivate-win32.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 #define STRICT                  /* We want strict type checks */
31 #include <windows.h>
32
33 /* Make up for some minor mingw32 lossage */
34
35 /* PS_JOIN_MASK is missing from the mingw32 headers */
36 #ifndef PS_JOIN_MASK
37 #define PS_JOIN_MASK (PS_JOIN_BEVEL|PS_JOIN_MITER|PS_JOIN_ROUND)
38 #endif
39
40 /* CLR_INVALID is missing */
41 #ifndef CLR_INVALID
42 #define CLR_INVALID CLR_NONE
43 #endif
44
45 /* MB_CUR_MAX is missing */
46 #ifndef MB_CUR_MAX
47 extern int *__imp___mb_cur_max;
48 #define MB_CUR_MAX (*__imp___mb_cur_max)
49 #endif
50
51 #include <time.h>
52
53 #include <gdk/gdkcursor.h>
54 #include <gdk/gdkevents.h>
55 #include <gdk/gdkfont.h>
56 #include <gdk/gdkgc.h>
57 #include <gdk/gdkim.h>
58 #include <gdk/gdkimage.h>
59 #include <gdk/gdkregion.h>
60 #include <gdk/gdkvisual.h>
61 #include <gdk/gdkwindow.h>
62
63 #include <gdk/gdktypes.h>
64
65 #define gdk_window_lookup(xid)     ((GdkWindow*) gdk_xid_table_lookup (xid))
66 #define gdk_pixmap_lookup(xid)     ((GdkPixmap*) gdk_xid_table_lookup (xid))
67
68 /* HFONTs clash with HWNDs, so add dithering to HFONTs... (hack) */
69 #define HFONT_DITHER 43
70 #define gdk_font_lookup(xid)       ((GdkFont*) gdk_xid_table_lookup ((HANDLE) ((guint) xid + HFONT_DITHER)))
71
72 #ifdef __cplusplus
73 extern "C" {
74 #endif /* __cplusplus */
75
76 /* Define corresponding Windows types for some X11 types, just for laziness.
77  */
78
79 typedef HANDLE XID;
80 typedef PALETTEENTRY XColor;
81 typedef HDC GC;
82 typedef ATOM Atom;
83 typedef HCURSOR Cursor;
84 typedef guint VisualID;
85 typedef DWORD KeySym;
86 typedef int Status;
87
88 /* Define some of the X11 constants also here, again just for laziness */
89
90 /* Generic null resource */
91 #define None 0
92
93 /* Error codes */
94 #define Success            0
95
96 /* Grabbing status */
97 #define GrabSuccess        0
98 #define AlreadyGrabbed     2
99
100 /* For CreateColormap */
101 #define AllocNone 0
102 #define AllocAll 1
103
104 /* Notify modes */
105 #define NotifyNormal 0
106 #define NotifyHint 1
107
108 /* Some structs are somewhat useful to emulate internally, just to
109    keep the code less #ifdefed.  */
110 typedef struct {
111   HPALETTE palette;             /* Palette handle used when drawing. */
112   guint size;                   /* Number of entries in the palette. */
113   gboolean stale;               /* 1 if palette needs to be realized,
114                                  * otherwise 0. */
115   gboolean *in_use;
116   gboolean rc_palette;          /* If RC_PALETTE is on in the RASTERCAPS */
117   gulong sizepalette;           /* SIZEPALETTE if rc_palette */
118 } ColormapStruct, *Colormap;
119   
120 typedef struct {
121   gint map_entries;
122   guint visualid;
123   guint bitspixel;
124 } Visual;
125
126 typedef struct {
127   Colormap colormap;
128   unsigned long red_max;
129   unsigned long red_mult;
130   unsigned long green_max;
131   unsigned long green_mult;
132   unsigned long blue_max;
133   unsigned long blue_mult;
134   unsigned long base_pixel;
135 } XStandardColormap;
136
137 typedef struct _GdkWindowPrivate       GdkWindowPrivate;
138 typedef struct _GdkWindowPrivate       GdkPixmapPrivate;
139 typedef struct _GdkImagePrivate        GdkImagePrivate;
140 typedef struct _GdkGCPrivate           GdkGCPrivate;
141 typedef struct _GdkColormapPrivate     GdkColormapPrivate;
142 typedef struct _GdkColorInfo           GdkColorInfo;
143 typedef struct _GdkVisualPrivate       GdkVisualPrivate;
144 typedef struct _GdkFontPrivate         GdkFontPrivate;
145 typedef struct _GdkCursorPrivate       GdkCursorPrivate;
146 typedef struct _GdkEventFilter         GdkEventFilter;
147 typedef struct _GdkClientFilter        GdkClientFilter;
148 typedef struct _GdkRegionPrivate       GdkRegionPrivate;
149
150
151 struct _GdkWindowPrivate
152 {
153   GdkWindow window;
154   GdkWindow *parent;
155   HANDLE xwindow;
156   gint16 x;
157   gint16 y;
158   guint16 width;
159   guint16 height;
160   guint8 resize_count;
161   guint8 window_type;
162   guint ref_count;
163   guint destroyed : 2;
164   guint mapped : 1;
165   guint guffaw_gravity : 1;
166
167   /* We must keep the event mask here to filter them ourselves */
168   gint event_mask;
169
170   /* Values for bg_type */
171 #define GDK_WIN32_BG_NORMAL 0
172 #define GDK_WIN32_BG_PIXEL 1
173 #define GDK_WIN32_BG_PIXMAP 2
174 #define GDK_WIN32_BG_PARENT_RELATIVE 3
175 #define GDK_WIN32_BG_TRANSPARENT 4
176
177   /* We draw the background ourselves at WM_ERASEBKGND  */
178   guchar bg_type;
179   GdkColor bg_pixel;
180   GdkPixmap *bg_pixmap;
181
182   HCURSOR xcursor;
183
184   /* Window size hints */
185   gint hint_flags;
186   gint hint_x, hint_y;
187   gint hint_min_width, hint_min_height;
188   gint hint_max_width, hint_max_height;
189
190   gint extension_events;
191   gboolean extension_events_selected;
192
193   GList *filters;
194   GdkColormap *colormap;
195   GList *children;
196 };
197
198 struct _GdkImagePrivate
199 {
200   GdkImage image;
201   HBITMAP ximage;
202   gpointer x_shm_info;
203
204   void (*image_put) (GdkDrawable *window,
205                      GdkGC       *gc,
206                      GdkImage    *image,
207                      gint         xsrc,
208                      gint         ysrc,
209                      gint         xdest,
210                      gint         ydest,
211                      gint         width,
212                      gint         height);
213 };
214
215 struct _GdkGCPrivate
216 {
217   GdkGC gc;
218   GC xgc;
219   /* A Windows Device Context (DC) is not equivalent to an X11
220    * GC. We can use a DC only in the window for which it was
221    * allocated, or (in the case of a memory DC) with the bitmap that
222    * has been selected into it. Thus, we have to release and
223    * reallocate a DC each time the GdkGC is used to paint into a new
224    * window or pixmap. We thus keep all the necessary values in the
225    * GdkGCPrivate struct.
226    */
227   GdkGCValuesMask values_mask;
228   GdkColor foreground;
229   GdkColor background;
230   HFONT font;
231   gint rop2;
232   GdkFill fill_style;
233   GdkPixmap *tile;
234   GdkPixmap *stipple;
235   HRGN clip_region;
236   GdkSubwindowMode subwindow_mode;
237   gint ts_x_origin;
238   gint ts_y_origin;
239   gint clip_x_origin;
240   gint clip_y_origin;
241   gint graphics_exposures;
242   gint pen_width;
243   DWORD pen_style;
244   HANDLE hwnd;                  /* If a DC is allocated, for which window
245                                    or what bitmap is selected into it */
246   int saved_dc;
247   guint ref_count;
248 };
249
250 typedef enum {
251   GDK_COLOR_WRITEABLE = 1 << 0
252 } GdkColorInfoFlags;
253
254 struct _GdkColorInfo
255 {
256   GdkColorInfoFlags flags;
257   guint ref_count;
258 };
259
260 struct _GdkColormapPrivate
261 {
262   GdkColormap colormap;
263   Colormap xcolormap;
264   GdkVisual *visual;
265   gint private_val;
266
267   GHashTable *hash;
268   GdkColorInfo *info;
269   time_t last_sync_time;
270   
271   guint ref_count;
272 };
273
274 struct _GdkVisualPrivate
275 {
276   GdkVisual visual;
277   Visual *xvisual;
278 };
279
280 struct _GdkFontPrivate
281 {
282   GdkFont font;
283   /* XFontStruct *xfont; */
284   /* generic pointer point to XFontStruct or XFontSet */
285   /* in Win32 a HFONT */ 
286   gpointer xfont;
287   guint ref_count;
288 };
289
290 struct _GdkCursorPrivate
291 {
292   GdkCursor cursor;
293   Cursor xcursor;
294 };
295
296 struct _GdkEventFilter {
297   GdkFilterFunc function;
298   gpointer data;
299 };
300
301 struct _GdkClientFilter {
302   GdkAtom       type;
303   GdkFilterFunc function;
304   gpointer      data;
305 };
306
307 #ifdef USE_XIM
308
309 typedef struct _GdkICPrivate GdkICPrivate;
310
311 struct _GdkICPrivate
312 {
313   XIC xic;
314   GdkICAttr *attr;
315   GdkICAttributesType mask;
316 };
317
318 #endif /* USE_XIM */
319
320 struct _GdkRegionPrivate
321 {
322   GdkRegion region;
323   HRGN xregion;
324 };
325
326 typedef enum {
327   GDK_DEBUG_MISC          = 1 << 0,
328   GDK_DEBUG_EVENTS        = 1 << 1,
329   GDK_DEBUG_DND           = 1 << 2,
330   GDK_DEBUG_COLOR_CONTEXT = 1 << 3,
331   GDK_DEBUG_XIM           = 1 << 4,
332   GDK_DEBUG_SELECTION     = 1 << 5
333 } GdkDebugFlag;
334
335 void gdk_events_init (void);
336 void gdk_window_init (void);
337 void gdk_visual_init (void);
338 void gdk_selection_init (void);
339 void gdk_dnd_init    (void);
340 void gdk_dnd_exit    (void);
341 void gdk_image_init  (void);
342 void gdk_image_exit  (void);
343
344 GdkColormap* gdk_colormap_lookup (Colormap  xcolormap);
345 GdkVisual*   gdk_visual_lookup   (Visual   *xvisual);
346
347 void gdk_window_add_colormap_windows (GdkWindow *window);
348 void gdk_window_destroy_notify       (GdkWindow *window);
349
350 void     gdk_xid_table_insert (XID      *xid,
351                                gpointer  data);
352 void     gdk_xid_table_remove (XID       xid);
353 gpointer gdk_xid_table_lookup (XID       xid);
354
355 /* Internal functions */
356
357 HDC     gdk_gc_predraw  (GdkWindowPrivate *window_private,
358                          GdkGCPrivate *gc_private);
359 void    gdk_gc_postdraw (GdkWindowPrivate *window_private,
360                          GdkGCPrivate *gc_private);
361 HRGN    BitmapToRegion  (HBITMAP hBmp);
362
363 void    gdk_sel_prop_store (GdkWindow *owner,
364                             GdkAtom    type,
365                             gint       format,
366                             guchar    *data,
367                             gint       length);
368
369 void       gdk_event_queue_append (GdkEvent *event);
370
371 /* Please see gdkwindow.c for comments on how to use */ 
372 HWND gdk_window_xid_at(HWND base, gint bx, gint by, gint x, gint y, GList *excludes, gboolean excl_child);
373 HWND gdk_window_xid_at_coords(gint x, gint y, GList *excludes, gboolean excl_child);
374
375 extern gint              gdk_debug_level;
376 extern gint              gdk_show_events;
377 extern gint              gdk_stack_trace;
378 extern gchar            *gdk_display_name;
379 extern HWND              gdk_root_window;
380 extern HWND              gdk_leader_window;
381 GDKVAR GdkWindowPrivate  gdk_root_parent;
382 GDKVAR Atom              gdk_selection_property;
383 extern GdkWindow        *selection_owner[];
384 GDKVAR gchar            *gdk_progclass;
385 GDKVAR gint              gdk_error_code;
386 GDKVAR gint              gdk_error_warnings;
387 GDKVAR gint              gdk_null_window_warnings;
388 extern GList            *gdk_default_filters;
389 extern gint              gdk_event_func_from_window_proc;
390
391 #ifdef USE_XIM
392 /* XIM support */
393 gint   gdk_im_open               (void);
394 void   gdk_im_close              (void);
395 void   gdk_ic_cleanup            (void);
396
397 extern GdkICPrivate *gdk_xim_ic;                /* currently using IC */
398 extern GdkWindow *gdk_xim_window;               /* currently using Window */
399 #endif /* USE_XIM */
400
401 extern HDC               gdk_DC;
402 extern HINSTANCE         gdk_DLLInstance;
403 extern HINSTANCE         gdk_ProgInstance;
404
405 extern UINT              gdk_selection_notify_msg;
406 extern UINT              gdk_selection_request_msg;
407 extern UINT              gdk_selection_clear_msg;
408 extern GdkAtom           gdk_clipboard_atom;
409 extern GdkAtom           gdk_win32_dropfiles_atom;
410 extern GdkAtom           gdk_ole2_dnd_atom;
411
412 extern LRESULT CALLBACK gdk_WindowProc (HWND, UINT, WPARAM, LPARAM);
413
414 /* Debugging support */
415
416 #ifdef G_ENABLE_DEBUG
417
418 #define GDK_NOTE(type,action)                G_STMT_START { \
419     if (gdk_debug_flags & GDK_DEBUG_##type)                 \
420        { action; };                          } G_STMT_END
421
422 #else /* !G_ENABLE_DEBUG */
423
424 #define GDK_NOTE(type,action)
425       
426 #endif /* G_ENABLE_DEBUG */
427
428 GDKVAR guint gdk_debug_flags;
429
430 /* Internal functions for debug output etc. */
431
432 char   *gdk_color_to_string (GdkColor *);
433
434 #ifdef __cplusplus
435 }
436 #endif /* __cplusplus */
437
438
439 #endif /* __GDK_PRIVATE_H__ */