]> Pileus Git - ~andy/gtk/blob - gdk/win32/gdkprivate-win32.h
Use cairo_set_device_offset().
[~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 VK_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 some combinations of GdkDebugFlags */
192 #define GDK_DEBUG_EVENTS_OR_COLORMAP (GDK_DEBUG_EVENTS|GDK_DEBUG_COLORMAP)
193 #define GDK_DEBUG_EVENTS_OR_INPUT (GDK_DEBUG_EVENTS|GDK_DEBUG_INPUT)
194 #define GDK_DEBUG_PIXMAP_OR_COLORMAP (GDK_DEBUG_PIXMAP|GDK_DEBUG_COLORMAP)
195 #define GDK_DEBUG_MISC_OR_COLORMAP (GDK_DEBUG_MISC|GDK_DEBUG_COLORMAP)
196
197 #define GDK_TYPE_GC_WIN32              (_gdk_gc_win32_get_type ())
198 #define GDK_GC_WIN32(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_GC_WIN32, GdkGCWin32))
199 #define GDK_GC_WIN32_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_GC_WIN32, GdkGCWin32Class))
200 #define GDK_IS_GC_WIN32(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_GC_WIN32))
201 #define GDK_IS_GC_WIN32_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_GC_WIN32))
202 #define GDK_GC_WIN32_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_GC_WIN32, GdkGCWin32Class))
203
204 typedef struct _GdkColormapPrivateWin32 GdkColormapPrivateWin32;
205 typedef struct _GdkCursorPrivate        GdkCursorPrivate;
206 typedef struct _GdkWin32SingleFont      GdkWin32SingleFont;
207 typedef struct _GdkFontPrivateWin32     GdkFontPrivateWin32;
208 typedef struct _GdkGCWin32              GdkGCWin32;
209 typedef struct _GdkGCWin32Class         GdkGCWin32Class;
210
211 struct _GdkCursorPrivate
212 {
213   GdkCursor cursor;
214   HCURSOR hcursor;
215 };
216
217 struct _GdkWin32SingleFont
218 {
219   HFONT hfont;
220   UINT charset;
221   UINT codepage;
222   FONTSIGNATURE fs;
223 };
224
225 struct _GdkFontPrivateWin32
226 {
227   GdkFontPrivate base;
228   GSList *fonts;                /* List of GdkWin32SingleFonts */
229   GSList *names;
230 };
231
232 struct _GdkVisualClass
233 {
234   GObjectClass parent_class;
235 };
236
237 typedef enum {
238   GDK_WIN32_PE_STATIC,
239   GDK_WIN32_PE_AVAILABLE,
240   GDK_WIN32_PE_INUSE
241 } GdkWin32PalEntryState;
242
243 struct _GdkColormapPrivateWin32
244 {
245   HPALETTE hpal;
246   gint current_size;            /* Current size of hpal */
247   GdkWin32PalEntryState *use;
248   gint private_val;
249
250   GHashTable *hash;
251   GdkColorInfo *info;
252 };
253
254 struct _GdkGCWin32
255 {
256   GdkGC parent_instance;
257
258   /* A Windows Device Context (DC) is not equivalent to an X11
259    * GC. We can use a DC only in the window for which it was
260    * allocated, or (in the case of a memory DC) with the bitmap that
261    * has been selected into it. Thus, we have to release and
262    * reallocate a DC each time the GdkGC is used to paint into a new
263    * window or pixmap. We thus keep all the necessary values in the
264    * GdkGCWin32 object.
265    */
266
267   HRGN hcliprgn;
268
269   GdkGCValuesMask values_mask;
270
271   gulong foreground;            /* Pixel values from GdkColor, */
272   gulong background;            /* not Win32 COLORREFs */
273
274   GdkFont *font;
275   gint rop2;
276   GdkFill fill_style;
277   GdkPixmap *tile;
278   GdkPixmap *stipple;
279   GdkSubwindowMode subwindow_mode;
280   gint graphics_exposures;
281   gint pen_width;
282   DWORD pen_style;
283   DWORD *pen_dashes;            /* use for PS_USERSTYLE or step-by-step rendering */
284   gint pen_num_dashes;
285   gint pen_dash_offset;
286   gboolean pen_double_dash;
287   HBRUSH pen_hbrbg;
288
289   /* Following fields are valid while the GC exists as a Windows DC */
290   HDC hdc;
291   int saved_dc;
292
293   HPALETTE holdpal;
294 };
295
296 struct _GdkGCWin32Class
297 {
298   GdkGCClass parent_class;
299 };
300
301 GType _gdk_gc_win32_get_type (void);
302
303 gulong _gdk_win32_get_next_tick (gulong suggested_tick);
304
305 void _gdk_window_init_position     (GdkWindow *window);
306 void _gdk_window_move_resize_child (GdkWindow *window,
307                                     gint       x,
308                                     gint       y,
309                                     gint       width,
310                                     gint       height);
311 void _gdk_window_process_expose    (GdkWindow *window,
312                                     GdkRegion *invalidate_region);
313
314 void _gdk_win32_selection_init (void);
315 void _gdk_win32_dnd_exit (void);
316
317 void     gdk_win32_handle_table_insert  (HANDLE   *handle,
318                                          gpointer data);
319 void     gdk_win32_handle_table_remove  (HANDLE handle);
320
321 GdkGC    *_gdk_win32_gc_new             (GdkDrawable        *drawable,
322                                          GdkGCValues        *values,
323                                          GdkGCValuesMask     values_mask);
324
325 GdkImage *_gdk_win32_get_image          (GdkDrawable *drawable,
326                                          gint         x,
327                                          gint         y,
328                                          gint         width,
329                                          gint         height);
330
331 GdkImage *_gdk_win32_copy_to_image      (GdkDrawable *drawable,
332                                          GdkImage    *image,
333                                          gint         src_x,
334                                          gint         src_y,
335                                          gint         dest_x,
336                                          gint         dest_y,
337                                          gint         width,
338                                          gint         height);
339
340 void      _gdk_win32_blit               (gboolean              use_fg_bg,
341                                          GdkDrawableImplWin32 *drawable,
342                                          GdkGC                 *gc,
343                                          GdkDrawable           *src,
344                                          gint                   xsrc,
345                                          gint                   ysrc,
346                                          gint                   xdest,
347                                          gint                   ydest,
348                                          gint                   width,
349                                          gint                   height);
350
351 COLORREF  _gdk_win32_colormap_color     (GdkColormap *colormap,
352                                          gulong       pixel);
353
354 HRGN      _gdk_win32_bitmap_to_hrgn     (GdkPixmap   *bitmap);
355
356 HRGN      _gdk_win32_gdkregion_to_hrgn  (GdkRegion   *region,
357                                          gint         x_origin,
358                                          gint         y_origin);
359
360 void    _gdk_win32_adjust_client_rect   (GdkWindow *window,
361                                          RECT      *RECT);
362
363 void    _gdk_win32_get_adjusted_client_rect (GdkWindow *window,
364                                              RECT      *RECT);
365
366 void    _gdk_selection_property_delete (GdkWindow *);
367
368 void    _gdk_dropfiles_store (gchar *data);
369
370 void    _gdk_wchar_text_handle    (GdkFont       *font,
371                                    const wchar_t *wcstr,
372                                    int            wclen,
373                                    void         (*handler)(GdkWin32SingleFont *,
374                                                            const wchar_t *,
375                                                            int,
376                                                            void *),
377                                    void          *arg);
378
379 #ifdef G_ENABLE_DEBUG
380 gchar *_gdk_win32_color_to_string      (const GdkColor *color);
381 void   _gdk_win32_print_paletteentries (const PALETTEENTRY *pep,
382                                         const int           nentries);
383 void   _gdk_win32_print_system_palette (void);
384 void   _gdk_win32_print_hpalette       (HPALETTE     hpal);
385 void   _gdk_win32_print_dc             (HDC          hdc);
386
387 gchar *_gdk_win32_cap_style_to_string  (GdkCapStyle  cap_style);
388 gchar *_gdk_win32_fill_style_to_string (GdkFill      fill);
389 gchar *_gdk_win32_function_to_string   (GdkFunction  function);
390 gchar *_gdk_win32_join_style_to_string (GdkJoinStyle join_style);
391 gchar *_gdk_win32_line_style_to_string (GdkLineStyle line_style);
392 gchar *_gdk_win32_gcvalues_mask_to_string (GdkGCValuesMask mask);
393 gchar *_gdk_win32_window_state_to_string (GdkWindowState state);
394 gchar *_gdk_win32_drawable_description (GdkDrawable *d);
395
396 gchar *_gdk_win32_rop2_to_string       (int          rop2);
397 gchar *_gdk_win32_lbstyle_to_string    (UINT         brush_style);
398 gchar *_gdk_win32_pstype_to_string     (DWORD        pen_style);
399 gchar *_gdk_win32_psstyle_to_string    (DWORD        pen_style);
400 gchar *_gdk_win32_psendcap_to_string   (DWORD        pen_style);
401 gchar *_gdk_win32_psjoin_to_string     (DWORD        pen_style);
402 gchar *_gdk_win32_message_to_string    (UINT         msg);
403 gchar *_gdk_win32_key_to_string        (LONG         lParam);
404 gchar *_gdk_win32_rect_to_string       (const RECT  *rect);
405
406 gchar *_gdk_win32_gdkrectangle_to_string (const GdkRectangle *rect);
407 gchar *_gdk_win32_gdkregion_to_string    (const GdkRegion    *box);
408
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 #if defined(__GNUC__) && (__GNUC__ < 3)
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 /* These two macros call a GDI or other Win32 API and if the return
433  * value is zero or NULL, print a warning message. The majority of GDI
434  * calls return zero or NULL on failure. The value of the macros is nonzero
435  * if the call succeeded, zero otherwise.
436  */
437
438 #define GDI_CALL(api, arglist) (api arglist ? 1 : (WIN32_GDI_FAILED (#api), 0))
439 #define API_CALL(api, arglist) (api arglist ? 1 : (WIN32_API_FAILED (#api), 0))
440  
441 extern LRESULT CALLBACK _gdk_win32_window_procedure (HWND, UINT, WPARAM, LPARAM);
442
443 extern GdkWindow        *_gdk_root;
444
445 extern GdkDisplay       *_gdk_display;
446 extern GdkScreen        *_gdk_screen;
447
448 extern gint              _gdk_num_monitors;
449 extern GdkRectangle     *_gdk_monitors;
450
451 /* Offsets to add to Windows coordinates (which are relative to the
452  * primary monitor's origin, and thus might be negative for monitors
453  * to the left and/or above the primary monitor) to get GDK
454  * coordinates, which should be non-negative on the whole screen.
455  */
456 extern gint              _gdk_offset_x, _gdk_offset_y;
457
458 extern HDC               _gdk_display_hdc;
459 extern HINSTANCE         _gdk_dll_hinstance;
460 extern HINSTANCE         _gdk_app_hmodule;
461
462 /* These are thread specific, but GDK/win32 works OK only when invoked
463  * from a single thread anyway.
464  */
465 extern HKL               _gdk_input_locale;
466 extern gboolean          _gdk_input_locale_is_ime;
467 extern UINT              _gdk_input_codepage;
468
469 extern guint             _gdk_keymap_serial;
470 extern gboolean          _gdk_keyboard_has_altgr;
471
472 /* Registered clipboard formats */
473 extern WORD              _cf_rtf;
474 extern WORD              _cf_utf8_string;
475
476 /* GdkAtoms: Targets */
477 extern GdkAtom           _utf8_string;
478 extern GdkAtom           _compound_text;
479 extern GdkAtom           _text_uri_list;
480 extern GdkAtom           _targets;
481
482 /* DND selections */
483 extern GdkAtom           _local_dnd;
484 extern GdkAtom           _gdk_win32_dropfiles;
485 extern GdkAtom           _gdk_ole2_dnd;
486
487 extern GdkAtom           _gdk_selection_property;
488
489 extern GdkAtom           _wm_transient_for;
490
491 /* Options */
492 extern gboolean          _gdk_input_ignore_wintab;
493 extern gint              _gdk_max_colors;
494
495 #define GDK_WIN32_COLORMAP_DATA(cmap) ((GdkColormapPrivateWin32 *) GDK_COLORMAP (cmap)->windowing_data)
496
497 /* TRUE while a user-initiated window move or resize operation is in progress */
498 extern gboolean          _sizemove_in_progress;
499
500 /* TRUE when we are emptying the clipboard ourselves */
501 extern gboolean         _ignore_destroy_clipboard;
502
503 /* Initialization */
504 void _gdk_windowing_window_init (void);
505 void _gdk_root_window_size_init (void);
506 void _gdk_monitor_init(void);
507 void _gdk_visual_init (void);
508 void _gdk_dnd_init    (void);
509 void _gdk_windowing_image_init  (void);
510 void _gdk_events_init (void);
511 void _gdk_input_init  (GdkDisplay *display);
512
513 #endif /* __GDK_PRIVATE_WIN32_H__ */