1 /* GDK - The GIMP Drawing Kit
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
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.
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.
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.
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/.
27 #ifndef __GDK_PRIVATE_H__
28 #define __GDK_PRIVATE_H__
30 #define STRICT /* We want strict type checks */
34 /* Make up for some minor mingw32 lossage */
36 /* PS_JOIN_MASK is missing from the mingw32 headers */
38 #define PS_JOIN_MASK (PS_JOIN_BEVEL|PS_JOIN_MITER|PS_JOIN_ROUND)
41 /* CLR_INVALID is missing */
43 #define CLR_INVALID CLR_NONE
46 /* Some charsets are missing */
48 #define JOHAB_CHARSET 130
50 #ifndef VIETNAMESE_CHARSET
51 #define VIETNAMESE_CHARSET 163
55 #define VK_OEM_PLUS 0xBB
60 #include <gdk/gdktypes.h>
62 #include <gdk/gdkcursor.h>
63 #include <gdk/gdkevents.h>
64 #include <gdk/gdkfont.h>
65 #include <gdk/gdkgc.h>
66 #include <gdk/gdkim.h>
67 #include <gdk/gdkimage.h>
68 #include <gdk/gdkregion.h>
69 #include <gdk/gdkvisual.h>
70 #include <gdk/gdkwindow.h>
72 #define GDK_DRAWABLE_TYPE(d) (((GdkDrawablePrivate *)d)->window_type)
73 #define GDK_IS_WINDOW(d) (GDK_DRAWABLE_TYPE(d) <= GDK_WINDOW_TEMP || \
74 GDK_DRAWABLE_TYPE(d) == GDK_WINDOW_FOREIGN)
75 #define GDK_IS_PIXMAP(d) (GDK_DRAWABLE_TYPE(d) == GDK_DRAWABLE_PIXMAP)
76 #define GDK_DRAWABLE_DESTROYED(d) (((GdkDrawablePrivate *)d)->destroyed)
78 #define gdk_window_lookup(xid) ((GdkWindow*) gdk_xid_table_lookup (xid))
79 #define gdk_pixmap_lookup(xid) ((GdkPixmap*) gdk_xid_table_lookup (xid))
81 /* HFONTs clash with HWNDs, so add dithering to HFONTs... (hack) */
82 #define HFONT_DITHER 43
83 #define gdk_font_lookup(xid) ((GdkFont*) gdk_xid_table_lookup ((HANDLE) ((guint) xid + HFONT_DITHER)))
87 #endif /* __cplusplus */
89 /* Define corresponding Windows types for some X11 types, just for laziness.
93 typedef PALETTEENTRY XColor;
96 typedef HCURSOR Cursor;
97 typedef guint VisualID;
101 /* Define some of the X11 constants also here, again just for laziness */
103 /* Generic null resource */
109 /* Grabbing status */
110 #define GrabSuccess 0
111 #define AlreadyGrabbed 2
113 /* For CreateColormap */
117 /* Some structs are somewhat useful to emulate internally, just to
118 keep the code less #ifdefed. */
120 HPALETTE palette; /* Palette handle used when drawing. */
121 guint size; /* Number of entries in the palette. */
122 gboolean stale; /* 1 if palette needs to be realized,
125 gboolean rc_palette; /* If RC_PALETTE is on in the RASTERCAPS */
126 gulong sizepalette; /* SIZEPALETTE if rc_palette */
127 } ColormapStruct, *Colormap;
137 unsigned long red_max;
138 unsigned long red_mult;
139 unsigned long green_max;
140 unsigned long green_mult;
141 unsigned long blue_max;
142 unsigned long blue_mult;
143 unsigned long base_pixel;
146 typedef struct _GdkDrawablePrivate GdkDrawablePrivate;
147 /* typedef struct _GdkDrawablePrivate GdkPixmapPrivate; */
148 typedef struct _GdkWindowPrivate GdkWindowPrivate;
149 typedef struct _GdkImagePrivate GdkImagePrivate;
150 typedef struct _GdkGCPrivate GdkGCPrivate;
151 typedef struct _GdkColormapPrivate GdkColormapPrivate;
152 typedef struct _GdkColorInfo GdkColorInfo;
153 typedef struct _GdkVisualPrivate GdkVisualPrivate;
154 typedef struct _GdkFontPrivate GdkFontPrivate;
155 typedef struct _GdkCursorPrivate GdkCursorPrivate;
156 typedef struct _GdkEventFilter GdkEventFilter;
157 typedef struct _GdkClientFilter GdkClientFilter;
158 typedef struct _GdkRegionPrivate GdkRegionPrivate;
160 struct _GdkDrawablePrivate
162 GdkDrawable drawable;
171 GdkColormap *colormap;
176 struct _GdkWindowPrivate
178 GdkDrawablePrivate drawable;
185 guint guffaw_gravity : 1;
187 /* We must keep the event mask here to filter them ourselves */
190 /* Values for bg_type */
191 #define GDK_WIN32_BG_NORMAL 0
192 #define GDK_WIN32_BG_PIXEL 1
193 #define GDK_WIN32_BG_PIXMAP 2
194 #define GDK_WIN32_BG_PARENT_RELATIVE 3
195 #define GDK_WIN32_BG_TRANSPARENT 4
197 /* We draw the background ourselves at WM_ERASEBKGND */
200 GdkPixmap *bg_pixmap;
204 /* Window size hints */
207 gint hint_min_width, hint_min_height;
208 gint hint_max_width, hint_max_height;
210 gint extension_events;
211 gboolean extension_events_selected;
217 CHARSETINFO charset_info;
220 struct _GdkImagePrivate
226 void (*image_put) (GdkDrawable *window,
241 /* A Windows Device Context (DC) is not equivalent to an X11
242 * GC. We can use a DC only in the window for which it was
243 * allocated, or (in the case of a memory DC) with the bitmap that
244 * has been selected into it. Thus, we have to release and
245 * reallocate a DC each time the GdkGC is used to paint into a new
246 * window or pixmap. We thus keep all the necessary values in the
247 * GdkGCPrivate struct.
249 GdkGCValuesMask values_mask;
258 GdkSubwindowMode subwindow_mode;
263 gint graphics_exposures;
266 HANDLE hwnd; /* If a DC is allocated, for which window
267 or what bitmap is selected into it */
273 GDK_COLOR_WRITEABLE = 1 << 0
278 GdkColorInfoFlags flags;
282 struct _GdkColormapPrivate
284 GdkColormap colormap;
291 time_t last_sync_time;
296 struct _GdkVisualPrivate
302 struct _GdkFontPrivate
305 /* For now, both GDK_FONT_FONT and GDK_FONT_FONTSET fonts
306 * just have one Windows font loaded. This will change.
318 struct _GdkCursorPrivate
324 struct _GdkEventFilter {
325 GdkFilterFunc function;
329 struct _GdkClientFilter {
331 GdkFilterFunc function;
335 struct _GdkRegionPrivate
342 GDK_DEBUG_MISC = 1 << 0,
343 GDK_DEBUG_EVENTS = 1 << 1,
344 GDK_DEBUG_DND = 1 << 2,
345 GDK_DEBUG_COLOR_CONTEXT = 1 << 3,
346 GDK_DEBUG_XIM = 1 << 4,
347 GDK_DEBUG_SELECTION = 1 << 5
350 void gdk_events_init (void);
351 void gdk_window_init (void);
352 void gdk_visual_init (void);
353 void gdk_selection_init (void);
354 void gdk_dnd_init (void);
355 void gdk_dnd_exit (void);
356 void gdk_image_init (void);
357 void gdk_image_exit (void);
359 GdkColormap* gdk_colormap_lookup (Colormap xcolormap);
360 GdkVisual* gdk_visual_lookup (Visual *xvisual);
362 void gdk_window_add_colormap_windows (GdkWindow *window);
363 void gdk_window_destroy_notify (GdkWindow *window);
365 void gdk_xid_table_insert (XID *xid,
367 void gdk_xid_table_remove (XID xid);
368 gpointer gdk_xid_table_lookup (XID xid);
370 /* Internal functions */
372 HDC gdk_gc_predraw (GdkDrawablePrivate *drawable_private,
373 GdkGCPrivate *gc_private);
374 void gdk_gc_postdraw (GdkDrawablePrivate *drawable_private,
375 GdkGCPrivate *gc_private);
376 HRGN BitmapToRegion (HBITMAP hBmp);
378 void gdk_sel_prop_store (GdkWindow *owner,
384 void gdk_event_queue_append (GdkEvent *event);
386 gint gdk_nmbstowcs (GdkWChar *dest,
390 gint gdk_nmbstowchar_ts (wchar_t *dest,
395 /* Please see gdkwindow.c for comments on how to use */
396 HWND gdk_window_xid_at(HWND base, gint bx, gint by, gint x, gint y, GList *excludes, gboolean excl_child);
397 HWND gdk_window_xid_at_coords(gint x, gint y, GList *excludes, gboolean excl_child);
399 extern gint gdk_debug_level;
400 extern gint gdk_show_events;
401 extern gint gdk_stack_trace;
402 extern HWND gdk_root_window;
403 extern HWND gdk_leader_window;
404 GDKVAR GdkWindowPrivate *gdk_root_parent;
405 GDKVAR Atom gdk_selection_property;
406 GDKVAR gchar *gdk_progclass;
407 GDKVAR gint gdk_error_code;
408 GDKVAR gint gdk_error_warnings;
409 GDKVAR gint gdk_null_window_warnings;
410 extern gint gdk_event_func_from_window_proc;
413 extern HINSTANCE gdk_DLLInstance;
414 extern HINSTANCE gdk_ProgInstance;
416 extern UINT gdk_selection_notify_msg;
417 extern UINT gdk_selection_request_msg;
418 extern UINT gdk_selection_clear_msg;
419 extern GdkAtom gdk_clipboard_atom;
420 extern GdkAtom gdk_win32_dropfiles_atom;
421 extern GdkAtom gdk_ole2_dnd_atom;
423 typedef BOOL (WINAPI *PFN_TrackMouseEvent) (LPTRACKMOUSEEVENT);
424 extern PFN_TrackMouseEvent p_TrackMouseEvent;
426 extern LRESULT CALLBACK gdk_WindowProc (HWND, UINT, WPARAM, LPARAM);
428 /* Debugging support */
430 #ifdef G_ENABLE_DEBUG
432 #define GDK_NOTE(type,action) G_STMT_START { \
433 if (gdk_debug_flags & GDK_DEBUG_##type) \
434 { action; }; } G_STMT_END
436 #else /* !G_ENABLE_DEBUG */
438 #define GDK_NOTE(type,action)
440 #endif /* G_ENABLE_DEBUG */
442 GDKVAR guint gdk_debug_flags;
444 /* Internal functions for debug output etc. */
446 char *gdk_color_to_string (GdkColor *);
450 #endif /* __cplusplus */
453 #endif /* __GDK_PRIVATE_H__ */