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