]> Pileus Git - ~andy/gtk/blob - gdk/win32/gdkwin32.h
Handle also WM_SYSCHAR, and other changes to get handling of Alt+nnn or
[~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 /* Define some of the X11 constants also here, again just for laziness */
156
157 /* Error codes */
158 #define Success            0
159
160 /* Grabbing status */
161 #define GrabSuccess        0
162 #define AlreadyGrabbed     2
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 _GdkGCWin32Data          GdkGCWin32Data;
195 typedef struct _GdkDrawableWin32Data    GdkDrawableWin32Data;
196 typedef struct _GdkWindowWin32Data      GdkWindowWin32Data;
197 typedef struct _GdkWin32PositionInfo    GdkWin32PositionInfo;
198 typedef struct _GdkColormapPrivateWin32 GdkColormapPrivateWin32;
199 typedef struct _GdkCursorPrivate        GdkCursorPrivate;
200 typedef struct _GdkWin32SingleFont      GdkWin32SingleFont;
201 typedef struct _GdkFontPrivateWin32     GdkFontPrivateWin32;
202 typedef struct _GdkImagePrivateWin32    GdkImagePrivateWin32;
203 typedef struct _GdkVisualPrivate        GdkVisualPrivate;
204 typedef struct _GdkRegionPrivate        GdkRegionPrivate;
205 typedef struct _GdkICPrivate            GdkICPrivate;
206
207 #define GDK_DRAWABLE_WIN32DATA(win) ((GdkDrawableWin32Data *)(((GdkDrawablePrivate*)(win))->klass_data))
208 #define GDK_WINDOW_WIN32DATA(win) ((GdkWindowWin32Data *)(((GdkDrawablePrivate*)(win))->klass_data))
209 #define GDK_GC_WIN32DATA(gc) ((GdkGCWin32Data *)(((GdkGCPrivate*)(gc))->klass_data))
210
211 struct _GdkGCWin32Data
212 {
213   GdkRegion *clip_region;
214
215   /* A Windows Device Context (DC) is not equivalent to an X11
216    * GC. We can use a DC only in the window for which it was
217    * allocated, or (in the case of a memory DC) with the bitmap that
218    * has been selected into it. Thus, we have to release and
219    * reallocate a DC each time the GdkGC is used to paint into a new
220    * window or pixmap. We thus keep all the necessary values in the
221    * GdkGCWin32Data struct.
222    */
223   HDC xgc;
224   HRGN hcliprgn;
225   GdkGCValuesMask values_mask;
226   gulong foreground;            /* Pixel values from GdkColor, */
227   gulong background;            /* not Win32 COLORREFs */
228   GdkFont *font;
229   gint rop2;
230   GdkFill fill_style;
231   GdkPixmap *tile;
232   GdkPixmap *stipple;
233   GdkSubwindowMode subwindow_mode;
234   gint graphics_exposures;
235   gint pen_width;
236   DWORD pen_style;
237   HANDLE hwnd;                  /* If a DC is allocated, for which window
238                                  * or what bitmap is selected into it
239                                  */
240   int saved_dc;
241 };
242
243 struct _GdkDrawableWin32Data
244 {
245   HANDLE xid;
246 };
247
248 struct _GdkWin32PositionInfo
249 {
250   gint x;
251   gint y;
252   gint width;
253   gint height;
254   gint x_offset;                /* Offsets to add to Win32 coordinates */
255   gint y_offset;                /* within window to get GDK coodinates */
256   gboolean big : 1;
257   gboolean mapped : 1;
258   gboolean no_bg : 1;           /* Set when the window background is 
259                                  * temporarily unset during resizing
260                                  * and scaling */
261   GdkRectangle clip_rect;       /* visible rectangle of window */
262 };
263
264 struct _GdkWindowWin32Data
265 {
266   GdkDrawableWin32Data drawable;
267
268   GdkWin32PositionInfo position_info;
269
270   /* We must keep the event mask here to filter them ourselves */
271   gint event_mask;
272
273   /* Values for bg_type */
274 #define GDK_WIN32_BG_NORMAL 0
275 #define GDK_WIN32_BG_PIXEL 1
276 #define GDK_WIN32_BG_PIXMAP 2
277 #define GDK_WIN32_BG_PARENT_RELATIVE 3
278 #define GDK_WIN32_BG_TRANSPARENT 4
279
280   /* We draw the background ourselves at WM_ERASEBKGND  */
281   guchar bg_type;
282   gulong bg_pixel;
283   GdkPixmap *bg_pixmap;
284
285   HCURSOR xcursor;
286
287   /* Window size hints */
288   gint hint_flags;
289   gint hint_x, hint_y;
290   gint hint_min_width, hint_min_height;
291   gint hint_max_width, hint_max_height;
292
293   gboolean extension_events_selected;
294
295   HKL input_locale;
296   CHARSETINFO charset_info;
297 };
298
299 struct _GdkCursorPrivate
300 {
301   GdkCursor cursor;
302   HCURSOR xcursor;
303 };
304
305 struct _GdkWin32SingleFont
306 {
307   HFONT xfont;
308   UINT charset;
309   UINT codepage;
310   FONTSIGNATURE fs;
311 };
312
313 struct _GdkFontPrivateWin32
314 {
315   GdkFontPrivate base;
316   GSList *fonts;                /* List of GdkWin32SingleFonts */
317   GSList *names;
318 };
319
320 struct _GdkVisualPrivate
321 {
322   GdkVisual visual;
323   Visual *xvisual;
324 };
325
326 struct _GdkColormapPrivateWin32
327 {
328   GdkColormapPrivate base;
329   Colormap xcolormap;
330   gint private_val;
331
332   GHashTable *hash;
333   GdkColorInfo *info;
334   DWORD last_sync_time;
335 };
336
337 struct _GdkImagePrivateWin32
338 {
339   GdkImagePrivate base;
340   HBITMAP ximage;
341 };
342
343 #define GDK_ROOT_WINDOW()             ((guint32) HWND_DESKTOP)
344 #define GDK_ROOT_PARENT()             ((GdkWindow *) gdk_parent_root)
345 #define GDK_DISPLAY()                 NULL
346 #define GDK_DRAWABLE_XID(win)         (GDK_DRAWABLE_WIN32DATA(win)->xid)
347 #define GDK_IMAGE_XIMAGE(image)       (((GdkImagePrivate *) image)->ximage)
348 #define GDK_COLORMAP_XDISPLAY(cmap)   NULL
349 #define GDK_COLORMAP_WIN32COLORMAP(cmap)(((GdkColormapPrivateWin32 *) cmap)->xcolormap)
350 #define GDK_VISUAL_XVISUAL(vis)       (((GdkVisualPrivate *) vis)->xvisual)
351
352 #define GDK_WINDOW_XWINDOW            GDK_DRAWABLE_XID
353 #define GDK_WINDOW_XDISPLAY           GDK_DRAWABLE_XDISPLAY
354
355 GDKVAR gchar            *gdk_progclass;
356 GDKVAR ATOM              gdk_selection_property;
357
358 /* Functions to create GDK pixmaps and windows from their native equivalents */
359 GdkPixmap    *gdk_pixmap_foreign_new (guint32     anid);
360 GdkWindow    *gdk_window_foreign_new (guint32     anid);
361
362 /* Return the Gdk* for a particular HANDLE */
363 gpointer      gdk_xid_table_lookup     (HANDLE handle);
364
365 #endif /* __GDK_WIN32_H__ */