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