]> Pileus Git - ~andy/gtk/blob - gdk/win32/gdkwin32.h
updated externals
[~andy/gtk] / gdk / win32 / gdkwin32.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 #ifndef __GDK_WIN32_H__
28 #define __GDK_WIN32_H__
29
30 #include <gdk/gdkprivate.h>
31 #include <gdk/gdkinternals.h>
32 #include <gdk/gdkcursor.h>
33
34 #ifndef STRICT
35 #define STRICT                  /* We want strict type checks */
36 #endif
37 #include <windows.h>
38 #include <commctrl.h>
39
40 #include <gdk/win32/gdkwindow-win32.h>
41 #include <gdk/win32/gdkpixmap-win32.h>
42
43 #ifdef __cplusplus
44 extern "C" {
45 #endif /* __cplusplus */
46
47 /* Make up for some minor w32api header lossage */
48
49 /* PS_JOIN_MASK is missing */
50 #ifndef PS_JOIN_MASK
51 #define PS_JOIN_MASK (PS_JOIN_BEVEL|PS_JOIN_MITER|PS_JOIN_ROUND)
52 #endif
53
54 /* CLR_INVALID is missing */
55 #ifndef CLR_INVALID
56 #define CLR_INVALID CLR_NONE
57 #endif
58
59 /* Some charsets are missing */
60 #ifndef JOHAB_CHARSET
61 #define JOHAB_CHARSET 130
62 #endif
63 #ifndef VIETNAMESE_CHARSET
64 #define VIETNAMESE_CHARSET 163
65 #endif
66
67 #ifndef FS_VIETNAMESE
68 #define FS_VIETNAMESE 0x100
69 #endif
70
71 /* Some virtual keycodes are missing */
72 #ifndef VM_OEM_PLUS
73 #define VK_OEM_PLUS 0xBB
74 #endif
75
76 #ifndef VK_OEM_COMMA
77 #define VK_OEM_COMMA 0xBC
78 #endif
79
80 #ifndef VK_OEM_MINUS
81 #define VK_OEM_MINUS 0xBD
82 #endif
83
84 #ifndef VK_OEM_PERIOD
85 #define VK_OEM_PERIOD 0xBE
86 #endif
87
88 #ifndef VK_OEM_1
89 #define VK_OEM_1 0xBA
90 #endif
91 #ifndef VK_OEM_2
92 #define VK_OEM_2 0xBF
93 #endif
94 #ifndef VK_OEM_3
95 #define VK_OEM_3 0xC0
96 #endif
97 #ifndef VK_OEM_4
98 #define VK_OEM_4 0xDB
99 #endif
100 #ifndef VK_OEM_5
101 #define VK_OEM_5 0xDC
102 #endif
103 #ifndef VK_OEM_6
104 #define VK_OEM_6 0xDD
105 #endif
106 #ifndef VK_OEM_7
107 #define VK_OEM_7 0xDE
108 #endif
109 #ifndef VK_OEM_8
110 #define VK_OEM_8 0xDF
111 #endif
112
113 /* Missing messages */
114 #ifndef WM_SYNCPAINT
115 #define WM_SYNCPAINT 0x88
116 #endif
117 #ifndef WM_MOUSEWHEEL
118 #define WM_MOUSEWHEEL 0X20A
119 #endif
120 #ifndef WM_GETOBJECT
121 #define WM_GETOBJECT 0x3D
122 #endif
123 #ifndef WM_NCXBUTTONDOWN
124 #define WM_NCXBUTTONDOWN 0xAB
125 #endif
126 #ifndef WM_NCXBUTTONUP
127 #define WM_NCXBUTTONUP 0xAC
128 #endif
129 #ifndef WM_NCXBUTTONDBLCLK
130 #define WM_NCXBUTTONDBLCLK 0xAD
131 #endif
132 #ifndef WM_MENURBUTTONUP
133 #define WM_MENURBUTTONUP 0x122
134 #endif
135 #ifndef WM_MENUDRAG
136 #define WM_MENUDRAG 0x123
137 #endif
138 #ifndef WM_MENUGETOBJECT
139 #define WM_MENUGETOBJECT 0x124
140 #endif
141 #ifndef WM_UNINITMENUPOPUP
142 #define WM_UNINITMENUPOPUP 0x125
143 #endif
144 #ifndef WM_MENUCOMMAND
145 #define WM_MENUCOMMAND 0x126
146 #endif
147 #ifndef WM_CHANGEUISTATE
148 #define WM_CHANGEUISTATE 0x127
149 #endif
150 #ifndef WM_UPDATEUISTATE
151 #define WM_UPDATEUISTATE 0x128
152 #endif
153 #ifndef WM_QUERYUISTATE
154 #define WM_QUERYUISTATE 0x129
155 #endif
156 #ifndef WM_XBUTTONDOWN
157 #define WM_XBUTTONDOWN 0x20B
158 #endif
159 #ifndef WM_XBUTTONUP
160 #define WM_XBUTTONUP 0x20C
161 #endif
162 #ifndef WM_XBUTTONDBLCLK
163 #define WM_XBUTTONDBLCLK 0x20D
164 #endif
165 #ifndef WM_IME_REQUEST
166 #define WM_IME_REQUEST 0x288
167 #endif
168 #ifndef WM_MOUSEHOVER
169 #define WM_MOUSEHOVER 0x2A1
170 #endif
171 #ifndef WM_MOUSELEAVE
172 #define WM_MOUSELEAVE 0x2A3
173 #endif
174 #ifndef WM_NCMOUSEHOVER
175 #define WM_NCMOUSEHOVER 0x2A0
176 #endif
177 #ifndef WM_NCMOUSELEAVE
178 #define WM_NCMOUSELEAVE 0x2A2
179 #endif
180 #ifndef WM_APPCOMMAND
181 #define WM_APPCOMMAND 0x319
182 #endif
183 #ifndef WM_HANDHELDFIRST
184 #define WM_HANDHELDFIRST 0x358
185 #endif
186 #ifndef WM_HANDHELDLAST
187 #define WM_HANDHELDLAST 0x35F
188 #endif
189 #ifndef WM_AFXFIRST
190 #define WM_AFXFIRST 0x360
191 #endif
192 #ifndef WM_AFXLAST
193 #define WM_AFXLAST 0x37F
194 #endif
195
196 #ifndef CopyCursor
197 #define CopyCursor(pcur) ((HCURSOR)CopyIcon((HICON)(pcur)))
198 #endif
199
200 #ifdef INSIDE_GDK_WIN32
201
202 #include <gdk/gdkprivate.h>
203
204 /* Define corresponding Windows types for some X11 types, just for laziness. */
205 typedef PALETTEENTRY XColor;
206
207 /* Some structs are somewhat useful to emulate internally, just to
208  * keep the code less #ifdefed.
209  */
210 typedef struct {
211   HPALETTE palette;             /* Palette handle used when drawing. */
212   guint size;                   /* Number of entries in the palette. */
213   gboolean stale;               /* 1 if palette needs to be realized,
214                                  * otherwise 0. */
215   gboolean *in_use;
216   gboolean rc_palette;          /* If RC_PALETTE is on in the RASTERCAPS */
217   gulong sizepalette;           /* SIZEPALETTE if rc_palette */
218 } ColormapStruct, *Colormap;
219   
220 typedef struct {
221   gint map_entries;
222   guint visualid;
223   guint bitspixel;
224 } Visual;
225
226 typedef struct {
227   Colormap colormap;
228   unsigned long red_max;
229   unsigned long red_mult;
230   unsigned long green_max;
231   unsigned long green_mult;
232   unsigned long blue_max;
233   unsigned long blue_mult;
234   unsigned long base_pixel;
235 } XStandardColormap;
236
237 typedef struct _GdkColormapPrivateWin32 GdkColormapPrivateWin32;
238 typedef struct _GdkCursorPrivate        GdkCursorPrivate;
239 typedef struct _GdkWin32SingleFont      GdkWin32SingleFont;
240 typedef struct _GdkFontPrivateWin32     GdkFontPrivateWin32;
241 typedef struct _GdkImagePrivateWin32    GdkImagePrivateWin32;
242 typedef struct _GdkVisualPrivate        GdkVisualPrivate;
243
244 struct _GdkCursorPrivate
245 {
246   GdkCursor cursor;
247   HCURSOR hcursor;
248 };
249
250 struct _GdkWin32SingleFont
251 {
252   HFONT hfont;
253   UINT charset;
254   UINT codepage;
255   FONTSIGNATURE fs;
256 };
257
258 struct _GdkFontPrivateWin32
259 {
260   GdkFontPrivate base;
261   GSList *fonts;                /* List of GdkWin32SingleFonts */
262   GSList *names;
263 };
264
265 struct _GdkVisualClass
266 {
267   GObjectClass parent_class;
268 };
269
270 struct _GdkVisualPrivate
271 {
272   GdkVisual visual;
273   Visual *xvisual;
274 };
275
276 struct _GdkColormapPrivateWin32
277 {
278   Colormap xcolormap;
279   gint private_val;
280
281   GHashTable *hash;
282   GdkColorInfo *info;
283   DWORD last_sync_time;
284 };
285
286 struct _GdkImagePrivateWin32
287 {
288   HBITMAP hbitmap;
289 };
290
291 typedef struct _GdkGCWin32      GdkGCWin32;
292 typedef struct _GdkGCWin32Class GdkGCWin32Class;
293
294 #define GDK_TYPE_GC_WIN32              (gdk_gc_win32_get_type ())
295 #define GDK_GC_WIN32(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_GC_WIN32, GdkGCWin32))
296 #define GDK_GC_WIN32_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_GC_WIN32, GdkGCWin32Class))
297 #define GDK_IS_GC_WIN32(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_GC_WIN32))
298 #define GDK_IS_GC_WIN32_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_GC_WIN32))
299 #define GDK_GC_WIN32_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_GC_WIN32, GdkGCWin32Class))
300
301 struct _GdkGCWin32
302 {
303   GdkGC parent_instance;
304
305   /* A Windows Device Context (DC) is not equivalent to an X11
306    * GC. We can use a DC only in the window for which it was
307    * allocated, or (in the case of a memory DC) with the bitmap that
308    * has been selected into it. Thus, we have to release and
309    * reallocate a DC each time the GdkGC is used to paint into a new
310    * window or pixmap. We thus keep all the necessary values in the
311    * GdkGCWin32 object.
312    */
313   HDC hdc;
314
315   GdkRegion *clip_region;
316   HRGN hcliprgn;
317
318   GdkGCValuesMask values_mask;
319
320   gulong foreground;            /* Pixel values from GdkColor, */
321   gulong background;            /* not Win32 COLORREFs */
322
323   GdkFont *font;
324   gint rop2;
325   GdkFill fill_style;
326   GdkPixmap *tile;
327   GdkPixmap *stipple;
328   GdkSubwindowMode subwindow_mode;
329   gint graphics_exposures;
330   gint pen_width;
331   DWORD pen_style;
332   HANDLE hwnd;                  /* If a HDC is allocated, for which window,
333                                  * or what bitmap is selected into it
334                                  */
335   int saved_dc;
336 };
337
338 struct _GdkGCWin32Class
339 {
340   GdkGCClass parent_class;
341 };
342
343 GType gdk_gc_win32_get_type (void);
344
345 #undef GDK_ROOT_PARENT /* internal access is direct */
346 #define GDK_ROOT_PARENT()             ((GdkWindow *) _gdk_parent_root)
347 #define GDK_WINDOW_HWND(win)          (GDK_DRAWABLE_IMPL_WIN32(((GdkWindowObject *)win)->impl)->handle)
348 #define GDK_PIXMAP_HBITMAP(pixmap)    (GDK_DRAWABLE_IMPL_WIN32(((GdkPixmapObject *)pixmap)->impl)->handle)
349 #define GDK_DRAWABLE_HANDLE(win)      (GDK_IS_WINDOW (win) ? (GDK_WINDOW_HWND (win)) : (GDK_PIXMAP_HBITMAP (win)))
350 #define GDK_IMAGE_HBM(image)          (((GdkImagePrivateWin32 *) GDK_IMAGE (image)->windowing_data)->hbm)
351 #define GDK_COLORMAP_PRIVATE_DATA(cmap) ((GdkColormapPrivateWin32 *) GDK_COLORMAP (cmap)->windowing_data)
352 #define GDK_COLORMAP_WIN32COLORMAP(cmap) (((GdkColormapPrivateWin32 *)GDK_COLORMAP (cmap)->windowing_data)->xcolormap)
353 #define GDK_VISUAL_XVISUAL(vis)       (((GdkVisualPrivate *) vis)->xvisual)
354
355 #else
356 /* definition for exported 'internals' go here */
357 #define GDK_WINDOW_HWND(d) (gdk_win32_drawable_get_handle (d))
358
359 #endif
360
361 #define GDK_ROOT_WINDOW()             ((guint32) HWND_DESKTOP)
362 #define GDK_DISPLAY()                 NULL
363
364 /* Functions to create GDK pixmaps and windows from their native equivalents */
365 GdkPixmap    *gdk_pixmap_foreign_new (GdkNativeWindow anid);
366 GdkWindow    *gdk_window_foreign_new (GdkNativeWindow anid);
367
368 /* Return the Gdk* for a particular HANDLE */
369 gpointer      gdk_win32_handle_table_lookup (GdkNativeWindow handle);
370
371 /* Translate from drawable to windows handle */
372 HWND          gdk_win32_drawable_get_handle (GdkDrawable *drawable);
373
374 #define gdk_window_lookup(hwnd) (GdkWindow*) gdk_win32_handle_table_lookup (hwnd)
375 #define gdk_pixmap_lookup(hbm)  (GdkPixmap*) gdk_win32_handle_table_lookup (hbm)
376
377 /* Return a device context to draw in a drawable, given a GDK GC,
378  * and a mask indicating which GC values might be used (for efficiency,
379  * no need to muck around with text-related stuff if we aren't going
380  * to output text, for instance).
381  */
382 HDC           gdk_win32_hdc_get      (GdkDrawable    *drawable,
383                                       GdkGC          *gc,
384                                       GdkGCValuesMask usage);
385
386 /* Each HDC returned from gdk_win32_hdc_get must be released with
387  * this function
388  */
389 void          gdk_win32_hdc_release  (GdkDrawable    *drawable,
390                                       GdkGC          *gc,
391                                       GdkGCValuesMask usage);
392
393 #ifdef __cplusplus
394 }
395 #endif /* __cplusplus */
396
397 #endif /* __GDK_WIN32_H__ */