]> Pileus Git - ~andy/gtk/blob - gdk/gdkdrawable.h
Merge branch 'master' into client-side-windows
[~andy/gtk] / gdk / gdkdrawable.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 #if defined(GTK_DISABLE_SINGLE_INCLUDES) && !defined (__GDK_H_INSIDE__) && !defined (GDK_COMPILATION)
28 #error "Only <gdk/gdk.h> can be included directly."
29 #endif
30
31 #ifndef __GDK_DRAWABLE_H__
32 #define __GDK_DRAWABLE_H__
33
34 #include <gdk/gdktypes.h>
35 #include <gdk/gdkgc.h>
36 #include <gdk/gdkrgb.h>
37 #include <gdk-pixbuf/gdk-pixbuf.h>
38
39 #include <cairo.h>
40
41 G_BEGIN_DECLS
42
43 typedef struct _GdkDrawableClass GdkDrawableClass;
44 typedef struct _GdkTrapezoid     GdkTrapezoid;
45
46 #define GDK_TYPE_DRAWABLE              (gdk_drawable_get_type ())
47 #define GDK_DRAWABLE(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_DRAWABLE, GdkDrawable))
48 #define GDK_DRAWABLE_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_DRAWABLE, GdkDrawableClass))
49 #define GDK_IS_DRAWABLE(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_DRAWABLE))
50 #define GDK_IS_DRAWABLE_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_DRAWABLE))
51 #define GDK_DRAWABLE_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_DRAWABLE, GdkDrawableClass))
52
53 struct _GdkDrawable
54 {
55   GObject parent_instance;
56 };
57  
58 struct _GdkDrawableClass 
59 {
60   GObjectClass parent_class;
61   
62   GdkGC *(*create_gc)    (GdkDrawable    *drawable,
63                           GdkGCValues    *values,
64                           GdkGCValuesMask mask);
65   void (*draw_rectangle) (GdkDrawable  *drawable,
66                           GdkGC        *gc,
67                           gboolean      filled,
68                           gint          x,
69                           gint          y,
70                           gint          width,
71                           gint          height);
72   void (*draw_arc)       (GdkDrawable  *drawable,
73                           GdkGC        *gc,
74                           gboolean      filled,
75                           gint          x,
76                           gint          y,
77                           gint          width,
78                           gint          height,
79                           gint          angle1,
80                           gint          angle2);
81   void (*draw_polygon)   (GdkDrawable  *drawable,
82                           GdkGC        *gc,
83                           gboolean      filled,
84                           GdkPoint     *points,
85                           gint          npoints);
86   void (*draw_text)      (GdkDrawable  *drawable,
87                           GdkFont      *font,
88                           GdkGC        *gc,
89                           gint          x,
90                           gint          y,
91                           const gchar  *text,
92                           gint          text_length);
93   void (*draw_text_wc)   (GdkDrawable    *drawable,
94                           GdkFont        *font,
95                           GdkGC          *gc,
96                           gint            x,
97                           gint            y,
98                           const GdkWChar *text,
99                           gint            text_length);
100   void (*draw_drawable)  (GdkDrawable  *drawable,
101                           GdkGC        *gc,
102                           GdkDrawable  *src,
103                           gint          xsrc,
104                           gint          ysrc,
105                           gint          xdest,
106                           gint          ydest,
107                           gint          width,
108                           gint          height);
109   void (*draw_points)    (GdkDrawable  *drawable,
110                           GdkGC        *gc,
111                           GdkPoint     *points,
112                           gint          npoints);
113   void (*draw_segments)  (GdkDrawable  *drawable,
114                           GdkGC        *gc,
115                           GdkSegment   *segs,
116                           gint          nsegs);
117   void (*draw_lines)     (GdkDrawable  *drawable,
118                           GdkGC        *gc,
119                           GdkPoint     *points,
120                           gint          npoints);
121
122   void (*draw_glyphs)    (GdkDrawable      *drawable,
123                           GdkGC            *gc,
124                           PangoFont        *font,
125                           gint              x,
126                           gint              y,
127                           PangoGlyphString *glyphs);
128
129   void (*draw_image)     (GdkDrawable *drawable,
130                           GdkGC       *gc,
131                           GdkImage    *image,
132                           gint         xsrc,
133                           gint         ysrc,
134                           gint         xdest,
135                           gint         ydest,
136                           gint         width,
137                           gint         height);
138   
139   gint (*get_depth)      (GdkDrawable  *drawable);
140   void (*get_size)       (GdkDrawable  *drawable,
141                           gint         *width,
142                           gint         *height);
143
144   void (*set_colormap)   (GdkDrawable  *drawable,
145                           GdkColormap  *cmap);
146
147   GdkColormap* (*get_colormap)  (GdkDrawable  *drawable);
148   GdkVisual*   (*get_visual)    (GdkDrawable  *drawable);
149   GdkScreen*   (*get_screen)    (GdkDrawable  *drawable);
150
151   GdkImage*    (*get_image)  (GdkDrawable  *drawable,
152                               gint          x,
153                               gint          y,
154                               gint          width,
155                               gint          height);
156
157   GdkRegion*   (*get_clip_region)    (GdkDrawable  *drawable);
158   GdkRegion*   (*get_visible_region) (GdkDrawable  *drawable);
159
160   GdkDrawable* (*get_composite_drawable) (GdkDrawable *drawable,
161                                           gint         x,
162                                           gint         y,
163                                           gint         width,
164                                           gint         height,
165                                           gint        *composite_x_offset,
166                                           gint        *composite_y_offset);
167
168   void         (*draw_pixbuf) (GdkDrawable *drawable,
169                                GdkGC       *gc,
170                                GdkPixbuf   *pixbuf,
171                                gint         src_x,
172                                gint         src_y,
173                                gint         dest_x,
174                                gint         dest_y,
175                                gint         width,
176                                gint         height,
177                                GdkRgbDither dither,
178                                gint         x_dither,
179                                gint         y_dither);
180   GdkImage*    (*_copy_to_image) (GdkDrawable    *drawable,
181                                   GdkImage       *image,
182                                   gint            src_x,
183                                   gint            src_y,
184                                   gint            dest_x,
185                                   gint            dest_y,
186                                   gint            width,
187                                   gint            height);
188   
189   void (*draw_glyphs_transformed) (GdkDrawable      *drawable,
190                                    GdkGC            *gc,
191                                    PangoMatrix      *matrix,
192                                    PangoFont        *font,
193                                    gint              x,
194                                    gint              y,
195                                    PangoGlyphString *glyphs);
196   void (*draw_trapezoids)         (GdkDrawable      *drawable,
197                                    GdkGC            *gc,
198                                    GdkTrapezoid     *trapezoids,
199                                    gint              n_trapezoids);
200
201   cairo_surface_t *(*ref_cairo_surface) (GdkDrawable *drawable);
202
203   GdkDrawable *(*get_source_drawable) (GdkDrawable *drawable);
204
205   void         (*set_cairo_clip)      (GdkDrawable *drawable,
206                                        cairo_t *cr);
207
208   cairo_surface_t * (*create_cairo_surface) (GdkDrawable *drawable,
209                                              int width,
210                                              int height);
211
212   /* Padding for future expansion */
213   void         (*_gdk_reserved7)  (void);
214   void         (*_gdk_reserved9)  (void);
215   void         (*_gdk_reserved10) (void);
216   void         (*_gdk_reserved11) (void);
217   void         (*_gdk_reserved12) (void);
218   void         (*_gdk_reserved13) (void);
219   void         (*_gdk_reserved14) (void);
220   void         (*_gdk_reserved15) (void);
221   void         (*_gdk_reserved16) (void);
222 };
223
224 struct _GdkTrapezoid
225 {
226   double y1, x11, x21, y2, x12, x22;
227 };
228
229 GType           gdk_drawable_get_type     (void) G_GNUC_CONST;
230
231 /* Manipulation of drawables
232  */
233
234 #ifndef GDK_DISABLE_DEPRECATED
235 void            gdk_drawable_set_data     (GdkDrawable    *drawable,
236                                            const gchar    *key,
237                                            gpointer       data,
238                                            GDestroyNotify  destroy_func);
239 gpointer        gdk_drawable_get_data     (GdkDrawable    *drawable,
240                                            const gchar    *key);
241 #endif /* GDK_DISABLE_DEPRECATED */
242
243 void            gdk_drawable_get_size     (GdkDrawable    *drawable,
244                                            gint           *width,
245                                            gint           *height);
246 void            gdk_drawable_set_colormap (GdkDrawable    *drawable,
247                                            GdkColormap    *colormap);
248 GdkColormap*    gdk_drawable_get_colormap (GdkDrawable    *drawable);
249 GdkVisual*      gdk_drawable_get_visual   (GdkDrawable    *drawable);
250 gint            gdk_drawable_get_depth    (GdkDrawable    *drawable);
251 GdkScreen*      gdk_drawable_get_screen   (GdkDrawable    *drawable);
252 GdkDisplay*     gdk_drawable_get_display  (GdkDrawable    *drawable);
253
254 #ifndef GDK_DISABLE_DEPRECATED
255 GdkDrawable*    gdk_drawable_ref          (GdkDrawable    *drawable);
256 void            gdk_drawable_unref        (GdkDrawable    *drawable);
257 #endif /* GDK_DISABLE_DEPRECATED */
258
259 /* Drawing
260  */
261 void gdk_draw_point     (GdkDrawable      *drawable,
262                          GdkGC            *gc,
263                          gint              x,
264                          gint              y);
265 void gdk_draw_line      (GdkDrawable      *drawable,
266                          GdkGC            *gc,
267                          gint              x1_,
268                          gint              y1_,
269                          gint              x2_,
270                          gint              y2_);
271 void gdk_draw_rectangle (GdkDrawable      *drawable,
272                          GdkGC            *gc,
273                          gboolean          filled,
274                          gint              x,
275                          gint              y,
276                          gint              width,
277                          gint              height);
278 void gdk_draw_arc       (GdkDrawable      *drawable,
279                          GdkGC            *gc,
280                          gboolean          filled,
281                          gint              x,
282                          gint              y,
283                          gint              width,
284                          gint              height,
285                          gint              angle1,
286                          gint              angle2);
287 void gdk_draw_polygon   (GdkDrawable      *drawable,
288                          GdkGC            *gc,
289                          gboolean          filled,
290                          const GdkPoint   *points,
291                          gint              n_points);
292 #if !defined (GDK_DISABLE_DEPRECATED) || defined (GTK_COMPILATION)
293 /* Used by gtk_default_draw_string () */
294 void gdk_draw_string    (GdkDrawable      *drawable,
295                          GdkFont          *font,
296                          GdkGC            *gc,
297                          gint              x,
298                          gint              y,
299                          const gchar      *string);
300 #endif /* !GDK_DISABLE_DEPRECATED || GTK_COMPILATION */
301 #if !defined (GDK_DISABLE_DEPRECATED) || defined (GDK_COMPILATION)
302 /* Used by gdk_pixmap_draw_text (), gdk_window_draw_text() */
303 void gdk_draw_text      (GdkDrawable      *drawable,
304                          GdkFont          *font,
305                          GdkGC            *gc,
306                          gint              x,
307                          gint              y,
308                          const gchar      *text,
309                          gint              text_length);
310 /* Used by gdk_pixmap_draw_text_wc (), gdk_window_draw_text_wc () */
311 void gdk_draw_text_wc   (GdkDrawable      *drawable,
312                          GdkFont          *font,
313                          GdkGC            *gc,
314                          gint              x,
315                          gint              y,
316                          const GdkWChar   *text,
317                          gint              text_length);
318 #endif /* !GDK_DISABLE_DEPRECATED || GDK_COMPILATION */
319 void gdk_draw_drawable  (GdkDrawable      *drawable,
320                          GdkGC            *gc,
321                          GdkDrawable      *src,
322                          gint              xsrc,
323                          gint              ysrc,
324                          gint              xdest,
325                          gint              ydest,
326                          gint              width,
327                          gint              height);
328 void gdk_draw_image     (GdkDrawable      *drawable,
329                          GdkGC            *gc,
330                          GdkImage         *image,
331                          gint              xsrc,
332                          gint              ysrc,
333                          gint              xdest,
334                          gint              ydest,
335                          gint              width,
336                          gint              height);
337 void gdk_draw_points    (GdkDrawable      *drawable,
338                          GdkGC            *gc,
339                          const GdkPoint   *points,
340                          gint              n_points);
341 void gdk_draw_segments  (GdkDrawable      *drawable,
342                          GdkGC            *gc,
343                          const GdkSegment *segs,
344                          gint              n_segs);
345 void gdk_draw_lines     (GdkDrawable      *drawable,
346                          GdkGC            *gc,
347                          const GdkPoint   *points,
348                          gint              n_points);
349 void gdk_draw_pixbuf    (GdkDrawable      *drawable,
350                          GdkGC            *gc,
351                          const GdkPixbuf  *pixbuf,
352                          gint              src_x,
353                          gint              src_y,
354                          gint              dest_x,
355                          gint              dest_y,
356                          gint              width,
357                          gint              height,
358                          GdkRgbDither      dither,
359                          gint              x_dither,
360                          gint              y_dither);
361
362 void gdk_draw_glyphs      (GdkDrawable      *drawable,
363                            GdkGC            *gc,
364                            PangoFont        *font,
365                            gint              x,
366                            gint              y,
367                            PangoGlyphString *glyphs);
368 void gdk_draw_layout_line (GdkDrawable      *drawable,
369                            GdkGC            *gc,
370                            gint              x,
371                            gint              y,
372                            PangoLayoutLine  *line);
373 void gdk_draw_layout      (GdkDrawable      *drawable,
374                            GdkGC            *gc,
375                            gint              x,
376                            gint              y,
377                            PangoLayout      *layout);
378
379 void gdk_draw_layout_line_with_colors (GdkDrawable     *drawable,
380                                        GdkGC           *gc,
381                                        gint             x,
382                                        gint             y,
383                                        PangoLayoutLine *line,
384                                        const GdkColor  *foreground,
385                                        const GdkColor  *background);
386 void gdk_draw_layout_with_colors      (GdkDrawable     *drawable,
387                                        GdkGC           *gc,
388                                        gint             x,
389                                        gint             y,
390                                        PangoLayout     *layout,
391                                        const GdkColor  *foreground,
392                                        const GdkColor  *background);
393
394 void gdk_draw_glyphs_transformed (GdkDrawable        *drawable,
395                                   GdkGC              *gc,
396                                   const PangoMatrix  *matrix,
397                                   PangoFont          *font,
398                                   gint                x,
399                                   gint                y,
400                                   PangoGlyphString   *glyphs);
401 void gdk_draw_trapezoids         (GdkDrawable        *drawable,
402                                   GdkGC              *gc,
403                                   const GdkTrapezoid *trapezoids,
404                                   gint                n_trapezoids);
405
406 #ifndef GDK_DISABLE_DEPRECATED
407 #define gdk_draw_pixmap                gdk_draw_drawable
408 #define gdk_draw_bitmap                gdk_draw_drawable
409 #endif /* GDK_DISABLE_DEPRECATED */
410
411 GdkImage* gdk_drawable_get_image      (GdkDrawable *drawable,
412                                        gint         x,
413                                        gint         y,
414                                        gint         width,
415                                        gint         height);
416 GdkImage *gdk_drawable_copy_to_image (GdkDrawable  *drawable,
417                                       GdkImage     *image,
418                                       gint          src_x,
419                                       gint          src_y,
420                                       gint          dest_x,
421                                       gint          dest_y,
422                                       gint          width,
423                                       gint          height);
424
425 GdkRegion *gdk_drawable_get_clip_region    (GdkDrawable *drawable);
426 GdkRegion *gdk_drawable_get_visible_region (GdkDrawable *drawable);
427
428 G_END_DECLS
429
430 #endif /* __GDK_DRAWABLE_H__ */