]> Pileus Git - ~andy/gtk/blob - gdk/win32/gdkprivate-win32.h
dac35be8d3c8d1b028714a17349fd6e3bb4c2527
[~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 Lesser 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  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser 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-2000.  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 #include <gdk/gdkprivate.h>
31 #include <gdk/win32/gdkwindow-win32.h>
32 #include <gdk/win32/gdkpixmap-win32.h>
33
34 #include "gdkinternals.h"
35
36 #include <config.h>
37
38 /* Make up for some minor w32api header lossage */
39
40 /* PS_JOIN_MASK is missing */
41 #ifndef PS_JOIN_MASK
42 #define PS_JOIN_MASK (PS_JOIN_BEVEL|PS_JOIN_MITER|PS_JOIN_ROUND)
43 #endif
44
45 /* CLR_INVALID is missing */
46 #ifndef CLR_INVALID
47 #define CLR_INVALID CLR_NONE
48 #endif
49
50 /* Some charsets are missing from MSVC 5 headers */
51 #ifndef JOHAB_CHARSET
52 #define JOHAB_CHARSET 130
53 #endif
54 #ifndef VIETNAMESE_CHARSET
55 #define VIETNAMESE_CHARSET 163
56 #endif
57
58 #ifndef FS_VIETNAMESE
59 #define FS_VIETNAMESE 0x100
60 #endif
61
62 /* Some virtual keycodes are missing */
63 #ifndef VM_OEM_PLUS
64 #define VK_OEM_PLUS 0xBB
65 #endif
66
67 #ifndef VK_OEM_COMMA
68 #define VK_OEM_COMMA 0xBC
69 #endif
70
71 #ifndef VK_OEM_MINUS
72 #define VK_OEM_MINUS 0xBD
73 #endif
74
75 #ifndef VK_OEM_PERIOD
76 #define VK_OEM_PERIOD 0xBE
77 #endif
78
79 #ifndef VK_OEM_1
80 #define VK_OEM_1 0xBA
81 #endif
82 #ifndef VK_OEM_2
83 #define VK_OEM_2 0xBF
84 #endif
85 #ifndef VK_OEM_3
86 #define VK_OEM_3 0xC0
87 #endif
88 #ifndef VK_OEM_4
89 #define VK_OEM_4 0xDB
90 #endif
91 #ifndef VK_OEM_5
92 #define VK_OEM_5 0xDC
93 #endif
94 #ifndef VK_OEM_6
95 #define VK_OEM_6 0xDD
96 #endif
97 #ifndef VK_OEM_7
98 #define VK_OEM_7 0xDE
99 #endif
100 #ifndef VK_OEM_8
101 #define VK_OEM_8 0xDF
102 #endif
103
104 /* Missing messages */
105 #ifndef WM_SYNCPAINT
106 #define WM_SYNCPAINT 0x88
107 #endif
108 #ifndef WM_MOUSEWHEEL
109 #define WM_MOUSEWHEEL 0X20A
110 #endif
111 #ifndef WM_GETOBJECT
112 #define WM_GETOBJECT 0x3D
113 #endif
114 #ifndef WM_NCXBUTTONDOWN
115 #define WM_NCXBUTTONDOWN 0xAB
116 #endif
117 #ifndef WM_NCXBUTTONUP
118 #define WM_NCXBUTTONUP 0xAC
119 #endif
120 #ifndef WM_NCXBUTTONDBLCLK
121 #define WM_NCXBUTTONDBLCLK 0xAD
122 #endif
123 #ifndef WM_MENURBUTTONUP
124 #define WM_MENURBUTTONUP 0x122
125 #endif
126 #ifndef WM_MENUDRAG
127 #define WM_MENUDRAG 0x123
128 #endif
129 #ifndef WM_MENUGETOBJECT
130 #define WM_MENUGETOBJECT 0x124
131 #endif
132 #ifndef WM_UNINITMENUPOPUP
133 #define WM_UNINITMENUPOPUP 0x125
134 #endif
135 #ifndef WM_MENUCOMMAND
136 #define WM_MENUCOMMAND 0x126
137 #endif
138 #ifndef WM_CHANGEUISTATE
139 #define WM_CHANGEUISTATE 0x127
140 #endif
141 #ifndef WM_UPDATEUISTATE
142 #define WM_UPDATEUISTATE 0x128
143 #endif
144 #ifndef WM_QUERYUISTATE
145 #define WM_QUERYUISTATE 0x129
146 #endif
147 #ifndef WM_XBUTTONDOWN
148 #define WM_XBUTTONDOWN 0x20B
149 #endif
150 #ifndef WM_XBUTTONUP
151 #define WM_XBUTTONUP 0x20C
152 #endif
153 #ifndef WM_XBUTTONDBLCLK
154 #define WM_XBUTTONDBLCLK 0x20D
155 #endif
156 #ifndef WM_IME_REQUEST
157 #define WM_IME_REQUEST 0x288
158 #endif
159 #ifndef WM_MOUSEHOVER
160 #define WM_MOUSEHOVER 0x2A1
161 #endif
162 #ifndef WM_MOUSELEAVE
163 #define WM_MOUSELEAVE 0x2A3
164 #endif
165 #ifndef WM_NCMOUSEHOVER
166 #define WM_NCMOUSEHOVER 0x2A0
167 #endif
168 #ifndef WM_NCMOUSELEAVE
169 #define WM_NCMOUSELEAVE 0x2A2
170 #endif
171 #ifndef WM_APPCOMMAND
172 #define WM_APPCOMMAND 0x319
173 #endif
174 #ifndef WM_HANDHELDFIRST
175 #define WM_HANDHELDFIRST 0x358
176 #endif
177 #ifndef WM_HANDHELDLAST
178 #define WM_HANDHELDLAST 0x35F
179 #endif
180 #ifndef WM_AFXFIRST
181 #define WM_AFXFIRST 0x360
182 #endif
183 #ifndef WM_AFXLAST
184 #define WM_AFXLAST 0x37F
185 #endif
186
187 #ifndef CopyCursor
188 #define CopyCursor(pcur) ((HCURSOR)CopyIcon((HICON)(pcur)))
189 #endif
190
191 /* Define corresponding Windows types for some X11 types, just for laziness. */
192 typedef PALETTEENTRY XColor;
193
194 /* Some structs are somewhat useful to emulate internally. */
195 typedef struct {
196   HPALETTE palette;             /* Palette handle used when drawing. */
197   guint size;                   /* Number of entries in the palette. */
198   gboolean stale;               /* 1 if palette needs to be realized,
199                                  * otherwise 0. */
200   gboolean *in_use;
201   gboolean rc_palette;          /* If RC_PALETTE is on in the RASTERCAPS */
202   gulong sizepalette;           /* SIZEPALETTE if rc_palette */
203 } ColormapStruct, *Colormap;
204   
205 typedef struct {
206   gint map_entries;
207   guint visualid;
208   guint bitspixel;
209 } Visual;
210
211 typedef struct {
212   Colormap colormap;
213   unsigned long red_max;
214   unsigned long red_mult;
215   unsigned long green_max;
216   unsigned long green_mult;
217   unsigned long blue_max;
218   unsigned long blue_mult;
219   unsigned long base_pixel;
220 } XStandardColormap;
221
222 #define GDK_TYPE_GC_WIN32              (_gdk_gc_win32_get_type ())
223 #define GDK_GC_WIN32(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_GC_WIN32, GdkGCWin32))
224 #define GDK_GC_WIN32_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_GC_WIN32, GdkGCWin32Class))
225 #define GDK_IS_GC_WIN32(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_GC_WIN32))
226 #define GDK_IS_GC_WIN32_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_GC_WIN32))
227 #define GDK_GC_WIN32_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_GC_WIN32, GdkGCWin32Class))
228
229 typedef struct _GdkColormapPrivateWin32 GdkColormapPrivateWin32;
230 typedef struct _GdkCursorPrivate        GdkCursorPrivate;
231 typedef struct _GdkWin32SingleFont      GdkWin32SingleFont;
232 typedef struct _GdkFontPrivateWin32     GdkFontPrivateWin32;
233 typedef struct _GdkImagePrivateWin32    GdkImagePrivateWin32;
234 typedef struct _GdkVisualPrivate        GdkVisualPrivate;
235 typedef struct _GdkGCWin32      GdkGCWin32;
236 typedef struct _GdkGCWin32Class GdkGCWin32Class;
237
238 struct _GdkCursorPrivate
239 {
240   GdkCursor cursor;
241   HCURSOR hcursor;
242 };
243
244 struct _GdkWin32SingleFont
245 {
246   HFONT hfont;
247   UINT charset;
248   UINT codepage;
249   FONTSIGNATURE fs;
250 };
251
252 struct _GdkFontPrivateWin32
253 {
254   GdkFontPrivate base;
255   GSList *fonts;                /* List of GdkWin32SingleFonts */
256   GSList *names;
257 };
258
259 struct _GdkVisualClass
260 {
261   GObjectClass parent_class;
262 };
263
264 struct _GdkVisualPrivate
265 {
266   GdkVisual visual;
267   Visual *xvisual;
268 };
269
270 struct _GdkColormapPrivateWin32
271 {
272   Colormap xcolormap;
273   gint private_val;
274
275   GHashTable *hash;
276   GdkColorInfo *info;
277   DWORD last_sync_time;
278 };
279
280 struct _GdkImagePrivateWin32
281 {
282   HBITMAP hbitmap;
283 };
284
285 struct _GdkGCWin32
286 {
287   GdkGC parent_instance;
288
289   /* A Windows Device Context (DC) is not equivalent to an X11
290    * GC. We can use a DC only in the window for which it was
291    * allocated, or (in the case of a memory DC) with the bitmap that
292    * has been selected into it. Thus, we have to release and
293    * reallocate a DC each time the GdkGC is used to paint into a new
294    * window or pixmap. We thus keep all the necessary values in the
295    * GdkGCWin32 object.
296    */
297   HDC hdc;
298
299   GdkRegion *clip_region;
300   HRGN hcliprgn;
301
302   GdkGCValuesMask values_mask;
303
304   gulong foreground;            /* Pixel values from GdkColor, */
305   gulong background;            /* not Win32 COLORREFs */
306
307   GdkFont *font;
308   gint rop2;
309   GdkFill fill_style;
310   GdkPixmap *tile;
311   GdkPixmap *stipple;
312   GdkSubwindowMode subwindow_mode;
313   gint graphics_exposures;
314   gint pen_width;
315   DWORD pen_style;
316   HANDLE hwnd;                  /* If a HDC is allocated, for which window,
317                                  * or what bitmap is selected into it
318                                  */
319   int saved_dc;
320 };
321
322 struct _GdkGCWin32Class
323 {
324   GdkGCClass parent_class;
325 };
326
327 GType _gdk_gc_win32_get_type (void);
328
329 /* Routines from gdkgeometry-win32.c */
330 void
331 _gdk_window_init_position (GdkWindow *window);
332 void
333 _gdk_window_move_resize_child (GdkWindow *window,
334                                gint       x,
335                                gint       y,
336                                gint       width,
337                                gint       height);
338 void _gdk_window_process_expose    (GdkWindow     *window,
339                                     gulong         serial,
340                                     GdkRectangle  *area);
341
342 /* gdkdrawable-win32.c, background draw helper */
343 void _gdk_win32_draw_tiles (GdkDrawable *drawable,
344                             GdkGC       *gc,
345                             GdkPixmap   *tile,
346                             gint        x, 
347                             gint        y, 
348                             gint        width, 
349                             gint        height);
350
351 void _gdk_win32_selection_init (void);
352 void _gdk_win32_dnd_exit (void);
353
354 void     gdk_win32_handle_table_insert    (HANDLE   *handle,
355                                            gpointer data);
356 void     gdk_win32_handle_table_remove    (HANDLE handle);
357
358 GdkGC *  _gdk_win32_gc_new       (GdkDrawable        *drawable,
359                                   GdkGCValues        *values,
360                                   GdkGCValuesMask     values_mask);
361
362 GdkImage* _gdk_win32_get_image (GdkDrawable    *drawable,
363                                 gint            x,
364                                 gint            y,
365                                 gint            width,
366                                 gint            height);
367
368 COLORREF _gdk_win32_colormap_color      (GdkColormap        *colormap,
369                                           gulong              pixel);
370
371 HRGN     BitmapToRegion          (HBITMAP hBmp);
372
373 gchar  *gdk_font_full_name_get   (GdkFont *font);
374
375 void    _gdk_selection_property_store (GdkWindow *owner,
376                                        GdkAtom    type,
377                                        gint       format,
378                                        guchar    *data,
379                                        gint       length);
380
381 void    _gdk_selection_property_delete (GdkWindow *);
382
383 gint    _gdk_win32_nmbstowchar_ts (wchar_t     *dest,
384                                    const gchar *src,
385                                    gint         src_len,
386                                    gint         dest_max);
387
388 void    _gdk_wchar_text_handle    (GdkFont       *font,
389                                    const wchar_t *wcstr,
390                                    int            wclen,
391                                    void         (*handler)(GdkWin32SingleFont *,
392                                                            const wchar_t *,
393                                                            int,
394                                                            void *),
395                                    void          *arg);
396
397 #ifdef G_ENABLE_DEBUG
398 gchar *gdk_win32_color_to_string      (const        GdkColor *color);
399 gchar *gdk_win32_cap_style_to_string  (GdkCapStyle  cap_style);
400 gchar *gdk_win32_fill_style_to_string (GdkFill      fill);
401 gchar *gdk_win32_function_to_string   (GdkFunction  function);
402 gchar *gdk_win32_join_style_to_string (GdkJoinStyle join_style);
403 gchar *gdk_win32_line_style_to_string (GdkLineStyle line_style);
404 gchar *gdk_win32_message_name         (UINT         msg);
405
406 #define PING() printf(G_STRLOC),fflush(stdout)
407 #else
408 #define PING()
409 #endif
410
411 gchar  *gdk_win32_last_error_string (void);
412 void    gdk_win32_api_failed        (const gchar *where,
413                                      gint line,
414                                      const gchar *api);
415 void    gdk_other_api_failed        (const gchar *where,
416                                      gint line,
417                                      const gchar *api);
418 void    gdk_win32_gdi_failed        (const gchar *where,
419                                      gint line,
420                                      const gchar *api);
421
422 #ifdef __GNUC__
423 #define WIN32_API_FAILED(api) gdk_win32_api_failed (__FILE__ ":" __PRETTY_FUNCTION__, __LINE__, api)
424 #define WIN32_GDI_FAILED(api) gdk_win32_gdi_failed (__FILE__ ":" __PRETTY_FUNCTION__, __LINE__, api)
425 #define OTHER_API_FAILED(api) gdk_other_api_failed (__FILE__ ":" __PRETTY_FUNCTION__, __LINE__, api)
426 #else
427 #define WIN32_API_FAILED(api) gdk_win32_api_failed (__FILE__, __LINE__, api)
428 #define WIN32_GDI_FAILED(api) gdk_win32_gdi_failed (__FILE__, __LINE__, api)
429 #define OTHER_API_FAILED(api) gdk_other_api_failed (__FILE__, __LINE__, api)
430 #endif
431  
432 extern LRESULT CALLBACK _gdk_win32_window_procedure (HWND, UINT, WPARAM, LPARAM);
433
434 extern HWND              gdk_root_window;
435 extern gboolean          gdk_event_func_from_window_proc;
436
437 extern HDC               gdk_display_hdc;
438 extern HINSTANCE         gdk_dll_hinstance;
439 extern HINSTANCE         gdk_app_hmodule;
440
441 extern UINT              gdk_selection_notify_msg;
442 extern UINT              gdk_selection_request_msg;
443 extern UINT              gdk_selection_clear_msg;
444 extern GdkAtom           gdk_clipboard_atom;
445 extern GdkAtom           gdk_win32_dropfiles_atom;
446 extern GdkAtom           gdk_ole2_dnd_atom;
447
448 extern DWORD             windows_version;
449 #define IS_WIN_NT()      (windows_version < 0x80000000)
450
451 extern gint              gdk_input_ignore_wintab;
452
453 extern GdkAtom           _gdk_selection_property;
454
455 #define IMAGE_PRIVATE_DATA(image) ((GdkImagePrivateWin32 *) GDK_IMAGE (image)->windowing_data)
456
457 #endif /* __GDK_PRIVATE_WIN32_H__ */