]> Pileus Git - ~andy/gtk/blob - gdk/win32/gdkwin32.h
Large changes to the Win32 backend, partially made necessary by 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 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 #ifndef WM_GETOBJECT
67 #define WM_GETOBJECT 0x3D
68 #endif
69
70 #ifndef WM_NCXBUTTONDOWN
71 #define WM_NCXBUTTONDOWN 0xAB
72 #define WM_NCXBUTTONUP 0xAC
73 #define WM_NCXBUTTONDBLCLK 0xAD
74 #endif
75
76 #ifndef WM_CHANGEUISTATE
77 #define WM_CHANGEUISTATE 0x127
78 #define WM_UPDATEUISTATE 0x128
79 #define WM_QUERYUISTATE 0x129
80 #endif
81
82 #ifndef WM_XBUTTONDOWN
83 #define WM_XBUTTONDOWN 0x20B
84 #define WM_XBUTTONUP 0x20C
85 #define WM_XBUTTONDBLCLK 0x20D
86 #endif
87
88 #ifndef WM_IME_REQUEST
89 #define WM_IME_REQUEST 0x288
90 #endif
91
92 #ifndef WM_NCMOUSEHOVER
93 #define WM_NCMOUSEHOVER 0x2A0
94 #define WM_NCMOUSELEAVE 0x2A2
95 #endif
96
97 #ifndef WM_APPCOMMAND
98 #define WM_APPCOMMAND 0x319
99 #endif
100
101
102 #include <gdk/gdkprivate.h>
103 #include "gdkwin32.h"
104
105 /* Define corresponding Windows types for some X11 types, just for laziness. */
106 typedef PALETTEENTRY XColor;
107
108 /* Define some of the X11 constants also here, again just for laziness */
109
110 /* Error codes */
111 #define Success            0
112
113 /* Grabbing status */
114 #define GrabSuccess        0
115 #define AlreadyGrabbed     2
116
117 /* Some structs are somewhat useful to emulate internally, just to
118  * keep the code less #ifdefed.
119  */
120 typedef struct {
121   HPALETTE palette;             /* Palette handle used when drawing. */
122   guint size;                   /* Number of entries in the palette. */
123   gboolean stale;               /* 1 if palette needs to be realized,
124                                  * otherwise 0. */
125   gboolean *in_use;
126   gboolean rc_palette;          /* If RC_PALETTE is on in the RASTERCAPS */
127   gulong sizepalette;           /* SIZEPALETTE if rc_palette */
128 } ColormapStruct, *Colormap;
129   
130 typedef struct {
131   gint map_entries;
132   guint visualid;
133   guint bitspixel;
134 } Visual;
135
136 typedef struct {
137   Colormap colormap;
138   unsigned long red_max;
139   unsigned long red_mult;
140   unsigned long green_max;
141   unsigned long green_mult;
142   unsigned long blue_max;
143   unsigned long blue_mult;
144   unsigned long base_pixel;
145 } XStandardColormap;
146
147 typedef struct _GdkGCWin32Data          GdkGCWin32Data;
148 typedef struct _GdkDrawableWin32Data    GdkDrawableWin32Data;
149 typedef struct _GdkWindowWin32Data      GdkWindowWin32Data;
150 typedef struct _GdkWin32PositionInfo    GdkWin32PositionInfo;
151 typedef struct _GdkColormapPrivateWin32 GdkColormapPrivateWin32;
152 typedef struct _GdkCursorPrivate        GdkCursorPrivate;
153 typedef struct _GdkWin32SingleFont      GdkWin32SingleFont;
154 typedef struct _GdkFontPrivateWin32     GdkFontPrivateWin32;
155 typedef struct _GdkImagePrivateWin32    GdkImagePrivateWin32;
156 typedef struct _GdkVisualPrivate        GdkVisualPrivate;
157 typedef struct _GdkRegionPrivate        GdkRegionPrivate;
158 typedef struct _GdkICPrivate            GdkICPrivate;
159
160 #define GDK_DRAWABLE_WIN32DATA(win) ((GdkDrawableWin32Data *)(((GdkDrawablePrivate*)(win))->klass_data))
161 #define GDK_WINDOW_WIN32DATA(win) ((GdkWindowWin32Data *)(((GdkDrawablePrivate*)(win))->klass_data))
162 #define GDK_GC_WIN32DATA(gc) ((GdkGCWin32Data *)(((GdkGCPrivate*)(gc))->klass_data))
163
164 struct _GdkGCWin32Data
165 {
166   GdkRegion *clip_region;
167
168   /* A Windows Device Context (DC) is not equivalent to an X11
169    * GC. We can use a DC only in the window for which it was
170    * allocated, or (in the case of a memory DC) with the bitmap that
171    * has been selected into it. Thus, we have to release and
172    * reallocate a DC each time the GdkGC is used to paint into a new
173    * window or pixmap. We thus keep all the necessary values in the
174    * GdkGCWin32Data struct.
175    */
176   HDC xgc;
177   HRGN hcliprgn;
178   GdkGCValuesMask values_mask;
179   gulong foreground;            /* Pixel values from GdkColor, */
180   gulong background;            /* not Win32 COLORREFs */
181   GdkFont *font;
182   gint rop2;
183   GdkFill fill_style;
184   GdkPixmap *tile;
185   GdkPixmap *stipple;
186   GdkSubwindowMode subwindow_mode;
187   gint graphics_exposures;
188   gint pen_width;
189   DWORD pen_style;
190   HANDLE hwnd;                  /* If a DC is allocated, for which window
191                                  * or what bitmap is selected into it
192                                  */
193   int saved_dc;
194 };
195
196 struct _GdkDrawableWin32Data
197 {
198   HANDLE xid;
199 };
200
201 struct _GdkWin32PositionInfo
202 {
203   gint x;
204   gint y;
205   gint width;
206   gint height;
207   gint x_offset;                /* Offsets to add to Win32 coordinates */
208   gint y_offset;                /* within window to get GDK coodinates */
209   gboolean big : 1;
210   gboolean mapped : 1;
211   gboolean no_bg : 1;           /* Set when the window background is 
212                                  * temporarily unset during resizing
213                                  * and scaling */
214   GdkRectangle clip_rect;       /* visible rectangle of window */
215 };
216
217 struct _GdkWindowWin32Data
218 {
219   GdkDrawableWin32Data drawable;
220
221   GdkWin32PositionInfo position_info;
222
223   /* We must keep the event mask here to filter them ourselves */
224   gint event_mask;
225
226   /* Values for bg_type */
227 #define GDK_WIN32_BG_NORMAL 0
228 #define GDK_WIN32_BG_PIXEL 1
229 #define GDK_WIN32_BG_PIXMAP 2
230 #define GDK_WIN32_BG_PARENT_RELATIVE 3
231 #define GDK_WIN32_BG_TRANSPARENT 4
232
233   /* We draw the background ourselves at WM_ERASEBKGND  */
234   guchar bg_type;
235   gulong bg_pixel;
236   GdkPixmap *bg_pixmap;
237
238   HCURSOR xcursor;
239
240   /* Window size hints */
241   gint hint_flags;
242   gint hint_x, hint_y;
243   gint hint_min_width, hint_min_height;
244   gint hint_max_width, hint_max_height;
245
246   gboolean extension_events_selected;
247
248   HKL input_locale;
249   CHARSETINFO charset_info;
250 };
251
252 struct _GdkCursorPrivate
253 {
254   GdkCursor cursor;
255   HCURSOR xcursor;
256 };
257
258 struct _GdkWin32SingleFont
259 {
260   HFONT xfont;
261   UINT charset;
262   UINT codepage;
263   FONTSIGNATURE fs;
264 };
265
266 struct _GdkFontPrivateWin32
267 {
268   GdkFontPrivate base;
269   GSList *fonts;                /* List of GdkWin32SingleFonts */
270   GSList *names;
271 };
272
273 struct _GdkVisualPrivate
274 {
275   GdkVisual visual;
276   Visual *xvisual;
277 };
278
279 struct _GdkColormapPrivateWin32
280 {
281   GdkColormapPrivate base;
282   Colormap xcolormap;
283   gint private_val;
284
285   GHashTable *hash;
286   GdkColorInfo *info;
287   DWORD last_sync_time;
288 };
289
290 struct _GdkImagePrivateWin32
291 {
292   GdkImagePrivate base;
293   HBITMAP ximage;
294 };
295
296 #define GDK_ROOT_WINDOW()             ((guint32) HWND_DESKTOP)
297 #define GDK_ROOT_PARENT()             ((GdkWindow *) gdk_parent_root)
298 #define GDK_DISPLAY()                 NULL
299 #define GDK_DRAWABLE_XID(win)         (GDK_DRAWABLE_WIN32DATA(win)->xid)
300 #define GDK_IMAGE_XIMAGE(image)       (((GdkImagePrivate *) image)->ximage)
301 #define GDK_COLORMAP_XDISPLAY(cmap)   NULL
302 #define GDK_COLORMAP_WIN32COLORMAP(cmap)(((GdkColormapPrivateWin32 *) cmap)->xcolormap)
303 #define GDK_VISUAL_XVISUAL(vis)       (((GdkVisualPrivate *) vis)->xvisual)
304
305 #define GDK_WINDOW_XWINDOW            GDK_DRAWABLE_XID
306 #define GDK_WINDOW_XDISPLAY           GDK_DRAWABLE_XDISPLAY
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 (guint32     anid);
313 GdkWindow    *gdk_window_foreign_new (guint32     anid);
314
315 /* Return the Gdk* for a particular HANDLE */
316 gpointer      gdk_xid_table_lookup     (HANDLE handle);
317
318 #endif /* __GDK_WIN32_H__ */