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/.
31 /* Needed for SEEK_END in SunOS */
34 #include "gdkpixmap.h"
36 #include "gdkprivate-fb.h"
48 GdkColormap *colormap;
52 static gpointer parent_class = NULL;
55 gdk_pixmap_impl_fb_init (GdkPixmapFBData *impl)
57 GdkDrawableFBData *private = (GdkDrawableFBData *)impl;
59 private->window_type = GDK_DRAWABLE_PIXMAP;
60 private->colormap = gdk_colormap_ref (gdk_colormap_get_system());
67 gdk_pixmap_impl_fb_finalize (GObject *object)
69 g_free (GDK_DRAWABLE_FBDATA (object)->mem);
71 G_OBJECT_CLASS (parent_class)->finalize (object);
75 gdk_pixmap_impl_fb_class_init (GdkPixmapFBClass *klass)
77 GObjectClass *object_class = G_OBJECT_CLASS (klass);
78 /* GdkDrawableClass *drawable_class = GDK_DRAWABLE_CLASS (klass); */
80 parent_class = g_type_class_peek_parent (klass);
82 object_class->finalize = gdk_pixmap_impl_fb_finalize;
86 _gdk_pixmap_impl_get_type (void)
88 static GType object_type = 0;
92 static const GTypeInfo object_info =
94 sizeof (GdkPixmapFBClass),
96 (GBaseFinalizeFunc) NULL,
97 (GClassInitFunc) gdk_pixmap_impl_fb_class_init,
98 NULL, /* class_finalize */
99 NULL, /* class_data */
100 sizeof (GdkPixmapFBData),
102 (GInstanceInitFunc) gdk_pixmap_impl_fb_init
105 object_type = g_type_register_static (gdk_drawable_impl_fb_get_type(),
115 gdk_pixmap_new (GdkWindow *window,
121 GdkDrawableFBData *private;
123 g_return_val_if_fail (window == NULL || GDK_IS_WINDOW (window), NULL);
124 g_return_val_if_fail ((window != NULL) || (depth != -1), NULL);
125 g_return_val_if_fail ((width != 0) && (height != 0), NULL);
128 window = _gdk_parent_root;
131 depth = gdk_drawable_get_visual (window)->depth;
133 pixmap = (GdkPixmap *)g_object_new (gdk_pixmap_get_type (), NULL);
134 private = GDK_DRAWABLE_IMPL_FBDATA (pixmap);
135 private->rowstride = (width * depth + 7) / 8; /* Round up to nearest whole byte */
136 private->mem = g_malloc (private->rowstride * height);
141 private->lim_x = width;
142 private->lim_y = height;
143 private->width = width;
144 private->height = height;
145 private->depth = ((GdkPixmapObject *)pixmap)->depth = depth;
151 gdk_bitmap_create_from_data (GdkWindow *window,
158 g_return_val_if_fail (data != NULL, NULL);
159 g_return_val_if_fail ((width != 0) && (height != 0), NULL);
160 g_return_val_if_fail (window == NULL || GDK_IS_WINDOW (window), NULL);
163 window = _gdk_parent_root;
165 pixmap = gdk_pixmap_new (window, width, height, 1);
167 memcpy (GDK_DRAWABLE_IMPL_FBDATA (pixmap)->mem, data, ((width + 7) / 8) * height);
173 gdk_pixmap_create_from_data (GdkWindow *window,
183 g_return_val_if_fail (window == NULL || GDK_IS_WINDOW (window), NULL);
184 g_return_val_if_fail (data != NULL, NULL);
185 g_return_val_if_fail (fg != NULL, NULL);
186 g_return_val_if_fail (bg != NULL, NULL);
187 g_return_val_if_fail ((window != NULL) || (depth != -1), NULL);
188 g_return_val_if_fail ((width != 0) && (height != 0), NULL);
191 window = _gdk_parent_root;
194 depth = gdk_drawable_get_visual (window)->depth;
196 pixmap = gdk_pixmap_new (window, width, height, depth);
198 memcpy (GDK_DRAWABLE_IMPL_FBDATA (pixmap)->mem, data, height * GDK_DRAWABLE_IMPL_FBDATA (pixmap)->rowstride);
204 gdk_pixmap_foreign_new (GdkNativeWindow anid)
206 return (GdkPixmap*) gdk_drawable_ref (anid);
210 gdk_pixmap_lookup (GdkNativeWindow anid)
212 return (GdkPixmap*) (anid);