1 /* GDK - The GIMP Drawing Kit
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
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.
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.
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.
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/.
27 #ifndef __GDK_PRIVATE_WIN32_H__
28 #define __GDK_PRIVATE_WIN32_H__
30 #include <gdk/gdkprivate.h>
31 #include <gdk/win32/gdkwindow-win32.h>
32 #include <gdk/win32/gdkpixmap-win32.h>
34 #include "gdkinternals.h"
38 /* Make up for some minor w32api header lossage */
40 /* PS_JOIN_MASK is missing */
42 #define PS_JOIN_MASK (PS_JOIN_BEVEL|PS_JOIN_MITER|PS_JOIN_ROUND)
45 /* CLR_INVALID is missing */
47 #define CLR_INVALID CLR_NONE
50 /* Some charsets are missing from MSVC 5 headers */
52 #define JOHAB_CHARSET 130
54 #ifndef VIETNAMESE_CHARSET
55 #define VIETNAMESE_CHARSET 163
59 #define FS_VIETNAMESE 0x100
62 /* Some virtual keycodes are missing */
64 #define VK_OEM_PLUS 0xBB
68 #define VK_OEM_COMMA 0xBC
72 #define VK_OEM_MINUS 0xBD
76 #define VK_OEM_PERIOD 0xBE
101 #define VK_OEM_8 0xDF
104 /* Missing messages */
106 #define WM_SYNCPAINT 0x88
108 #ifndef WM_MOUSEWHEEL
109 #define WM_MOUSEWHEEL 0X20A
112 #define WM_GETOBJECT 0x3D
114 #ifndef WM_NCXBUTTONDOWN
115 #define WM_NCXBUTTONDOWN 0xAB
117 #ifndef WM_NCXBUTTONUP
118 #define WM_NCXBUTTONUP 0xAC
120 #ifndef WM_NCXBUTTONDBLCLK
121 #define WM_NCXBUTTONDBLCLK 0xAD
123 #ifndef WM_MENURBUTTONUP
124 #define WM_MENURBUTTONUP 0x122
127 #define WM_MENUDRAG 0x123
129 #ifndef WM_MENUGETOBJECT
130 #define WM_MENUGETOBJECT 0x124
132 #ifndef WM_UNINITMENUPOPUP
133 #define WM_UNINITMENUPOPUP 0x125
135 #ifndef WM_MENUCOMMAND
136 #define WM_MENUCOMMAND 0x126
138 #ifndef WM_CHANGEUISTATE
139 #define WM_CHANGEUISTATE 0x127
141 #ifndef WM_UPDATEUISTATE
142 #define WM_UPDATEUISTATE 0x128
144 #ifndef WM_QUERYUISTATE
145 #define WM_QUERYUISTATE 0x129
147 #ifndef WM_XBUTTONDOWN
148 #define WM_XBUTTONDOWN 0x20B
151 #define WM_XBUTTONUP 0x20C
153 #ifndef WM_XBUTTONDBLCLK
154 #define WM_XBUTTONDBLCLK 0x20D
156 #ifndef WM_IME_REQUEST
157 #define WM_IME_REQUEST 0x288
159 #ifndef WM_MOUSEHOVER
160 #define WM_MOUSEHOVER 0x2A1
162 #ifndef WM_MOUSELEAVE
163 #define WM_MOUSELEAVE 0x2A3
165 #ifndef WM_NCMOUSEHOVER
166 #define WM_NCMOUSEHOVER 0x2A0
168 #ifndef WM_NCMOUSELEAVE
169 #define WM_NCMOUSELEAVE 0x2A2
171 #ifndef WM_APPCOMMAND
172 #define WM_APPCOMMAND 0x319
174 #ifndef WM_HANDHELDFIRST
175 #define WM_HANDHELDFIRST 0x358
177 #ifndef WM_HANDHELDLAST
178 #define WM_HANDHELDLAST 0x35F
181 #define WM_AFXFIRST 0x360
184 #define WM_AFXLAST 0x37F
188 #define CopyCursor(pcur) ((HCURSOR)CopyIcon((HICON)(pcur)))
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)
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))
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;
211 struct _GdkCursorPrivate
217 struct _GdkWin32SingleFont
225 struct _GdkFontPrivateWin32
228 GSList *fonts; /* List of GdkWin32SingleFonts */
232 struct _GdkVisualClass
234 GObjectClass parent_class;
239 GDK_WIN32_PE_AVAILABLE,
241 } GdkWin32PalEntryState;
243 struct _GdkColormapPrivateWin32
246 gint current_size; /* Current size of hpal */
247 GdkWin32PalEntryState *use;
256 GdkGC parent_instance;
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
269 GdkGCValuesMask values_mask;
271 gulong foreground; /* Pixel values from GdkColor, */
272 gulong background; /* not Win32 COLORREFs */
279 GdkSubwindowMode subwindow_mode;
280 gint graphics_exposures;
283 DWORD *pen_dashes; /* use for PS_USERSTYLE or step-by-step rendering */
285 gint pen_dash_offset;
286 gboolean pen_double_dash;
289 /* Following fields are valid while the GC exists as a Windows DC */
293 HANDLE hwnd; /* For which window, or what bitmap is
299 struct _GdkGCWin32Class
301 GdkGCClass parent_class;
304 GType _gdk_gc_win32_get_type (void);
306 gulong _gdk_win32_get_next_tick (gulong suggested_tick);
308 void _gdk_window_init_position (GdkWindow *window);
309 void _gdk_window_move_resize_child (GdkWindow *window,
314 void _gdk_window_process_expose (GdkWindow *window,
315 GdkRegion *invalidate_region);
317 void _gdk_win32_selection_init (void);
318 void _gdk_win32_dnd_exit (void);
320 void gdk_win32_handle_table_insert (HANDLE *handle,
322 void gdk_win32_handle_table_remove (HANDLE handle);
324 GdkGC *_gdk_win32_gc_new (GdkDrawable *drawable,
326 GdkGCValuesMask values_mask);
328 GdkImage *_gdk_win32_get_image (GdkDrawable *drawable,
334 GdkImage *_gdk_win32_copy_to_image (GdkDrawable *drawable,
343 void _gdk_win32_blit (gboolean use_fg_bg,
344 GdkDrawableImplWin32 *drawable,
354 COLORREF _gdk_win32_colormap_color (GdkColormap *colormap,
357 HRGN _gdk_win32_bitmap_to_hrgn (GdkPixmap *bitmap);
359 HRGN _gdk_win32_gdkregion_to_hrgn (GdkRegion *region,
363 void _gdk_win32_adjust_client_rect (GdkWindow *window,
366 void _gdk_win32_get_adjusted_client_rect (GdkWindow *window,
369 void _gdk_selection_property_delete (GdkWindow *);
371 void _gdk_dropfiles_store (gchar *data);
373 void _gdk_wchar_text_handle (GdkFont *font,
374 const wchar_t *wcstr,
376 void (*handler)(GdkWin32SingleFont *,
382 #ifdef G_ENABLE_DEBUG
383 gchar *_gdk_win32_color_to_string (const GdkColor *color);
384 void _gdk_win32_print_paletteentries (const PALETTEENTRY *pep,
386 void _gdk_win32_print_system_palette (void);
387 void _gdk_win32_print_hpalette (HPALETTE hpal);
388 void _gdk_win32_print_dc (HDC hdc);
390 gchar *_gdk_win32_cap_style_to_string (GdkCapStyle cap_style);
391 gchar *_gdk_win32_fill_style_to_string (GdkFill fill);
392 gchar *_gdk_win32_function_to_string (GdkFunction function);
393 gchar *_gdk_win32_join_style_to_string (GdkJoinStyle join_style);
394 gchar *_gdk_win32_line_style_to_string (GdkLineStyle line_style);
395 gchar *_gdk_win32_gcvalues_mask_to_string (GdkGCValuesMask mask);
396 gchar *_gdk_win32_window_state_to_string (GdkWindowState state);
397 gchar *_gdk_win32_drawable_description (GdkDrawable *d);
399 gchar *_gdk_win32_rop2_to_string (int rop2);
400 gchar *_gdk_win32_lbstyle_to_string (UINT brush_style);
401 gchar *_gdk_win32_pstype_to_string (DWORD pen_style);
402 gchar *_gdk_win32_psstyle_to_string (DWORD pen_style);
403 gchar *_gdk_win32_psendcap_to_string (DWORD pen_style);
404 gchar *_gdk_win32_psjoin_to_string (DWORD pen_style);
405 gchar *_gdk_win32_message_to_string (UINT msg);
406 gchar *_gdk_win32_key_to_string (LONG lParam);
407 gchar *_gdk_win32_rect_to_string (const RECT *rect);
409 gchar *_gdk_win32_gdkrectangle_to_string (const GdkRectangle *rect);
410 gchar *_gdk_win32_gdkregion_to_string (const GdkRegion *box);
414 gchar *_gdk_win32_last_error_string (void);
415 void _gdk_win32_api_failed (const gchar *where,
418 void _gdk_other_api_failed (const gchar *where,
421 void _gdk_win32_gdi_failed (const gchar *where,
425 #if defined(__GNUC__) && (__GNUC__ < 3)
426 #define WIN32_API_FAILED(api) _gdk_win32_api_failed (__FILE__ ":" __PRETTY_FUNCTION__, __LINE__, api)
427 #define WIN32_GDI_FAILED(api) _gdk_win32_gdi_failed (__FILE__ ":" __PRETTY_FUNCTION__, __LINE__, api)
428 #define OTHER_API_FAILED(api) _gdk_other_api_failed (__FILE__ ":" __PRETTY_FUNCTION__, __LINE__, api)
430 #define WIN32_API_FAILED(api) _gdk_win32_api_failed (__FILE__, __LINE__, api)
431 #define WIN32_GDI_FAILED(api) _gdk_win32_gdi_failed (__FILE__, __LINE__, api)
432 #define OTHER_API_FAILED(api) _gdk_other_api_failed (__FILE__, __LINE__, api)
435 /* These two macros call a GDI or other Win32 API and if the return
436 * value is zero or NULL, print a warning message. The majority of GDI
437 * calls return zero or NULL on failure. The value of the macros is nonzero
438 * if the call succeeded, zero otherwise.
441 #define GDI_CALL(api, arglist) (api arglist ? 1 : (WIN32_GDI_FAILED (#api), 0))
442 #define API_CALL(api, arglist) (api arglist ? 1 : (WIN32_API_FAILED (#api), 0))
444 extern LRESULT CALLBACK _gdk_win32_window_procedure (HWND, UINT, WPARAM, LPARAM);
446 extern HWND _gdk_root_window;
447 extern GdkWindow *_gdk_parent_root;
449 extern GdkDisplay *_gdk_display;
450 extern GdkScreen *_gdk_screen;
452 extern gint _gdk_num_monitors;
453 extern GdkRectangle *_gdk_monitors;
455 /* Offsets to add to Windows coordinates (which are relative to the
456 * primary monitor's origin, and thus might be negative for monitors
457 * to the left and/or above the primary monitor) to get GDK
458 * coordinates, which should be non-negative on the whole screen.
460 extern gint _gdk_offset_x, _gdk_offset_y;
462 extern HDC _gdk_display_hdc;
463 extern HINSTANCE _gdk_dll_hinstance;
464 extern HINSTANCE _gdk_app_hmodule;
466 /* These are thread specific, but GDK/win32 works OK only when invoked
467 * from a single thread anyway.
469 extern HKL _gdk_input_locale;
470 extern gboolean _gdk_input_locale_is_ime;
471 extern UINT _gdk_input_codepage;
473 extern guint _gdk_keymap_serial;
474 extern gboolean _gdk_keyboard_has_altgr;
476 /* Registered clipboard formats */
478 extern WORD _cf_utf8_string;
480 /* GdkAtoms: Targets */
481 extern GdkAtom _utf8_string;
482 extern GdkAtom _compound_text;
483 extern GdkAtom _text_uri_list;
484 extern GdkAtom _targets;
487 extern GdkAtom _local_dnd;
488 extern GdkAtom _gdk_win32_dropfiles;
489 extern GdkAtom _gdk_ole2_dnd;
491 extern GdkAtom _gdk_selection_property;
493 extern GdkAtom _wm_transient_for;
496 extern gboolean _gdk_input_ignore_wintab;
497 extern gint _gdk_max_colors;
499 #define GDK_WIN32_COLORMAP_DATA(cmap) ((GdkColormapPrivateWin32 *) GDK_COLORMAP (cmap)->windowing_data)
501 /* TRUE while a user-initiated window move or resize operation is in progress */
502 extern gboolean _sizemove_in_progress;
504 /* TRUE when we are emptying the clipboard ourselves */
505 extern gboolean _ignore_destroy_clipboard;
508 void _gdk_windowing_window_init (void);
509 void _gdk_root_window_size_init (void);
510 void _gdk_monitor_init(void);
511 void _gdk_visual_init (void);
512 void _gdk_dnd_init (void);
513 void _gdk_windowing_image_init (void);
514 void _gdk_events_init (void);
515 void _gdk_input_init (GdkDisplay *display);
517 #endif /* __GDK_PRIVATE_WIN32_H__ */