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