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