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