]> Pileus Git - ~andy/gtk/blob - gdk/win32/gdkprivate.h
New font private structures, related to fontsets.
[~andy/gtk] / gdk / win32 / gdkprivate.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 Library 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  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library 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-1999.  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_H__
28 #define __GDK_PRIVATE_H__
29
30 #define STRICT                  /* We want strict type checks */
31 #include <windows.h>
32 #include <commctrl.h>
33
34 /* Make up for some minor mingw32 lossage */
35
36 /* PS_JOIN_MASK is missing from the mingw32 headers */
37 #ifndef PS_JOIN_MASK
38 #define PS_JOIN_MASK (PS_JOIN_BEVEL|PS_JOIN_MITER|PS_JOIN_ROUND)
39 #endif
40
41 /* CLR_INVALID is missing */
42 #ifndef CLR_INVALID
43 #define CLR_INVALID CLR_NONE
44 #endif
45
46 /* Some charsets are missing */
47 #ifndef JOHAB_CHARSET
48 #define JOHAB_CHARSET 130
49 #endif
50 #ifndef VIETNAMESE_CHARSET
51 #define VIETNAMESE_CHARSET 163
52 #endif
53
54 #ifndef VM_OEM_PLUS
55 #define VK_OEM_PLUS 0xBB
56 #endif
57
58 #include <time.h>
59
60 #include <gdk/gdktypes.h>
61
62 #include <gdk/gdkcursor.h>
63 #include <gdk/gdkevents.h>
64 #include <gdk/gdkfont.h>
65 #include <gdk/gdkgc.h>
66 #include <gdk/gdkim.h>
67 #include <gdk/gdkimage.h>
68 #include <gdk/gdkregion.h>
69 #include <gdk/gdkvisual.h>
70 #include <gdk/gdkwindow.h>
71
72 #define GDK_DRAWABLE_TYPE(d) (((GdkDrawablePrivate *)d)->window_type)
73 #define GDK_IS_WINDOW(d) (GDK_DRAWABLE_TYPE(d) <= GDK_WINDOW_TEMP || \
74                           GDK_DRAWABLE_TYPE(d) == GDK_WINDOW_FOREIGN)
75 #define GDK_IS_PIXMAP(d) (GDK_DRAWABLE_TYPE(d) == GDK_DRAWABLE_PIXMAP)
76 #define GDK_DRAWABLE_DESTROYED(d) (((GdkDrawablePrivate *)d)->destroyed)
77
78 #define gdk_window_lookup(xid)     ((GdkWindow*) gdk_xid_table_lookup (xid))
79 #define gdk_pixmap_lookup(xid)     ((GdkPixmap*) gdk_xid_table_lookup (xid))
80
81 #ifdef __cplusplus
82 extern "C" {
83 #endif /* __cplusplus */
84
85 /* Define corresponding Windows types for some X11 types, just for laziness.
86  */
87
88 typedef HANDLE XID;
89 typedef PALETTEENTRY XColor;
90 typedef HDC GC;
91 typedef ATOM Atom;
92 typedef HCURSOR Cursor;
93 typedef guint VisualID;
94 typedef DWORD KeySym;
95 typedef int Status;
96
97 /* Define some of the X11 constants also here, again just for laziness */
98
99 /* Generic null resource */
100 #define None 0
101
102 /* Error codes */
103 #define Success            0
104
105 /* Grabbing status */
106 #define GrabSuccess        0
107 #define AlreadyGrabbed     2
108
109 /* For CreateColormap */
110 #define AllocNone 0
111 #define AllocAll 1
112
113 /* Some structs are somewhat useful to emulate internally, just to
114    keep the code less #ifdefed.  */
115 typedef struct {
116   HPALETTE palette;             /* Palette handle used when drawing. */
117   guint size;                   /* Number of entries in the palette. */
118   gboolean stale;               /* 1 if palette needs to be realized,
119                                  * otherwise 0. */
120   gboolean *in_use;
121   gboolean rc_palette;          /* If RC_PALETTE is on in the RASTERCAPS */
122   gulong sizepalette;           /* SIZEPALETTE if rc_palette */
123 } ColormapStruct, *Colormap;
124   
125 typedef struct {
126   gint map_entries;
127   guint visualid;
128   guint bitspixel;
129 } Visual;
130
131 typedef struct {
132   Colormap colormap;
133   unsigned long red_max;
134   unsigned long red_mult;
135   unsigned long green_max;
136   unsigned long green_mult;
137   unsigned long blue_max;
138   unsigned long blue_mult;
139   unsigned long base_pixel;
140 } XStandardColormap;
141
142 typedef struct _GdkDrawablePrivate     GdkDrawablePrivate;
143 /* typedef struct _GdkDrawablePrivate     GdkPixmapPrivate; */
144 typedef struct _GdkWindowPrivate       GdkWindowPrivate;
145 typedef struct _GdkImagePrivate        GdkImagePrivate;
146 typedef struct _GdkGCPrivate           GdkGCPrivate;
147 typedef struct _GdkColormapPrivate     GdkColormapPrivate;
148 typedef struct _GdkColorInfo           GdkColorInfo;
149 typedef struct _GdkVisualPrivate       GdkVisualPrivate;
150 typedef struct _GdkFontPrivate         GdkFontPrivate;
151 typedef struct _GdkCursorPrivate       GdkCursorPrivate;
152 typedef struct _GdkEventFilter         GdkEventFilter;
153 typedef struct _GdkClientFilter        GdkClientFilter;
154 typedef struct _GdkRegionPrivate       GdkRegionPrivate;
155
156 struct _GdkDrawablePrivate
157 {
158   GdkDrawable drawable;
159
160   guint8 window_type;
161   guint ref_count;
162
163   guint16 width;
164   guint16 height;
165
166   HANDLE xwindow;
167   GdkColormap *colormap;
168
169   guint destroyed : 2;
170 };
171
172 struct _GdkWindowPrivate
173 {
174   GdkDrawablePrivate drawable;
175
176   GdkWindow *parent;
177   gint16 x;
178   gint16 y;
179   guint8 resize_count;
180   guint mapped : 1;
181   guint guffaw_gravity : 1;
182
183   /* We must keep the event mask here to filter them ourselves */
184   gint event_mask;
185
186   /* Values for bg_type */
187 #define GDK_WIN32_BG_NORMAL 0
188 #define GDK_WIN32_BG_PIXEL 1
189 #define GDK_WIN32_BG_PIXMAP 2
190 #define GDK_WIN32_BG_PARENT_RELATIVE 3
191 #define GDK_WIN32_BG_TRANSPARENT 4
192
193   /* We draw the background ourselves at WM_ERASEBKGND  */
194   guchar bg_type;
195   GdkColor bg_pixel;
196   GdkPixmap *bg_pixmap;
197
198   HCURSOR xcursor;
199
200   /* Window size hints */
201   gint hint_flags;
202   gint hint_x, hint_y;
203   gint hint_min_width, hint_min_height;
204   gint hint_max_width, hint_max_height;
205
206   gint extension_events;
207   gboolean extension_events_selected;
208
209   GList *filters;
210   GList *children;
211
212   HKL input_locale;
213   CHARSETINFO charset_info;
214 };
215
216 struct _GdkImagePrivate
217 {
218   GdkImage image;
219   HBITMAP ximage;
220   gpointer x_shm_info;
221
222   void (*image_put) (GdkDrawable *window,
223                      GdkGC       *gc,
224                      GdkImage    *image,
225                      gint         xsrc,
226                      gint         ysrc,
227                      gint         xdest,
228                      gint         ydest,
229                      gint         width,
230                      gint         height);
231 };
232
233 struct _GdkGCPrivate
234 {
235   GdkGC gc;
236   GC xgc;
237   /* A Windows Device Context (DC) is not equivalent to an X11
238    * GC. We can use a DC only in the window for which it was
239    * allocated, or (in the case of a memory DC) with the bitmap that
240    * has been selected into it. Thus, we have to release and
241    * reallocate a DC each time the GdkGC is used to paint into a new
242    * window or pixmap. We thus keep all the necessary values in the
243    * GdkGCPrivate struct.
244    */
245   GdkGCValuesMask values_mask;
246   GdkColor foreground;
247   GdkColor background;
248   GdkFont *font;
249   gint rop2;
250   GdkFill fill_style;
251   GdkPixmap *tile;
252   GdkPixmap *stipple;
253   HRGN clip_region;
254   GdkSubwindowMode subwindow_mode;
255   gint ts_x_origin;
256   gint ts_y_origin;
257   gint clip_x_origin;
258   gint clip_y_origin;
259   gint graphics_exposures;
260   gint pen_width;
261   DWORD pen_style;
262   HANDLE hwnd;                  /* If a DC is allocated, for which window
263                                    or what bitmap is selected into it */
264   int saved_dc;
265   guint ref_count;
266 };
267
268 typedef enum {
269   GDK_COLOR_WRITEABLE = 1 << 0
270 } GdkColorInfoFlags;
271
272 struct _GdkColorInfo
273 {
274   GdkColorInfoFlags flags;
275   guint ref_count;
276 };
277
278 struct _GdkColormapPrivate
279 {
280   GdkColormap colormap;
281   Colormap xcolormap;
282   GdkVisual *visual;
283   gint private_val;
284
285   GHashTable *hash;
286   GdkColorInfo *info;
287   time_t last_sync_time;
288   
289   guint ref_count;
290 };
291
292 struct _GdkVisualPrivate
293 {
294   GdkVisual visual;
295   Visual *xvisual;
296 };
297
298 typedef struct
299 {
300   HFONT xfont;
301   DWORD charset;
302   UINT codepage;
303   CPINFO cpinfo;
304   FONTSIGNATURE fs;
305 } GdkWin32SingleFont;
306
307 struct _GdkFontPrivate
308 {
309   GdkFont font;
310   guint ref_count;
311
312   GSList *fonts;
313   GSList *names;
314 };
315
316 struct _GdkCursorPrivate
317 {
318   GdkCursor cursor;
319   Cursor xcursor;
320 };
321
322 struct _GdkEventFilter {
323   GdkFilterFunc function;
324   gpointer data;
325 };
326
327 struct _GdkClientFilter {
328   GdkAtom       type;
329   GdkFilterFunc function;
330   gpointer      data;
331 };
332
333 struct _GdkRegionPrivate
334 {
335   GdkRegion region;
336   HRGN xregion;
337 };
338
339 typedef enum {
340   GDK_DEBUG_MISC          = 1 << 0,
341   GDK_DEBUG_EVENTS        = 1 << 1,
342   GDK_DEBUG_DND           = 1 << 2,
343   GDK_DEBUG_COLOR_CONTEXT = 1 << 3,
344   GDK_DEBUG_XIM           = 1 << 4,
345   GDK_DEBUG_SELECTION     = 1 << 5
346 } GdkDebugFlag;
347
348 void gdk_events_init (void);
349 void gdk_window_init (void);
350 void gdk_visual_init (void);
351 void gdk_selection_init (void);
352 void gdk_dnd_init    (void);
353 void gdk_dnd_exit    (void);
354 void gdk_image_init  (void);
355 void gdk_image_exit  (void);
356
357 GdkColormap* gdk_colormap_lookup (Colormap  xcolormap);
358 GdkVisual*   gdk_visual_lookup   (Visual   *xvisual);
359
360 void gdk_window_add_colormap_windows (GdkWindow *window);
361 void gdk_window_destroy_notify       (GdkWindow *window);
362
363 void     gdk_xid_table_insert (XID      *xid,
364                                gpointer  data);
365 void     gdk_xid_table_remove (XID       xid);
366 gpointer gdk_xid_table_lookup (XID       xid);
367
368 /* Internal functions */
369
370 HDC     gdk_gc_predraw  (GdkDrawablePrivate *drawable_private,
371                          GdkGCPrivate       *gc_private);
372 void    gdk_gc_postdraw (GdkDrawablePrivate *drawable_private,
373                          GdkGCPrivate       *gc_private);
374 HRGN    BitmapToRegion  (HBITMAP hBmp);
375
376 void    gdk_sel_prop_store (GdkWindow *owner,
377                             GdkAtom    type,
378                             gint       format,
379                             guchar    *data,
380                             gint       length);
381
382 void gdk_event_queue_append (GdkEvent *event);
383
384 gint gdk_nmbstowcs (GdkWChar    *dest,
385                           const gchar *src,
386                           gint         src_len,
387                           gint         dest_max);
388 gint gdk_nmbstowchar_ts (wchar_t     *dest,
389                                const gchar *src,
390                                gint         src_len,
391                                gint         dest_max);
392
393 void gdk_wchar_text_handle (GdkFont       *font,
394                             const wchar_t *wcstr,
395                             int            wclen,
396                             void         (*handler)(GdkWin32SingleFont *,
397                                                     const wchar_t *,
398                                                     int,
399                                                     void *),
400                             void          *arg);
401
402 /* Please see gdkwindow.c for comments on how to use */ 
403 HWND gdk_window_xid_at(HWND base, gint bx, gint by, gint x, gint y, GList *excludes, gboolean excl_child);
404 HWND gdk_window_xid_at_coords(gint x, gint y, GList *excludes, gboolean excl_child);
405
406 extern gint              gdk_debug_level;
407 extern gint              gdk_show_events;
408 extern gint              gdk_stack_trace;
409 extern HWND              gdk_root_window;
410 extern HWND              gdk_leader_window;
411 GDKVAR GdkWindowPrivate *gdk_root_parent;
412 GDKVAR Atom              gdk_selection_property;
413 GDKVAR gchar            *gdk_progclass;
414 GDKVAR gint              gdk_error_code;
415 GDKVAR gint              gdk_error_warnings;
416 GDKVAR gint              gdk_null_window_warnings;
417 extern gint              gdk_event_func_from_window_proc;
418
419 extern HDC               gdk_DC;
420 extern HINSTANCE         gdk_DLLInstance;
421 extern HINSTANCE         gdk_ProgInstance;
422
423 extern UINT              gdk_selection_notify_msg;
424 extern UINT              gdk_selection_request_msg;
425 extern UINT              gdk_selection_clear_msg;
426 extern GdkAtom           gdk_clipboard_atom;
427 extern GdkAtom           gdk_win32_dropfiles_atom;
428 extern GdkAtom           gdk_ole2_dnd_atom;
429
430 extern LRESULT CALLBACK gdk_WindowProc (HWND, UINT, WPARAM, LPARAM);
431
432 extern DWORD             windows_version;
433
434 /* Debugging support */
435
436 #ifdef G_ENABLE_DEBUG
437
438 #define GDK_NOTE(type,action)                G_STMT_START { \
439     if (gdk_debug_flags & GDK_DEBUG_##type)                 \
440        { action; };                          } G_STMT_END
441
442 #else /* !G_ENABLE_DEBUG */
443
444 #define GDK_NOTE(type,action)
445       
446 #endif /* G_ENABLE_DEBUG */
447
448 GDKVAR guint gdk_debug_flags;
449
450 /* Internal functions for debug output etc. */
451
452 char   *gdk_color_to_string (GdkColor *);
453
454 #ifdef __cplusplus
455 }
456 #endif /* __cplusplus */
457
458
459 #endif /* __GDK_PRIVATE_H__ */