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