Debian Codegraph @

gdk/win32/gdkprivate-win32.h

raw
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 #ifndef WINVER
31 #define WINVER 0x0500
32 #endif
33
34 #ifndef _WIN32_WINNT
35 #define _WIN32_WINNT WINVER
36 #endif
37
38 #include <gdk/gdkprivate.h>
39 #include <gdk/win32/gdkwindow-win32.h>
40 #include <gdk/win32/gdkpixmap-win32.h>
41 #include <gdk/win32/gdkwin32keys.h>
42
43 #include "gdkinternals.h"
44
45 #include "config.h"
46
47 /* Make up for some minor w32api or MSVC6 header lossage */
48
49 #ifndef PS_JOIN_MASK
50 #define PS_JOIN_MASK (PS_JOIN_BEVEL|PS_JOIN_MITER|PS_JOIN_ROUND)
51 #endif
52
53 #ifndef FS_VIETNAMESE
54 #define FS_VIETNAMESE 0x100
55 #endif
56
57 #ifndef WM_GETOBJECT
58 #define WM_GETOBJECT 0x3D
59 #endif
60 #ifndef WM_NCXBUTTONDOWN
61 #define WM_NCXBUTTONDOWN 0xAB
62 #endif
63 #ifndef WM_NCXBUTTONUP
64 #define WM_NCXBUTTONUP 0xAC
65 #endif
66 #ifndef WM_NCXBUTTONDBLCLK
67 #define WM_NCXBUTTONDBLCLK 0xAD
68 #endif
69 #ifndef WM_CHANGEUISTATE
70 #define WM_CHANGEUISTATE 0x127
71 #endif
72 #ifndef WM_UPDATEUISTATE
73 #define WM_UPDATEUISTATE 0x128
74 #endif
75 #ifndef WM_QUERYUISTATE
76 #define WM_QUERYUISTATE 0x129
77 #endif
78 #ifndef WM_XBUTTONDOWN
79 #define WM_XBUTTONDOWN 0x20B
80 #endif
81 #ifndef WM_XBUTTONUP
82 #define WM_XBUTTONUP 0x20C
83 #endif
84 #ifndef WM_XBUTTONDBLCLK
85 #define WM_XBUTTONDBLCLK 0x20D
86 #endif
87 #ifndef WM_NCMOUSEHOVER
88 #define WM_NCMOUSEHOVER 0x2A0
89 #endif
90 #ifndef WM_NCMOUSELEAVE
91 #define WM_NCMOUSELEAVE 0x2A2
92 #endif
93 #ifndef WM_APPCOMMAND
94 #define WM_APPCOMMAND 0x319
95 #endif
96 #ifndef WM_MOUSEHWHEEL
97 #define WM_MOUSEHWHEEL 0x20E
98 #endif
99
100 #ifndef CF_DIBV5
101 #define CF_DIBV5 17
102 #endif
103
104
105 /* Define some combinations of GdkDebugFlags */
106 #define GDK_DEBUG_EVENTS_OR_COLORMAP (GDK_DEBUG_EVENTS|GDK_DEBUG_COLORMAP)
107 #define GDK_DEBUG_EVENTS_OR_INPUT (GDK_DEBUG_EVENTS|GDK_DEBUG_INPUT)
108 #define GDK_DEBUG_PIXMAP_OR_COLORMAP (GDK_DEBUG_PIXMAP|GDK_DEBUG_COLORMAP)
109 #define GDK_DEBUG_MISC_OR_COLORMAP (GDK_DEBUG_MISC|GDK_DEBUG_COLORMAP)
110 #define GDK_DEBUG_MISC_OR_EVENTS (GDK_DEBUG_MISC|GDK_DEBUG_EVENTS)
111
112 #define GDK_TYPE_GC_WIN32 (_gdk_gc_win32_get_type ())
113 #define GDK_GC_WIN32(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_GC_WIN32, GdkGCWin32))
114 #define GDK_GC_WIN32_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_GC_WIN32, GdkGCWin32Class))
115 #define GDK_IS_GC_WIN32(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_GC_WIN32))
116 #define GDK_IS_GC_WIN32_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_GC_WIN32))
117 #define GDK_GC_WIN32_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_GC_WIN32, GdkGCWin32Class))
118
119 //#define GDK_WINDOW_SCREEN(win) (_gdk_screen)
120 GdkScreen *GDK_WINDOW_SCREEN(GObject *win);
121
122 #define GDK_WINDOW_IS_WIN32(win) (GDK_IS_WINDOW_IMPL_WIN32 (((GdkWindowObject *)win)->impl))
123
124 typedef struct _GdkColormapPrivateWin32 GdkColormapPrivateWin32;
125 typedef struct _GdkCursorPrivate GdkCursorPrivate;
126 typedef struct _GdkWin32SingleFont GdkWin32SingleFont;
127 typedef struct _GdkFontPrivateWin32 GdkFontPrivateWin32;
128 typedef struct _GdkGCWin32 GdkGCWin32;
129 typedef struct _GdkGCWin32Class GdkGCWin32Class;
130
131 struct _GdkCursorPrivate
132 {
133 GdkCursor cursor;
134 HCURSOR hcursor;
135 };
136
137 struct _GdkWin32SingleFont
138 {
139 HFONT hfont;
140 UINT charset;
141 UINT codepage;
142 FONTSIGNATURE fs;
143 };
144
145 #ifndef GDK_DISABLE_DEPRECATED
146
147 struct _GdkFontPrivateWin32
148 {
149 GdkFontPrivate base;
150 GSList *fonts; /* List of GdkWin32SingleFonts */
151 GSList *names;
152 };
153
154 #endif /* GDK_DISABLE_DEPRECATED */
155
156 struct _GdkVisualClass
157 {
158 GObjectClass parent_class;
159 };
160
161 typedef enum {
162 GDK_WIN32_PE_STATIC,
163 GDK_WIN32_PE_AVAILABLE,
164 GDK_WIN32_PE_INUSE
165 } GdkWin32PalEntryState;
166
167 struct _GdkColormapPrivateWin32
168 {
169 HPALETTE hpal;
170 gint current_size; /* Current size of hpal */
171 GdkWin32PalEntryState *use;
172 gint private_val;
173
174 GHashTable *hash;
175 GdkColorInfo *info;
176 };
177
178 struct _GdkGCWin32
179 {
180 GdkGC parent_instance;
181
182 /* A Windows Device Context (DC) is not equivalent to an X11
183 * GC. We can use a DC only in the window for which it was
184 * allocated, or (in the case of a memory DC) with the bitmap that
185 * has been selected into it. Thus, we have to release and
186 * reallocate a DC each time the GdkGC is used to paint into a new
187 * window or pixmap. We thus keep all the necessary values in the
188 * GdkGCWin32 object.
189 */
190
191 HRGN hcliprgn;
192
193 GdkGCValuesMask values_mask;
194
195 GdkFont *font;
196 gint rop2;
197 GdkSubwindowMode subwindow_mode;
198 gint graphics_exposures;
199 gint pen_width;
200 DWORD pen_style;
201 GdkLineStyle line_style;
202 GdkCapStyle cap_style;
203 GdkJoinStyle join_style;
204 DWORD *pen_dashes; /* use for PS_USERSTYLE or step-by-step rendering */
205 gint pen_num_dashes;
206 gint pen_dash_offset;
207 HBRUSH pen_hbrbg;
208
209 /* Following fields are valid while the GC exists as a Windows DC */
210 HDC hdc;
211 int saved_dc;
212
213 HPALETTE holdpal;
214 };
215
216 struct _GdkGCWin32Class
217 {
218 GdkGCClass parent_class;
219 };
220
221 GType _gdk_gc_win32_get_type (void);
222
223 gulong _gdk_win32_get_next_tick (gulong suggested_tick);
224
225 void _gdk_window_init_position (GdkWindow *window);
226 void _gdk_window_move_resize_child (GdkWindow *window,
227 gint x,
228 gint y,
229 gint width,
230 gint height);
231
232 /* GdkWindowImpl methods */
233 void _gdk_win32_window_scroll (GdkWindow *window,
234 gint dx,
235 gint dy);
236 void _gdk_win32_window_move_region (GdkWindow *window,
237 const GdkRegion *region,
238 gint dx,
239 gint dy);
240 void _gdk_win32_windowing_window_get_offsets (GdkWindow *window,
241 gint *x_offset,
242 gint *y_offset);
243
244
245 void _gdk_win32_selection_init (void);
246 void _gdk_win32_dnd_exit (void);
247
248 void gdk_win32_handle_table_insert (HANDLE *handle,
249 gpointer data);
250 void gdk_win32_handle_table_remove (HANDLE handle);
251
252 GdkGC *_gdk_win32_gc_new (GdkDrawable *drawable,
253 GdkGCValues *values,
254 GdkGCValuesMask values_mask);
255
256 GdkImage *_gdk_win32_get_image (GdkDrawable *drawable,
257 gint x,
258 gint y,
259 gint width,
260 gint height);
261
262 GdkImage *_gdk_win32_copy_to_image (GdkDrawable *drawable,
263 GdkImage *image,
264 gint src_x,
265 gint src_y,
266 gint dest_x,
267 gint dest_y,
268 gint width,
269 gint height);
270
271 void _gdk_win32_blit (gboolean use_fg_bg,
272 GdkDrawableImplWin32 *drawable,
273 GdkGC *gc,
274 GdkDrawable *src,
275 gint xsrc,
276 gint ysrc,
277 gint xdest,
278 gint ydest,
279 gint width,
280 gint height);
281
282 COLORREF _gdk_win32_colormap_color (GdkColormap *colormap,
283 gulong pixel);
284
285 HRGN _gdk_win32_bitmap_to_hrgn (GdkPixmap *bitmap);
286
287 HRGN _gdk_win32_gdkregion_to_hrgn (const GdkRegion *region,
288 gint x_origin,
289 gint y_origin);
290
291 GdkRegion *_gdk_win32_hrgn_to_region (HRGN hrgn);
292
293 void _gdk_win32_adjust_client_rect (GdkWindow *window,
294 RECT *RECT);
295
296 void _gdk_selection_property_delete (GdkWindow *);
297
298 void _gdk_dropfiles_store (gchar *data);
299
300 void _gdk_wchar_text_handle (GdkFont *font,
301 const wchar_t *wcstr,
302 int wclen,
303 void (*handler)(GdkWin32SingleFont *,
304 const wchar_t *,
305 int,
306 void *),
307 void *arg);
308
309 void _gdk_push_modal_window (GdkWindow *window);
310 void _gdk_remove_modal_window (GdkWindow *window);
311 GdkWindow *_gdk_modal_current (void);
312 gboolean _gdk_modal_blocked (GdkWindow *window);
313
314 #ifdef G_ENABLE_DEBUG
315 gchar *_gdk_win32_color_to_string (const GdkColor *color);
316 void _gdk_win32_print_paletteentries (const PALETTEENTRY *pep,
317 const int nentries);
318 void _gdk_win32_print_system_palette (void);
319 void _gdk_win32_print_hpalette (HPALETTE hpal);
320 void _gdk_win32_print_dc (HDC hdc);
321
322 gchar *_gdk_win32_cap_style_to_string (GdkCapStyle cap_style);
323 gchar *_gdk_win32_fill_style_to_string (GdkFill fill);
324 gchar *_gdk_win32_function_to_string (GdkFunction function);
325 gchar *_gdk_win32_join_style_to_string (GdkJoinStyle join_style);
326 gchar *_gdk_win32_line_style_to_string (GdkLineStyle line_style);
327 gchar *_gdk_win32_drag_protocol_to_string (GdkDragProtocol protocol);
328 gchar *_gdk_win32_gcvalues_mask_to_string (GdkGCValuesMask mask);
329 gchar *_gdk_win32_window_state_to_string (GdkWindowState state);
330 gchar *_gdk_win32_window_style_to_string (LONG style);
331 gchar *_gdk_win32_window_exstyle_to_string (LONG style);
332 gchar *_gdk_win32_window_pos_bits_to_string (UINT flags);
333 gchar *_gdk_win32_drag_action_to_string (GdkDragAction actions);
334 gchar *_gdk_win32_drawable_description (GdkDrawable *d);
335
336 gchar *_gdk_win32_rop2_to_string (int rop2);
337 gchar *_gdk_win32_lbstyle_to_string (UINT brush_style);
338 gchar *_gdk_win32_pstype_to_string (DWORD pen_style);
339 gchar *_gdk_win32_psstyle_to_string (DWORD pen_style);
340 gchar *_gdk_win32_psendcap_to_string (DWORD pen_style);
341 gchar *_gdk_win32_psjoin_to_string (DWORD pen_style);
342 gchar *_gdk_win32_message_to_string (UINT msg);
343 gchar *_gdk_win32_key_to_string (LONG lParam);
344 gchar *_gdk_win32_cf_to_string (UINT format);
345 gchar *_gdk_win32_data_to_string (const guchar*data,
346 int nbytes);
347 gchar *_gdk_win32_rect_to_string (const RECT *rect);
348
349 gchar *_gdk_win32_gdkrectangle_to_string (const GdkRectangle *rect);
350 gchar *_gdk_win32_gdkregion_to_string (const GdkRegion *box);
351
352 void _gdk_win32_print_event (const GdkEvent *event);
353
354 #endif
355
356 gchar *_gdk_win32_last_error_string (void);
357 void _gdk_win32_api_failed (const gchar *where,
358 const gchar *api);
359 void _gdk_other_api_failed (const gchar *where,
360 const gchar *api);
361
362 #define WIN32_API_FAILED(api) _gdk_win32_api_failed (G_STRLOC , api)
363 #define WIN32_GDI_FAILED(api) WIN32_API_FAILED (api)
364 #define OTHER_API_FAILED(api) _gdk_other_api_failed (G_STRLOC, api)
365
366 /* These two macros call a GDI or other Win32 API and if the return
367 * value is zero or NULL, print a warning message. The majority of GDI
368 * calls return zero or NULL on failure. The value of the macros is nonzero
369 * if the call succeeded, zero otherwise.
370 */
371
372 #define GDI_CALL(api, arglist) (api arglist ? 1 : (WIN32_GDI_FAILED (#api), 0))
373 #define API_CALL(api, arglist) (api arglist ? 1 : (WIN32_API_FAILED (#api), 0))
374
375 extern LRESULT CALLBACK _gdk_win32_window_procedure (HWND, UINT, WPARAM, LPARAM);
376
377 extern GdkWindow *_gdk_root;
378
379 extern GdkDisplay *_gdk_display;
380 extern GdkScreen *_gdk_screen;
381
382 extern gint _gdk_num_monitors;
383 typedef struct _GdkWin32Monitor GdkWin32Monitor;
384 struct _GdkWin32Monitor
385 {
386 gchar *name;
387 gint width_mm, height_mm;
388 GdkRectangle rect;
389 };
390 extern GdkWin32Monitor *_gdk_monitors;
391
392 /* Offsets to add to Windows coordinates (which are relative to the
393 * primary monitor's origin, and thus might be negative for monitors
394 * to the left and/or above the primary monitor) to get GDK
395 * coordinates, which should be non-negative on the whole screen.
396 */
397 extern gint _gdk_offset_x, _gdk_offset_y;
398
399 extern HDC _gdk_display_hdc;
400 extern HINSTANCE _gdk_dll_hinstance;
401 extern HINSTANCE _gdk_app_hmodule;
402
403 /* These are thread specific, but GDK/win32 works OK only when invoked
404 * from a single thread anyway.
405 */
406 extern HKL _gdk_input_locale;
407 extern gboolean _gdk_input_locale_is_ime;
408 extern UINT _gdk_input_codepage;
409
410 extern guint _gdk_keymap_serial;
411
412 /* GdkAtoms: properties, targets and types */
413 extern GdkAtom _gdk_selection;
414 extern GdkAtom _wm_transient_for;
415 extern GdkAtom _targets;
416 extern GdkAtom _delete;
417 extern GdkAtom _save_targets;
418 extern GdkAtom _utf8_string;
419 extern GdkAtom _text;
420 extern GdkAtom _compound_text;
421 extern GdkAtom _text_uri_list;
422 extern GdkAtom _text_html;
423 extern GdkAtom _image_png;
424 extern GdkAtom _image_jpeg;
425 extern GdkAtom _image_bmp;
426 extern GdkAtom _image_gif;
427
428 /* DND selections */
429 extern GdkAtom _local_dnd;
430 extern GdkAtom _gdk_win32_dropfiles;
431 extern GdkAtom _gdk_ole2_dnd;
432
433 /* Clipboard formats */
434 extern UINT _cf_png;
435 extern UINT _cf_jfif;
436 extern UINT _cf_gif;
437 extern UINT _cf_url;
438 extern UINT _cf_html_format;
439 extern UINT _cf_text_html;
440
441 /* OLE-based DND state */
442 typedef enum {
443 GDK_WIN32_DND_NONE,
444 GDK_WIN32_DND_PENDING,
445 GDK_WIN32_DND_DROPPED,
446 GDK_WIN32_DND_FAILED,
447 GDK_WIN32_DND_DRAGGING,
448 } GdkWin32DndState;
449
450 extern GdkWin32DndState _dnd_target_state;
451 extern GdkWin32DndState _dnd_source_state;
452
453 void _gdk_win32_dnd_do_dragdrop (void);
454 void _gdk_win32_ole2_dnd_property_change (GdkAtom type,
455 gint format,
456 const guchar *data,
457 gint nelements);
458
459 void _gdk_win32_begin_modal_call (void);
460 void _gdk_win32_end_modal_call (void);
461
462
463 /* Options */
464 extern gboolean _gdk_input_ignore_wintab;
465 extern gint _gdk_max_colors;
466
467 #define GDK_WIN32_COLORMAP_DATA(cmap) ((GdkColormapPrivateWin32 *) GDK_COLORMAP (cmap)->windowing_data)
468
469 /* TRUE while a modal sizing, moving, or dnd operation is in progress */
470 extern gboolean _modal_operation_in_progress;
471
472 extern HWND _modal_move_resize_window;
473
474 /* TRUE when we are emptying the clipboard ourselves */
475 extern gboolean _ignore_destroy_clipboard;
476
477 /* Mapping from registered clipboard format id (native) to
478 * corresponding GdkAtom
479 */
480 extern GHashTable *_format_atom_table;
481
482 /* Hold the result of a delayed rendering */
483 extern HGLOBAL _delayed_rendering_data;
484
485 HGLOBAL _gdk_win32_selection_convert_to_dib (HGLOBAL hdata,
486 GdkAtom target);
487
488 /* Convert a pixbuf to an HICON (or HCURSOR). Supports alpha under
489 * Windows XP, thresholds alpha otherwise.
490 */
491 HICON _gdk_win32_pixbuf_to_hicon (GdkPixbuf *pixbuf);
492 HICON _gdk_win32_pixbuf_to_hcursor (GdkPixbuf *pixbuf,
493 gint x_hotspot,
494 gint y_hotspot);
495 gboolean _gdk_win32_pixbuf_to_hicon_supports_alpha (void);
496
497 void _gdk_win32_append_event (GdkEvent *event);
498 void _gdk_win32_emit_configure_event (GdkWindow *window);
499 GdkWindow *_gdk_win32_find_window_for_mouse_event (GdkWindow* reported_window,
500 MSG* msg);
501
502 guint32 _gdk_win32_keymap_get_decimal_mark (GdkWin32Keymap *keymap);
503 gboolean _gdk_win32_keymap_has_altgr (GdkWin32Keymap *keymap);
504 guint8 _gdk_win32_keymap_get_active_group (GdkWin32Keymap *keymap);
505 guint8 _gdk_win32_keymap_get_rshift_scancode (GdkWin32Keymap *keymap);
506 void _gdk_win32_keymap_set_active_layout (GdkWin32Keymap *keymap,
507 HKL hkl);
508
509 /* Initialization */
510 void _gdk_windowing_window_init (GdkScreen *screen);
511 void _gdk_root_window_size_init (void);
512 void _gdk_monitor_init(void);
513 void _gdk_visual_init (void);
514 void _gdk_dnd_init (void);
515 void _gdk_windowing_image_init (void);
516 void _gdk_events_init (void);
517 void _gdk_input_init (GdkDisplay *display);
518
519 #endif /* __GDK_PRIVATE_WIN32_H__ */