]> Pileus Git - ~andy/gtk/blob - gdk/win32/gdkprivate-win32.h
gdk: Remove GdkPixmap
[~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
41 #include "gdkinternals.h"
42
43 #include "config.h"
44
45 /* Make up for some minor w32api or MSVC6 header lossage */
46
47 #ifndef PS_JOIN_MASK
48 #define PS_JOIN_MASK (PS_JOIN_BEVEL|PS_JOIN_MITER|PS_JOIN_ROUND)
49 #endif
50
51 #ifndef FS_VIETNAMESE
52 #define FS_VIETNAMESE 0x100
53 #endif
54
55 #ifndef WM_GETOBJECT
56 #define WM_GETOBJECT 0x3D
57 #endif
58 #ifndef WM_NCXBUTTONDOWN
59 #define WM_NCXBUTTONDOWN 0xAB
60 #endif
61 #ifndef WM_NCXBUTTONUP
62 #define WM_NCXBUTTONUP 0xAC
63 #endif
64 #ifndef WM_NCXBUTTONDBLCLK
65 #define WM_NCXBUTTONDBLCLK 0xAD
66 #endif
67 #ifndef WM_CHANGEUISTATE
68 #define WM_CHANGEUISTATE 0x127
69 #endif
70 #ifndef WM_UPDATEUISTATE
71 #define WM_UPDATEUISTATE 0x128
72 #endif
73 #ifndef WM_QUERYUISTATE
74 #define WM_QUERYUISTATE 0x129
75 #endif
76 #ifndef WM_XBUTTONDOWN
77 #define WM_XBUTTONDOWN 0x20B
78 #endif
79 #ifndef WM_XBUTTONUP
80 #define WM_XBUTTONUP 0x20C
81 #endif
82 #ifndef WM_XBUTTONDBLCLK
83 #define WM_XBUTTONDBLCLK 0x20D
84 #endif
85 #ifndef WM_NCMOUSEHOVER
86 #define WM_NCMOUSEHOVER 0x2A0
87 #endif
88 #ifndef WM_NCMOUSELEAVE
89 #define WM_NCMOUSELEAVE 0x2A2
90 #endif
91 #ifndef WM_APPCOMMAND
92 #define WM_APPCOMMAND 0x319
93 #endif
94
95 #ifndef CF_DIBV5
96 #define CF_DIBV5 17
97 #endif
98
99
100 /* Define some combinations of GdkDebugFlags */
101 #define GDK_DEBUG_EVENTS_OR_COLORMAP (GDK_DEBUG_EVENTS|GDK_DEBUG_COLORMAP)
102 #define GDK_DEBUG_EVENTS_OR_INPUT (GDK_DEBUG_EVENTS|GDK_DEBUG_INPUT)
103 #define GDK_DEBUG_PIXMAP_OR_COLORMAP (GDK_DEBUG_PIXMAP|GDK_DEBUG_COLORMAP)
104 #define GDK_DEBUG_MISC_OR_COLORMAP (GDK_DEBUG_MISC|GDK_DEBUG_COLORMAP)
105 #define GDK_DEBUG_MISC_OR_EVENTS (GDK_DEBUG_MISC|GDK_DEBUG_EVENTS)
106
107 //#define GDK_WINDOW_SCREEN(win)         (_gdk_screen)
108 GdkScreen *GDK_WINDOW_SCREEN(GObject *win);
109
110 #define GDK_WINDOW_IS_WIN32(win)        (GDK_IS_WINDOW_IMPL_WIN32 (((GdkWindowObject *)win)->impl))
111
112 typedef struct _GdkColormapPrivateWin32 GdkColormapPrivateWin32;
113 typedef struct _GdkCursorPrivate        GdkCursorPrivate;
114 typedef struct _GdkWin32SingleFont      GdkWin32SingleFont;
115
116 struct _GdkCursorPrivate
117 {
118   GdkCursor cursor;
119   HCURSOR hcursor;
120 };
121
122 struct _GdkWin32SingleFont
123 {
124   HFONT hfont;
125   UINT charset;
126   UINT codepage;
127   FONTSIGNATURE fs;
128 };
129
130 struct _GdkVisualClass
131 {
132   GObjectClass parent_class;
133 };
134
135 typedef enum {
136   GDK_WIN32_PE_STATIC,
137   GDK_WIN32_PE_AVAILABLE,
138   GDK_WIN32_PE_INUSE
139 } GdkWin32PalEntryState;
140
141 struct _GdkColormapPrivateWin32
142 {
143   HPALETTE hpal;
144   gint current_size;            /* Current size of hpal */
145   GdkWin32PalEntryState *use;
146   gint private_val;
147
148   GHashTable *hash;
149   GdkColorInfo *info;
150 };
151
152 GType _gdk_gc_win32_get_type (void);
153
154 gulong _gdk_win32_get_next_tick (gulong suggested_tick);
155
156 void _gdk_window_init_position     (GdkWindow *window);
157 void _gdk_window_move_resize_child (GdkWindow *window,
158                                     gint       x,
159                                     gint       y,
160                                     gint       width,
161                                     gint       height);
162
163 /* GdkWindowImpl methods */
164 void _gdk_win32_window_scroll (GdkWindow *window,
165                                gint       dx,
166                                gint       dy);
167 void _gdk_win32_window_move_region (GdkWindow       *window,
168                                     const cairo_region_t *region,
169                                     gint             dx,
170                                     gint             dy);
171 void _gdk_win32_windowing_window_get_offsets (GdkWindow *window,
172                                               gint      *x_offset,
173                                               gint      *y_offset);
174
175
176 void _gdk_win32_selection_init (void);
177 void _gdk_win32_dnd_exit (void);
178
179 void     gdk_win32_handle_table_insert  (HANDLE   *handle,
180                                          gpointer data);
181 void     gdk_win32_handle_table_remove  (HANDLE handle);
182
183 COLORREF  _gdk_win32_colormap_color     (GdkColormap *colormap,
184                                          gulong       pixel);
185
186 HRGN      _gdk_win32_cairo_region_to_hrgn (const cairo_region_t *region,
187                                            gint                  x_origin,
188                                            gint                  y_origin);
189
190 cairo_region_t *_gdk_win32_hrgn_to_region    (HRGN hrgn);
191
192 void    _gdk_win32_adjust_client_rect   (GdkWindow *window,
193                                          RECT      *RECT);
194
195 void    _gdk_selection_property_delete (GdkWindow *);
196
197 void    _gdk_dropfiles_store (gchar *data);
198
199 void       _gdk_push_modal_window   (GdkWindow *window);
200 void       _gdk_remove_modal_window (GdkWindow *window);
201 GdkWindow *_gdk_modal_current       (void);
202
203
204 #ifdef G_ENABLE_DEBUG
205 gchar *_gdk_win32_color_to_string      (const GdkColor *color);
206 void   _gdk_win32_print_paletteentries (const PALETTEENTRY *pep,
207                                         const int           nentries);
208 void   _gdk_win32_print_system_palette (void);
209 void   _gdk_win32_print_hpalette       (HPALETTE     hpal);
210 void   _gdk_win32_print_dc             (HDC          hdc);
211
212 gchar *_gdk_win32_drag_protocol_to_string (GdkDragProtocol protocol);
213 gchar *_gdk_win32_window_state_to_string (GdkWindowState state);
214 gchar *_gdk_win32_window_style_to_string (LONG style);
215 gchar *_gdk_win32_window_exstyle_to_string (LONG style);
216 gchar *_gdk_win32_window_pos_bits_to_string (UINT flags);
217 gchar *_gdk_win32_drag_action_to_string (GdkDragAction actions);
218 gchar *_gdk_win32_drawable_description (GdkDrawable *d);
219
220 gchar *_gdk_win32_rop2_to_string       (int          rop2);
221 gchar *_gdk_win32_lbstyle_to_string    (UINT         brush_style);
222 gchar *_gdk_win32_pstype_to_string     (DWORD        pen_style);
223 gchar *_gdk_win32_psstyle_to_string    (DWORD        pen_style);
224 gchar *_gdk_win32_psendcap_to_string   (DWORD        pen_style);
225 gchar *_gdk_win32_psjoin_to_string     (DWORD        pen_style);
226 gchar *_gdk_win32_message_to_string    (UINT         msg);
227 gchar *_gdk_win32_key_to_string        (LONG         lParam);
228 gchar *_gdk_win32_cf_to_string         (UINT         format);
229 gchar *_gdk_win32_data_to_string       (const guchar*data,
230                                         int          nbytes);
231 gchar *_gdk_win32_rect_to_string       (const RECT  *rect);
232
233 gchar *_gdk_win32_gdkrectangle_to_string (const GdkRectangle *rect);
234 gchar *_gdk_win32_cairo_region_to_string (const cairo_region_t    *box);
235
236 void   _gdk_win32_print_event            (const GdkEvent     *event);
237
238 #endif
239
240 gchar  *_gdk_win32_last_error_string (void);
241 void    _gdk_win32_api_failed        (const gchar *where,
242                                      const gchar *api);
243 void    _gdk_other_api_failed        (const gchar *where,
244                                      const gchar *api);
245
246 #define WIN32_API_FAILED(api) _gdk_win32_api_failed (G_STRLOC , api)
247 #define WIN32_GDI_FAILED(api) WIN32_API_FAILED (api)
248 #define OTHER_API_FAILED(api) _gdk_other_api_failed (G_STRLOC, api)
249  
250 /* These two macros call a GDI or other Win32 API and if the return
251  * value is zero or NULL, print a warning message. The majority of GDI
252  * calls return zero or NULL on failure. The value of the macros is nonzero
253  * if the call succeeded, zero otherwise.
254  */
255
256 #define GDI_CALL(api, arglist) (api arglist ? 1 : (WIN32_GDI_FAILED (#api), 0))
257 #define API_CALL(api, arglist) (api arglist ? 1 : (WIN32_API_FAILED (#api), 0))
258  
259 extern LRESULT CALLBACK _gdk_win32_window_procedure (HWND, UINT, WPARAM, LPARAM);
260
261 extern GdkWindow        *_gdk_root;
262
263 extern GdkDisplay       *_gdk_display;
264 extern GdkScreen        *_gdk_screen;
265
266 extern gint              _gdk_num_monitors;
267 typedef struct _GdkWin32Monitor GdkWin32Monitor;
268 struct _GdkWin32Monitor
269 {
270   gchar *name;
271   gint width_mm, height_mm;
272   GdkRectangle rect;
273 };
274 extern GdkWin32Monitor  *_gdk_monitors;
275
276 /* Offsets to add to Windows coordinates (which are relative to the
277  * primary monitor's origin, and thus might be negative for monitors
278  * to the left and/or above the primary monitor) to get GDK
279  * coordinates, which should be non-negative on the whole screen.
280  */
281 extern gint              _gdk_offset_x, _gdk_offset_y;
282
283 extern HDC               _gdk_display_hdc;
284 extern HINSTANCE         _gdk_dll_hinstance;
285 extern HINSTANCE         _gdk_app_hmodule;
286
287 /* These are thread specific, but GDK/win32 works OK only when invoked
288  * from a single thread anyway.
289  */
290 extern HKL               _gdk_input_locale;
291 extern gboolean          _gdk_input_locale_is_ime;
292 extern UINT              _gdk_input_codepage;
293
294 extern guint             _gdk_keymap_serial;
295 extern gboolean          _gdk_keyboard_has_altgr;
296 extern guint             _scancode_rshift;
297
298 /* GdkAtoms: properties, targets and types */
299 extern GdkAtom           _gdk_selection;
300 extern GdkAtom           _wm_transient_for;
301 extern GdkAtom           _targets;
302 extern GdkAtom           _delete;
303 extern GdkAtom           _save_targets;
304 extern GdkAtom           _utf8_string;
305 extern GdkAtom           _text;
306 extern GdkAtom           _compound_text;
307 extern GdkAtom           _text_uri_list;
308 extern GdkAtom           _text_html;
309 extern GdkAtom           _image_png;
310 extern GdkAtom           _image_jpeg;
311 extern GdkAtom           _image_bmp;
312 extern GdkAtom           _image_gif;
313
314 /* DND selections */
315 extern GdkAtom           _local_dnd;
316 extern GdkAtom           _gdk_win32_dropfiles;
317 extern GdkAtom           _gdk_ole2_dnd;
318
319 /* Clipboard formats */
320 extern UINT              _cf_png;
321 extern UINT              _cf_jfif;
322 extern UINT              _cf_gif;
323 extern UINT              _cf_url;
324 extern UINT              _cf_html_format;
325 extern UINT              _cf_text_html;
326
327 /* OLE-based DND state */
328 typedef enum {
329   GDK_WIN32_DND_NONE,
330   GDK_WIN32_DND_PENDING,
331   GDK_WIN32_DND_DROPPED,
332   GDK_WIN32_DND_FAILED,
333   GDK_WIN32_DND_DRAGGING,
334 } GdkWin32DndState;
335
336 extern GdkWin32DndState  _dnd_target_state;
337 extern GdkWin32DndState  _dnd_source_state;
338
339 void _gdk_win32_dnd_do_dragdrop (void);
340 void _gdk_win32_ole2_dnd_property_change (GdkAtom       type,
341                                           gint          format,
342                                           const guchar *data,
343                                           gint          nelements);
344
345 void  _gdk_win32_begin_modal_call (void);
346 void  _gdk_win32_end_modal_call (void);
347
348
349 /* Options */
350 extern gboolean          _gdk_input_ignore_wintab;
351 extern gint              _gdk_max_colors;
352
353 #define GDK_WIN32_COLORMAP_DATA(cmap) ((GdkColormapPrivateWin32 *) GDK_COLORMAP (cmap)->windowing_data)
354
355 /* TRUE while a modal sizing, moving, or dnd operation is in progress */
356 extern gboolean         _modal_operation_in_progress;
357
358 /* TRUE when we are emptying the clipboard ourselves */
359 extern gboolean         _ignore_destroy_clipboard;
360
361 /* Mapping from registered clipboard format id (native) to
362  * corresponding GdkAtom
363  */
364 extern GHashTable       *_format_atom_table;
365
366 /* Hold the result of a delayed rendering */
367 extern HGLOBAL          _delayed_rendering_data;
368
369 HGLOBAL _gdk_win32_selection_convert_to_dib (HGLOBAL  hdata,
370                                              GdkAtom  target);
371
372 /* Convert a pixbuf to an HICON (or HCURSOR).  Supports alpha under
373  * Windows XP, thresholds alpha otherwise.
374  */
375 HICON _gdk_win32_pixbuf_to_hicon   (GdkPixbuf *pixbuf);
376 HICON _gdk_win32_pixbuf_to_hcursor (GdkPixbuf *pixbuf,
377                                     gint       x_hotspot,
378                                     gint       y_hotspot);
379 gboolean _gdk_win32_pixbuf_to_hicon_supports_alpha (void);
380
381 /* Initialization */
382 void _gdk_windowing_window_init (GdkScreen *screen);
383 void _gdk_root_window_size_init (void);
384 void _gdk_monitor_init(void);
385 void _gdk_visual_init (void);
386 void _gdk_dnd_init    (void);
387 void _gdk_events_init (void);
388 void _gdk_input_init  (GdkDisplay *display);
389
390 #endif /* __GDK_PRIVATE_WIN32_H__ */