GtkPixmap patch for large pixmaps



Currently, if the minimum size of a pixmap is set
smaller that the actual size of the pixmap, the
pixmap is drawn over other widgets. This simple
patch sets the source region in the call to
gdk_draw_pixmap to draw only in the allocated area.

This seems like the right thing to do.

Sam


*** gtk+-1.2.7.old/gtk/gtkpixmap.c      Wed Feb 24 02:15:10 1999
--- gtk+-1.2.7/gtk/gtkpixmap.c  Mon Apr 24 14:57:00 2000
***************
*** 189,194 ****
--- 189,195 ----
    GtkPixmap *pixmap;
    GtkMisc *misc;
    gint x, y;
+   gint src_x, src_y, src_width, src_height;
  
    g_return_val_if_fail (widget != NULL, FALSE);
    g_return_val_if_fail (GTK_IS_PIXMAP (widget), FALSE);
***************
*** 214,219 ****
--- 215,244 ----
          gdk_gc_set_clip_origin (widget->style->black_gc, x, y);
        }
  
+         if (x < widget->allocation.x)
+     {
+       src_x = widget->allocation.x - x;
+         x += src_x;
+       src_width = widget->allocation.width;
+     }
+       else
+     {
+         src_x = 0;
+       src_width = -1;
+     }   
+ 
+         if (y < widget->allocation.y)
+     {
+       src_y = widget->allocation.y - y;
+         y += src_y;
+       src_height = widget->allocation.height;
+     }
+       else
+     {
+         src_y = 0;
+         src_height = -1;
+     }
+ 
        if (GTK_WIDGET_STATE (widget) == GTK_STATE_INSENSITIVE
            && pixmap->build_insensitive)
          {
***************
*** 222,235 ****
            gdk_draw_pixmap (widget->window,
                           widget->style->black_gc,
                           pixmap->pixmap_insensitive,
!                          0, 0, x, y, -1, -1);
          }
        else
        {
            gdk_draw_pixmap (widget->window,
                           widget->style->black_gc,
                           pixmap->pixmap,
!                          0, 0, x, y, -1, -1);
        }
  
        if (pixmap->mask)
--- 247,260 ----
            gdk_draw_pixmap (widget->window,
                           widget->style->black_gc,
                           pixmap->pixmap_insensitive,
!                          src_x, src_y, x, y, src_width, src_height);
          }
        else
        {
            gdk_draw_pixmap (widget->window,
                           widget->style->black_gc,
                           pixmap->pixmap,
!                          src_x, src_y, x, y, src_width, src_height);
        }
  
        if (pixmap->mask)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]