]> Pileus Git - ~andy/gtk/blob - gdk/win32/gdkprivate-win32.h
75ebfb1a1c7b5f61c4ebcf83b4bec31185ab9188
[~andy/gtk] / gdk / win32 / gdkprivate-win32.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_PRIVATE_WIN32_H__
28 #define __GDK_PRIVATE_WIN32_H__
29
30 #define STRICT                  /* We want strict type checks */
31 #include <windows.h>
32 #include <commctrl.h>
33
34 /* Make up for some minor mingw32 lossage */
35
36 /* PS_JOIN_MASK is missing from the mingw32 headers */
37 #ifndef PS_JOIN_MASK
38 #define PS_JOIN_MASK (PS_JOIN_BEVEL|PS_JOIN_MITER|PS_JOIN_ROUND)
39 #endif
40
41 /* CLR_INVALID is missing */
42 #ifndef CLR_INVALID
43 #define CLR_INVALID CLR_NONE
44 #endif
45
46 /* Some charsets are missing */
47 #ifndef JOHAB_CHARSET
48 #define JOHAB_CHARSET 130
49 #endif
50 #ifndef VIETNAMESE_CHARSET
51 #define VIETNAMESE_CHARSET 163
52 #endif
53
54 #ifndef FS_VIETNAMESE
55 #define FS_VIETNAMESE 0x100
56 #endif
57
58 #ifndef VM_OEM_PLUS
59 #define VK_OEM_PLUS 0xBB
60 #endif
61
62 #include <time.h>
63
64 #include <gdk/gdktypes.h>
65 #include <gdk/gdkprivate.h>
66
67 #include <gdk/gdkcursor.h>
68 #include <gdk/gdkevents.h>
69 #include <gdk/gdkfont.h>
70 #include <gdk/gdkgc.h>
71 #include <gdk/gdkim.h>
72 #include <gdk/gdkimage.h>
73 #include <gdk/gdkvisual.h>
74 #include <gdk/gdkwindow.h>
75
76 #ifdef __cplusplus
77 extern "C" {
78 #endif /* __cplusplus */
79
80 /* Define corresponding Windows types for some X11 types, just for laziness.
81  */
82
83 typedef PALETTEENTRY XColor;
84 typedef guint VisualID;
85 typedef int Status;
86
87 /* Define some of the X11 constants also here, again just for laziness */
88
89 /* Generic null resource */
90 #define None 0
91
92 /* Error codes */
93 #define Success            0
94
95 /* Grabbing status */
96 #define GrabSuccess        0
97 #define AlreadyGrabbed     2
98
99 /* Some structs are somewhat useful to emulate internally, just to
100    keep the code less #ifdefed.  */
101 typedef struct {
102   HPALETTE palette;             /* Palette handle used when drawing. */
103   guint size;                   /* Number of entries in the palette. */
104   gboolean stale;               /* 1 if palette needs to be realized,
105                                  * otherwise 0. */
106   gboolean *in_use;
107   gboolean rc_palette;          /* If RC_PALETTE is on in the RASTERCAPS */
108   gulong sizepalette;           /* SIZEPALETTE if rc_palette */
109 } ColormapStruct, *Colormap;
110   
111 typedef struct {
112   gint map_entries;
113   guint visualid;
114   guint bitspixel;
115 } Visual;
116
117 typedef struct {
118   Colormap colormap;
119   unsigned long red_max;
120   unsigned long red_mult;
121   unsigned long green_max;
122   unsigned long green_mult;
123   unsigned long blue_max;
124   unsigned long blue_mult;
125   unsigned long base_pixel;
126 } XStandardColormap;
127
128 typedef struct _GdkGCWin32Data          GdkGCWin32Data;
129 typedef struct _GdkDrawableWin32Data    GdkDrawableWin32Data;
130 typedef struct _GdkWindowWin32Data      GdkWindowWin32Data;
131 typedef struct _GdkColormapPrivateWin32 GdkColormapPrivateWin32;
132 typedef struct _GdkCursorPrivate        GdkCursorPrivate;
133 typedef struct _GdkWin32SingleFont      GdkWin32SingleFont;
134 typedef struct _GdkFontPrivateWin32     GdkFontPrivateWin32;
135 typedef struct _GdkImagePrivateWin32    GdkImagePrivateWin32;
136 typedef struct _GdkVisualPrivate        GdkVisualPrivate;
137 typedef struct _GdkRegionPrivate        GdkRegionPrivate;
138 typedef struct _GdkICPrivate            GdkICPrivate;
139
140 #define GDK_DRAWABLE_WIN32DATA(win) ((GdkDrawableWin32Data *)(((GdkDrawablePrivate*)(win))->klass_data))
141 #define GDK_WINDOW_WIN32DATA(win) ((GdkWindowWin32Data *)(((GdkDrawablePrivate*)(win))->klass_data))
142 #define GDK_GC_WIN32DATA(gc) ((GdkGCWin32Data *)(((GdkGCPrivate*)(gc))->klass_data))
143
144 struct _GdkGCWin32Data
145 {
146   /* A Windows Device Context (DC) is not equivalent to an X11
147    * GC. We can use a DC only in the window for which it was
148    * allocated, or (in the case of a memory DC) with the bitmap that
149    * has been selected into it. Thus, we have to release and
150    * reallocate a DC each time the GdkGC is used to paint into a new
151    * window or pixmap. We thus keep all the necessary values in the
152    * GdkGCWin32Data struct.
153    */
154   HDC xgc;
155   GdkGCValuesMask values_mask;
156   gulong foreground;
157   gulong background;
158   GdkFont *font;
159   gint rop2;
160   GdkFill fill_style;
161   GdkPixmap *tile;
162   GdkPixmap *stipple;
163   HRGN clip_region;
164   GdkSubwindowMode subwindow_mode;
165   gint ts_x_origin;
166   gint ts_y_origin;
167   gint clip_x_origin;
168   gint clip_y_origin;
169   gint graphics_exposures;
170   gint pen_width;
171   DWORD pen_style;
172   HANDLE hwnd;                  /* If a DC is allocated, for which window
173                                  * or what bitmap is selected into it
174                                  */
175   int saved_dc;
176 };
177
178 struct _GdkDrawableWin32Data
179 {
180   HANDLE xid;
181 };
182
183 struct _GdkWindowWin32Data
184 {
185   GdkDrawableWin32Data drawable;
186
187   /* We must keep the event mask here to filter them ourselves */
188   gint event_mask;
189
190   /* Values for bg_type */
191 #define GDK_WIN32_BG_NORMAL 0
192 #define GDK_WIN32_BG_PIXEL 1
193 #define GDK_WIN32_BG_PIXMAP 2
194 #define GDK_WIN32_BG_PARENT_RELATIVE 3
195 #define GDK_WIN32_BG_TRANSPARENT 4
196
197   /* We draw the background ourselves at WM_ERASEBKGND  */
198   guchar bg_type;
199   GdkColor bg_pixel;
200   GdkPixmap *bg_pixmap;
201
202   HCURSOR xcursor;
203
204   /* Window size hints */
205   gint hint_flags;
206   gint hint_x, hint_y;
207   gint hint_min_width, hint_min_height;
208   gint hint_max_width, hint_max_height;
209
210   gboolean extension_events_selected;
211
212   HKL input_locale;
213   CHARSETINFO charset_info;
214 };
215
216 struct _GdkCursorPrivate
217 {
218   GdkCursor cursor;
219   HCURSOR xcursor;
220 };
221
222 struct _GdkWin32SingleFont
223 {
224   HFONT xfont;
225   UINT charset;
226   UINT codepage;
227   FONTSIGNATURE fs;
228 };
229
230 struct _GdkFontPrivateWin32
231 {
232   GdkFontPrivate base;
233   GSList *fonts;                /* List of GdkWin32SingleFonts */
234   GSList *names;
235 };
236
237 struct _GdkVisualPrivate
238 {
239   GdkVisual visual;
240   Visual *xvisual;
241 };
242
243 struct _GdkColormapPrivateWin32
244 {
245   GdkColormapPrivate base;
246   Colormap xcolormap;
247   gint private_val;
248
249   GHashTable *hash;
250   GdkColorInfo *info;
251   time_t last_sync_time;
252 };
253
254 struct _GdkImagePrivateWin32
255 {
256   GdkImagePrivate base;
257   HBITMAP ximage;
258 };
259
260 struct _GdkRegionPrivate
261 {
262   GdkRegion region;
263   HRGN xregion;
264 };
265
266 void gdk_win32_selection_init (void);
267 void gdk_win32_dnd_exit (void);
268
269 GdkColormap* gdk_colormap_lookup (Colormap  xcolormap);
270 GdkVisual*   gdk_visual_lookup   (Visual   *xvisual);
271
272 void     gdk_xid_table_insert    (HANDLE   *hnd,
273                                   gpointer data);
274 void     gdk_xid_table_remove    (HANDLE xid);
275 gpointer gdk_xid_table_lookup    (HANDLE xid);
276
277 GdkGC *  _gdk_win32_gc_new       (GdkDrawable        *drawable,
278                                   GdkGCValues        *values,
279                                   GdkGCValuesMask     values_mask);
280 HDC     gdk_gc_predraw           (GdkDrawable        *drawable,
281                                   GdkGCPrivate       *gc_private,
282                                   GdkGCValuesMask     usage);
283 void    gdk_gc_postdraw          (GdkDrawable        *drawable,
284                                   GdkGCPrivate       *gc_private,
285                                   GdkGCValuesMask     usage);
286 HRGN    BitmapToRegion           (HBITMAP hBmp);
287
288 void    gdk_sel_prop_store       (GdkWindow *owner,
289                                   GdkAtom    type,
290                                   gint       format,
291                                   guchar    *data,
292                                   gint       length);
293
294 gint gdk_nmbstowcs               (GdkWChar    *dest,
295                                   const gchar *src,
296                                   gint         src_len,
297                                   gint         dest_max);
298 gint gdk_nmbstowchar_ts          (wchar_t     *dest,
299                                   const gchar *src,
300                                   gint         src_len,
301                                   gint         dest_max);
302
303 void gdk_wchar_text_handle       (GdkFont       *font,
304                                   const wchar_t *wcstr,
305                                   int            wclen,
306                                   void         (*handler)(GdkWin32SingleFont *,
307                                                           const wchar_t *,
308                                                           int,
309                                                           void *),
310                                   void          *arg);
311
312 gchar *gdk_color_to_string         (const GdkColor *);
313 gchar *gdk_win32_last_error_string (void);
314 void   gdk_win32_api_failed        (const gchar *where,
315                                     gint line,
316                                     const gchar *api);
317 #ifdef __GNUC__
318 #define WIN32_API_FAILED(api) gdk_win32_api_failed (__PRETTY_FUNCTION__, __LINE__, api)
319 #else
320 #define WIN32_API_FAILED(api) gdk_win32_api_failed (__FILE__, __LINE__, api)
321 #endif
322  
323 extern LRESULT CALLBACK gdk_WindowProc (HWND, UINT, WPARAM, LPARAM);
324
325 extern GdkDrawableClass  _gdk_win32_drawable_class;
326 extern HWND              gdk_root_window;
327 GDKVAR ATOM              gdk_selection_property;
328 GDKVAR gchar            *gdk_progclass;
329 extern gboolean          gdk_event_func_from_window_proc;
330
331 extern HDC               gdk_DC;
332 extern HINSTANCE         gdk_DLLInstance;
333 extern HINSTANCE         gdk_ProgInstance;
334
335 extern UINT              gdk_selection_notify_msg;
336 extern UINT              gdk_selection_request_msg;
337 extern UINT              gdk_selection_clear_msg;
338 extern GdkAtom           gdk_clipboard_atom;
339 extern GdkAtom           gdk_win32_dropfiles_atom;
340 extern GdkAtom           gdk_ole2_dnd_atom;
341
342 extern DWORD             windows_version;
343
344 #ifdef __cplusplus
345 }
346 #endif /* __cplusplus */
347
348
349 #endif /* __GDK_PRIVATE_WIN32_H__ */