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