1 /* GDK - The GIMP Drawing Kit
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
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.
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.
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.
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/.
28 #include "gdkpixmap.h"
29 #include "gdkinternals.h"
30 #include "gdkpixbuf.h"
31 #include "gdkscreen.h"
34 static void gdk_pixmap_real_get_size (GdkDrawable *drawable,
38 static cairo_surface_t *gdk_pixmap_ref_cairo_surface (GdkDrawable *drawable);
39 static cairo_surface_t *gdk_pixmap_create_cairo_surface (GdkDrawable *drawable,
43 static GdkVisual* gdk_pixmap_real_get_visual (GdkDrawable *drawable);
44 static gint gdk_pixmap_real_get_depth (GdkDrawable *drawable);
45 static void gdk_pixmap_real_set_colormap (GdkDrawable *drawable,
47 static GdkColormap* gdk_pixmap_real_get_colormap (GdkDrawable *drawable);
48 static GdkScreen* gdk_pixmap_real_get_screen (GdkDrawable *drawable);
50 static void gdk_pixmap_init (GdkPixmapObject *pixmap);
51 static void gdk_pixmap_class_init (GdkPixmapObjectClass *klass);
52 static void gdk_pixmap_finalize (GObject *object);
54 static gpointer parent_class = NULL;
57 gdk_pixmap_get_type (void)
59 static GType object_type = 0;
62 object_type = g_type_register_static_simple (GDK_TYPE_DRAWABLE,
64 sizeof (GdkPixmapObjectClass),
65 (GClassInitFunc) gdk_pixmap_class_init,
66 sizeof (GdkPixmapObject),
67 (GInstanceInitFunc) gdk_pixmap_init,
74 gdk_pixmap_init (GdkPixmapObject *pixmap)
76 /* 0-initialization is good for all other fields. */
77 pixmap->impl = g_object_new (_gdk_pixmap_impl_get_type (), NULL);
81 gdk_pixmap_class_init (GdkPixmapObjectClass *klass)
83 GObjectClass *object_class = G_OBJECT_CLASS (klass);
84 GdkDrawableClass *drawable_class = GDK_DRAWABLE_CLASS (klass);
86 parent_class = g_type_class_peek_parent (klass);
88 object_class->finalize = gdk_pixmap_finalize;
90 drawable_class->get_depth = gdk_pixmap_real_get_depth;
91 drawable_class->get_screen = gdk_pixmap_real_get_screen;
92 drawable_class->get_size = gdk_pixmap_real_get_size;
93 drawable_class->set_colormap = gdk_pixmap_real_set_colormap;
94 drawable_class->get_colormap = gdk_pixmap_real_get_colormap;
95 drawable_class->get_visual = gdk_pixmap_real_get_visual;
96 drawable_class->ref_cairo_surface = gdk_pixmap_ref_cairo_surface;
97 drawable_class->create_cairo_surface = gdk_pixmap_create_cairo_surface;
101 gdk_pixmap_finalize (GObject *object)
103 GdkPixmapObject *obj = (GdkPixmapObject *) object;
105 g_object_unref (obj->impl);
108 G_OBJECT_CLASS (parent_class)->finalize (object);
112 gdk_pixmap_new (GdkDrawable *drawable,
117 GdkDrawable *source_drawable;
120 source_drawable = _gdk_drawable_get_source_drawable (drawable);
122 source_drawable = NULL;
123 return _gdk_pixmap_new (source_drawable, width, height, depth);
127 gdk_pixmap_real_get_size (GdkDrawable *drawable,
131 g_return_if_fail (GDK_IS_PIXMAP (drawable));
133 gdk_drawable_get_size (GDK_DRAWABLE (((GdkPixmapObject*)drawable)->impl),
138 gdk_pixmap_real_get_visual (GdkDrawable *drawable)
140 GdkColormap *colormap;
142 g_return_val_if_fail (GDK_IS_PIXMAP (drawable), NULL);
144 colormap = gdk_drawable_get_colormap (drawable);
145 return colormap ? gdk_colormap_get_visual (colormap) : NULL;
149 gdk_pixmap_real_get_depth (GdkDrawable *drawable)
153 g_return_val_if_fail (GDK_IS_PIXMAP (drawable), 0);
155 depth = GDK_PIXMAP_OBJECT (drawable)->depth;
161 gdk_pixmap_real_set_colormap (GdkDrawable *drawable,
164 g_return_if_fail (GDK_IS_PIXMAP (drawable));
166 gdk_drawable_set_colormap (((GdkPixmapObject*)drawable)->impl, cmap);
170 gdk_pixmap_real_get_colormap (GdkDrawable *drawable)
172 g_return_val_if_fail (GDK_IS_PIXMAP (drawable), NULL);
174 return gdk_drawable_get_colormap (((GdkPixmapObject*)drawable)->impl);
177 static cairo_surface_t *
178 gdk_pixmap_ref_cairo_surface (GdkDrawable *drawable)
180 return _gdk_drawable_ref_cairo_surface (((GdkPixmapObject*)drawable)->impl);
183 static cairo_surface_t *
184 gdk_pixmap_create_cairo_surface (GdkDrawable *drawable,
188 return _gdk_drawable_create_cairo_surface (GDK_PIXMAP_OBJECT(drawable)->impl,
193 gdk_pixmap_real_get_screen (GdkDrawable *drawable)
195 return gdk_drawable_get_screen (GDK_PIXMAP_OBJECT (drawable)->impl);