]> Pileus Git - ~andy/gtk/blob - gdk/gdkdraw.c
2c5c4e2630cbd0de9154ff8bfaf32ba1fae3a966
[~andy/gtk] / gdk / gdkdraw.c
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 #include "config.h"
28 #include <math.h>
29 #include <pango/pangocairo.h>
30 #include <gdk-pixbuf/gdk-pixbuf.h>
31 #include "gdkcairo.h"
32 #include "gdkdrawable.h"
33 #include "gdkinternals.h"
34 #include "gdkwindow.h"
35 #include "gdkscreen.h"
36 #include "gdkpixbuf.h"
37
38
39 G_DEFINE_ABSTRACT_TYPE (GdkDrawable, gdk_drawable, G_TYPE_OBJECT)
40
41 static void
42 gdk_drawable_class_init (GdkDrawableClass *klass)
43 {
44 }
45
46 static void
47 gdk_drawable_init (GdkDrawable *drawable)
48 {
49 }
50
51 /**
52  * gdk_drawable_get_clip_region:
53  * @drawable: a #GdkDrawable
54  * 
55  * Computes the region of a drawable that potentially can be written
56  * to by drawing primitives. This region will not take into account
57  * the clip region for the GC, and may also not take into account
58  * other factors such as if the window is obscured by other windows,
59  * but no area outside of this region will be affected by drawing
60  * primitives.
61  * 
62  * Returns: a #cairo_region_t. This must be freed with cairo_region_destroy()
63  *          when you are done.
64  **/
65 cairo_region_t *
66 gdk_drawable_get_clip_region (GdkDrawable *drawable)
67 {
68   g_return_val_if_fail (GDK_IS_DRAWABLE (drawable), NULL);
69
70   return GDK_DRAWABLE_GET_CLASS (drawable)->get_clip_region (drawable);
71 }
72
73 /**
74  * gdk_drawable_get_visible_region:
75  * @drawable: a #GdkDrawable
76  * 
77  * Computes the region of a drawable that is potentially visible.
78  * This does not necessarily take into account if the window is
79  * obscured by other windows, but no area outside of this region
80  * is visible.
81  * 
82  * Returns: a #cairo_region_t. This must be freed with cairo_region_destroy()
83  *          when you are done.
84  **/
85 cairo_region_t *
86 gdk_drawable_get_visible_region (GdkDrawable *drawable)
87 {
88   g_return_val_if_fail (GDK_IS_DRAWABLE (drawable), NULL);
89
90   return GDK_DRAWABLE_GET_CLASS (drawable)->get_visible_region (drawable);
91 }
92
93 /**
94  * _gdk_drawable_ref_cairo_surface:
95  * @drawable: a #GdkDrawable
96  * 
97  * Obtains a #cairo_surface_t for the given drawable. If a
98  * #cairo_surface_t for the drawable already exists, it will be
99  * referenced, otherwise a new surface will be created.
100  * 
101  * Return value: a newly referenced #cairo_surface_t that points
102  *  to @drawable. Unref with cairo_surface_destroy()
103  **/
104 cairo_surface_t *
105 _gdk_drawable_ref_cairo_surface (GdkDrawable *drawable)
106 {
107   g_return_val_if_fail (GDK_IS_DRAWABLE (drawable), NULL);
108
109   return GDK_DRAWABLE_GET_CLASS (drawable)->ref_cairo_surface (drawable);
110 }
111
112 /************************************************************************/
113
114 cairo_surface_t *
115 _gdk_drawable_create_cairo_surface (GdkDrawable *drawable,
116                                     int width,
117                                     int height)
118 {
119   return GDK_DRAWABLE_GET_CLASS (drawable)->create_cairo_surface (drawable,
120                                                                   width, height);
121 }