]> Pileus Git - ~andy/gtk/blobdiff - gdk/gdkpixmap.c
Fix typo, where x value was assigned to both x and y.
[~andy/gtk] / gdk / gdkpixmap.c
index 8b44d8728777cb25f811cadea3d5a6c3ae768766..5e757246fb2db886616a388f94b689e55d1ca0c9 100644 (file)
@@ -102,17 +102,32 @@ static void   gdk_pixmap_draw_image     (GdkDrawable     *drawable,
                                          gint             ydest,
                                          gint             width,
                                          gint             height);
+static void   gdk_pixmap_draw_pixbuf    (GdkDrawable     *drawable,
+                                        GdkGC           *gc,
+                                        GdkPixbuf       *pixbuf,
+                                        gint             src_x,
+                                        gint             src_y,
+                                        gint             dest_x,
+                                        gint             dest_y,
+                                        gint             width,
+                                        gint             height,
+                                        GdkRgbDither     dither,
+                                        gint             x_dither,
+                                        gint             y_dither);
+
 
 static void   gdk_pixmap_real_get_size  (GdkDrawable     *drawable,
                                          gint            *width,
                                          gint            *height);
 
-static GdkImage* gdk_pixmap_get_image   (GdkDrawable     *drawable,
-                                         gint             x,
-                                         gint             y,
-                                         gint             width,
-                                         gint             height);
-
+static GdkImage* gdk_pixmap_copy_to_image (GdkDrawable *drawable,
+                                          GdkImage    *image,
+                                          gint         src_x,
+                                          gint         src_y,
+                                          gint         dest_x,
+                                          gint         dest_y,
+                                          gint         width,
+                                          gint         height);
 
 static GdkVisual*   gdk_pixmap_real_get_visual   (GdkDrawable *drawable);
 static gint         gdk_pixmap_real_get_depth    (GdkDrawable *drawable);
@@ -148,7 +163,7 @@ gdk_pixmap_get_type (void)
       
       object_type = g_type_register_static (GDK_TYPE_DRAWABLE,
                                             "GdkPixmap",
-                                            &object_info);
+                                            &object_info, 0);
     }
   
   return object_type;
@@ -183,12 +198,13 @@ gdk_pixmap_class_init (GdkPixmapObjectClass *klass)
   drawable_class->draw_lines = gdk_pixmap_draw_lines;
   drawable_class->draw_glyphs = gdk_pixmap_draw_glyphs;
   drawable_class->draw_image = gdk_pixmap_draw_image;
+  drawable_class->_draw_pixbuf = gdk_pixmap_draw_pixbuf;
   drawable_class->get_depth = gdk_pixmap_real_get_depth;
   drawable_class->get_size = gdk_pixmap_real_get_size;
   drawable_class->set_colormap = gdk_pixmap_real_set_colormap;
   drawable_class->get_colormap = gdk_pixmap_real_get_colormap;
   drawable_class->get_visual = gdk_pixmap_real_get_visual;
-  drawable_class->get_image = gdk_pixmap_get_image;
+  drawable_class->_copy_to_image = gdk_pixmap_copy_to_image;
 }
 
 static void
@@ -367,6 +383,27 @@ gdk_pixmap_draw_image (GdkDrawable     *drawable,
                   width, height);
 }
 
+static void
+gdk_pixmap_draw_pixbuf (GdkDrawable     *drawable,
+                       GdkGC           *gc,
+                       GdkPixbuf       *pixbuf,
+                       gint             src_x,
+                       gint             src_y,
+                       gint             dest_x,
+                       gint             dest_y,
+                       gint             width,
+                       gint             height,
+                       GdkRgbDither     dither,
+                       gint             x_dither,
+                       gint             y_dither)
+{
+  GdkPixmapObject *private = (GdkPixmapObject *)drawable;
+
+  _gdk_draw_pixbuf (private->impl, gc, pixbuf,
+                   src_x, src_y, dest_x, dest_y, width, height,
+                   dither, x_dither, y_dither);
+}
+
 static void
 gdk_pixmap_real_get_size (GdkDrawable *drawable,
                           gint *width,
@@ -419,16 +456,40 @@ gdk_pixmap_real_get_colormap (GdkDrawable *drawable)
 }
 
 static GdkImage*
-gdk_pixmap_get_image (GdkDrawable     *drawable,
-                      gint             x,
-                      gint             y,
-                      gint             width,
-                      gint             height)
+gdk_pixmap_copy_to_image (GdkDrawable     *drawable,
+                         GdkImage        *image,
+                         gint             src_x,
+                         gint             src_y,
+                         gint             dest_x,
+                         gint             dest_y,
+                         gint             width,
+                         gint             height)
 {
   g_return_val_if_fail (GDK_IS_PIXMAP (drawable), NULL);
   
-  return gdk_drawable_get_image (((GdkPixmapObject*)drawable)->impl,
-                                 x, y, width, height);
+  return _gdk_drawable_copy_to_image (((GdkPixmapObject*)drawable)->impl,
+                                     image,
+                                     src_x, src_y, dest_x, dest_y,
+                                     width, height);
+}
+
+static GdkBitmap *
+make_solid_mask (gint width, gint height)
+{
+  GdkBitmap *bitmap;
+  GdkGC *gc;
+  GdkGCValues gc_values;
+  
+  bitmap = gdk_pixmap_new (NULL, width, height, 1);
+
+  gc_values.foreground.pixel = 1;
+  gc = gdk_gc_new_with_values (bitmap, &gc_values, GDK_GC_FOREGROUND);
+  
+  gdk_draw_rectangle (bitmap, gc, TRUE, 0, 0, width, height);
+  
+  gdk_gc_unref (gc);
+  
+  return bitmap;
 }
 
 #define PACKED_COLOR(c) ((((c)->red & 0xff) << 8) | ((c)->green & 0xff) | ((c)->blue >> 8))
@@ -474,6 +535,10 @@ gdk_pixmap_colormap_new_from_pixbuf (GdkColormap *colormap,
   if (mask)
     gdk_pixbuf_render_pixmap_and_mask (pixbuf, NULL, mask, 128);
 
+  if (mask && !*mask)
+    *mask = make_solid_mask (gdk_pixbuf_get_width (pixbuf),
+                            gdk_pixbuf_get_height (pixbuf));
+
   return pixmap;
 }
 
@@ -499,8 +564,9 @@ gdk_pixmap_colormap_create_from_xpm (GdkWindow   *window,
     return NULL;
 
   pixmap = gdk_pixmap_colormap_new_from_pixbuf (colormap, mask, transparent_color, pixbuf);
-  gdk_pixbuf_unref (pixbuf);
 
+  gdk_pixbuf_unref (pixbuf);
+  
   return pixmap;
 }
 
@@ -536,6 +602,7 @@ gdk_pixmap_colormap_create_from_xpm_d (GdkWindow  *window,
     return NULL;
 
   pixmap = gdk_pixmap_colormap_new_from_pixbuf (colormap, mask, transparent_color, pixbuf);
+
   gdk_pixbuf_unref (pixbuf);
 
   return pixmap;