]> Pileus Git - ~andy/gtk/blob - gdk/win32/gdkwin32.h
Win32 changes, still doesn't build though.
[~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 #define STRICT                  /* We want strict type checks */
34 #include <windows.h>
35 #include <commctrl.h>
36
37 /* Make up for some minor w32api header lossage */
38
39 /* PS_JOIN_MASK is missing */
40 #ifndef PS_JOIN_MASK
41 #define PS_JOIN_MASK (PS_JOIN_BEVEL|PS_JOIN_MITER|PS_JOIN_ROUND)
42 #endif
43
44 /* CLR_INVALID is missing */
45 #ifndef CLR_INVALID
46 #define CLR_INVALID CLR_NONE
47 #endif
48
49 /* Some charsets are missing */
50 #ifndef JOHAB_CHARSET
51 #define JOHAB_CHARSET 130
52 #endif
53 #ifndef VIETNAMESE_CHARSET
54 #define VIETNAMESE_CHARSET 163
55 #endif
56
57 #ifndef FS_VIETNAMESE
58 #define FS_VIETNAMESE 0x100
59 #endif
60
61 #ifndef VM_OEM_PLUS
62 #define VK_OEM_PLUS 0xBB
63 #endif
64
65
66 /* Missing messages */
67 #ifndef WM_MOUSEWHEEL
68 #define WM_MOUSEWHEEL 0X20A
69 #endif
70 #ifndef WM_GETOBJECT
71 #define WM_GETOBJECT 0x3D
72 #endif
73 #ifndef WM_NCXBUTTONDOWN
74 #define WM_NCXBUTTONDOWN 0xAB
75 #endif
76 #ifndef WM_NCXBUTTONUP
77 #define WM_NCXBUTTONUP 0xAC
78 #endif
79 #ifndef WM_NCXBUTTONDBLCLK
80 #define WM_NCXBUTTONDBLCLK 0xAD
81 #endif
82 #ifndef WM_MENURBUTTONUP
83 #define WM_MENURBUTTONUP 0x122
84 #endif
85 #ifndef WM_MENUDRAG
86 #define WM_MENUDRAG 0x123
87 #endif
88 #ifndef WM_MENUGETOBJECT
89 #define WM_MENUGETOBJECT 0x124
90 #endif
91 #ifndef WM_UNINITMENUPOPUP
92 #define WM_UNINITMENUPOPUP 0x125
93 #endif
94 #ifndef WM_MENUCOMMAND
95 #define WM_MENUCOMMAND 0x126
96 #endif
97 #ifndef WM_CHANGEUISTATE
98 #define WM_CHANGEUISTATE 0x127
99 #endif
100 #ifndef WM_UPDATEUISTATE
101 #define WM_UPDATEUISTATE 0x128
102 #endif
103 #ifndef WM_QUERYUISTATE
104 #define WM_QUERYUISTATE 0x129
105 #endif
106 #ifndef WM_XBUTTONDOWN
107 #define WM_XBUTTONDOWN 0x20B
108 #endif
109 #ifndef WM_XBUTTONUP
110 #define WM_XBUTTONUP 0x20C
111 #endif
112 #ifndef WM_XBUTTONDBLCLK
113 #define WM_XBUTTONDBLCLK 0x20D
114 #endif
115 #ifndef WM_IME_REQUEST
116 #define WM_IME_REQUEST 0x288
117 #endif
118 #ifndef WM_MOUSEHOVER
119 #define WM_MOUSEHOVER 0x2A1
120 #endif
121 #ifndef WM_MOUSELEAVE
122 #define WM_MOUSELEAVE 0x2A3
123 #endif
124 #ifndef WM_NCMOUSEHOVER
125 #define WM_NCMOUSEHOVER 0x2A0
126 #endif
127 #ifndef WM_NCMOUSELEAVE
128 #define WM_NCMOUSELEAVE 0x2A2
129 #endif
130 #ifndef WM_APPCOMMAND
131 #define WM_APPCOMMAND 0x319
132 #endif
133 #ifndef WM_HANDHELDFIRST
134 #define WM_HANDHELDFIRST 0x358
135 #endif
136 #ifndef WM_HANDHELDLAST
137 #define WM_HANDHELDLAST 0x35F
138 #endif
139 #ifndef WM_AFXFIRST
140 #define WM_AFXFIRST 0x360
141 #endif
142 #ifndef WM_AFXLAST
143 #define WM_AFXLAST 0x37F
144 #endif
145
146 #ifndef CopyCursor
147 #define CopyCursor(pcur) ((HCURSOR)CopyIcon((HICON)(pcur)))
148 #endif
149
150 #include <gdk/gdkprivate.h>
151
152 /* Define corresponding Windows types for some X11 types, just for laziness. */
153 typedef PALETTEENTRY XColor;
154
155 /* Some structs are somewhat useful to emulate internally, just to
156  * keep the code less #ifdefed.
157  */
158 typedef struct {
159   HPALETTE palette;             /* Palette handle used when drawing. */
160   guint size;                   /* Number of entries in the palette. */
161   gboolean stale;               /* 1 if palette needs to be realized,
162                                  * otherwise 0. */
163   gboolean *in_use;
164   gboolean rc_palette;          /* If RC_PALETTE is on in the RASTERCAPS */
165   gulong sizepalette;           /* SIZEPALETTE if rc_palette */
166 } ColormapStruct, *Colormap;
167   
168 typedef struct {
169   gint map_entries;
170   guint visualid;
171   guint bitspixel;
172 } Visual;
173
174 typedef struct {
175   Colormap colormap;
176   unsigned long red_max;
177   unsigned long red_mult;
178   unsigned long green_max;
179   unsigned long green_mult;
180   unsigned long blue_max;
181   unsigned long blue_mult;
182   unsigned long base_pixel;
183 } XStandardColormap;
184
185 typedef struct _GdkGCWin32Data          GdkGCWin32Data;
186 typedef struct _GdkDrawableWin32Data    GdkDrawableWin32Data;
187 typedef struct _GdkWindowWin32Data      GdkWindowWin32Data;
188 typedef struct _GdkWin32PositionInfo    GdkWin32PositionInfo;
189 typedef struct _GdkColormapPrivateWin32 GdkColormapPrivateWin32;
190 typedef struct _GdkCursorPrivate        GdkCursorPrivate;
191 typedef struct _GdkWin32SingleFont      GdkWin32SingleFont;
192 typedef struct _GdkFontPrivateWin32     GdkFontPrivateWin32;
193 typedef struct _GdkImagePrivateWin32    GdkImagePrivateWin32;
194 typedef struct _GdkVisualPrivate        GdkVisualPrivate;
195 typedef struct _GdkRegionPrivate        GdkRegionPrivate;
196 typedef struct _GdkICPrivate            GdkICPrivate;
197
198 #define GDK_DRAWABLE_WIN32DATA(win) ((GdkDrawableWin32Data *)(((GdkDrawablePrivate*)(win))->klass_data))
199 #define GDK_WINDOW_WIN32DATA(win) ((GdkWindowWin32Data *)(((GdkDrawablePrivate*)(win))->klass_data))
200 #define GDK_GC_WIN32DATA(gc) ((GdkGCWin32Data *)(((GdkGCPrivate*)(gc))->klass_data))
201
202 struct _GdkGCWin32Data
203 {
204   GdkRegion *clip_region;
205
206   /* A Windows Device Context (DC) is not equivalent to an X11
207    * GC. We can use a DC only in the window for which it was
208    * allocated, or (in the case of a memory DC) with the bitmap that
209    * has been selected into it. Thus, we have to release and
210    * reallocate a DC each time the GdkGC is used to paint into a new
211    * window or pixmap. We thus keep all the necessary values in the
212    * GdkGCWin32Data struct.
213    */
214   HDC xgc;
215   HRGN hcliprgn;
216   GdkGCValuesMask values_mask;
217   gulong foreground;            /* Pixel values from GdkColor, */
218   gulong background;            /* not Win32 COLORREFs */
219   GdkFont *font;
220   gint rop2;
221   GdkFill fill_style;
222   GdkPixmap *tile;
223   GdkPixmap *stipple;
224   GdkSubwindowMode subwindow_mode;
225   gint graphics_exposures;
226   gint pen_width;
227   DWORD pen_style;
228   HANDLE hwnd;                  /* If a DC is allocated, for which window
229                                  * or what bitmap is selected into it
230                                  */
231   int saved_dc;
232 };
233
234 struct _GdkDrawableWin32Data
235 {
236   HANDLE xid;
237 };
238
239 struct _GdkWin32PositionInfo
240 {
241   gint x;
242   gint y;
243   gint width;
244   gint height;
245   gint x_offset;                /* Offsets to add to Win32 coordinates */
246   gint y_offset;                /* within window to get GDK coodinates */
247   gboolean big : 1;
248   gboolean mapped : 1;
249   gboolean no_bg : 1;           /* Set when the window background is 
250                                  * temporarily unset during resizing
251                                  * and scaling */
252   GdkRectangle clip_rect;       /* visible rectangle of window */
253 };
254
255 struct _GdkWindowWin32Data
256 {
257   GdkDrawableWin32Data drawable;
258
259   GdkWin32PositionInfo position_info;
260
261   /* We must keep the event mask here to filter them ourselves */
262   gint event_mask;
263
264   /* Values for bg_type */
265 #define GDK_WIN32_BG_NORMAL 0
266 #define GDK_WIN32_BG_PIXEL 1
267 #define GDK_WIN32_BG_PIXMAP 2
268 #define GDK_WIN32_BG_PARENT_RELATIVE 3
269 #define GDK_WIN32_BG_TRANSPARENT 4
270
271   /* We draw the background ourselves at WM_ERASEBKGND  */
272   guchar bg_type;
273   gulong bg_pixel;
274   GdkPixmap *bg_pixmap;
275
276   HCURSOR xcursor;
277
278   /* Window size hints */
279   gint hint_flags;
280   gint hint_x, hint_y;
281   gint hint_min_width, hint_min_height;
282   gint hint_max_width, hint_max_height;
283
284   gboolean extension_events_selected;
285
286   HKL input_locale;
287   CHARSETINFO charset_info;
288 };
289
290 struct _GdkCursorPrivate
291 {
292   GdkCursor cursor;
293   HCURSOR xcursor;
294 };
295
296 struct _GdkWin32SingleFont
297 {
298   HFONT xfont;
299   UINT charset;
300   UINT codepage;
301   FONTSIGNATURE fs;
302 };
303
304 struct _GdkFontPrivateWin32
305 {
306   GdkFontPrivate base;
307   GSList *fonts;                /* List of GdkWin32SingleFonts */
308   GSList *names;
309 };
310
311 struct _GdkVisualPrivate
312 {
313   GdkVisual visual;
314   Visual *xvisual;
315 };
316
317 struct _GdkColormapPrivateWin32
318 {
319   Colormap xcolormap;
320   gint private_val;
321
322   GHashTable *hash;
323   GdkColorInfo *info;
324   DWORD last_sync_time;
325 };
326
327 struct _GdkImagePrivateWin32
328 {
329   HBITMAP ximage;
330 };
331
332 #define GDK_ROOT_WINDOW()             ((guint32) HWND_DESKTOP)
333 #define GDK_ROOT_PARENT()             ((GdkWindow *) gdk_parent_root)
334 #define GDK_DISPLAY()                 NULL
335 #define GDK_DRAWABLE_XID(win)         (GDK_DRAWABLE_WIN32DATA(win)->xid)
336 #define GDK_IMAGE_XIMAGE(image)       (((GdkImagePrivate *) image)->ximage)
337 #define GDK_COLORMAP_XDISPLAY(cmap)   NULL
338 #define GDK_COLORMAP_WIN32COLORMAP(cmap)(((GdkColormapPrivateWin32 *) cmap)->xcolormap)
339 #define GDK_VISUAL_XVISUAL(vis)       (((GdkVisualPrivate *) vis)->xvisual)
340
341 #define GDK_WINDOW_XWINDOW            GDK_DRAWABLE_XID
342 #define GDK_WINDOW_XDISPLAY           GDK_DRAWABLE_XDISPLAY
343
344 GDKVAR gchar            *gdk_progclass;
345 GDKVAR ATOM              gdk_selection_property;
346
347 /* Functions to create GDK pixmaps and windows from their native equivalents */
348 GdkPixmap    *gdk_pixmap_foreign_new (guint32     anid);
349 GdkWindow    *gdk_window_foreign_new (guint32     anid);
350
351 /* Return the Gdk* for a particular HANDLE */
352 gpointer      gdk_xid_table_lookup     (HANDLE handle);
353
354 /* Return a device context to draw in a drawable, given a GDK GC,
355  * and a mask indicating which GC values might be used (for efficiency,
356  * no need to muck around with text-related stuff if we aren't going
357  * to output text, for instance).
358  */
359 HDC           gdk_win32_hdc_get (GdkDrawable    *drawable,
360                                  GdkGC          *gc,
361                                  GdkGCValuesMask usage);
362
363
364 /* Each HDC returned from gdk_win32_hdc_get must be released with
365  * this function
366  */
367 void          gdk_win32_hdc_release (GdkDrawable    *drawable,
368                                      GdkGC          *gc,
369                                      GdkGCValuesMask usage);
370
371 #endif /* __GDK_WIN32_H__ */