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