Simple draw question



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

I have a situation where I need to highlight an eventbox when a user
enters it and unhighlight it when the users leaves. I'm using this code
but the color I'm drawing in the leave_button_callback is always wrong
and varies from run to run with the program. Any ideas what I am doing
wrong. I was looking for a XOR option or something but I don't see it.

gboolean enter_button_callback (GtkWidget *widget, GdkEventCrossing
*event, gpointer data)
{
        GdkGC *gc;
        gc = gdk_gc_new(widget->window);
    gdk_draw_rectangle(widget->window, gc, FALSE, 0, 0,
widget->allocation.width-1,
                           widget->allocation.height-1);
    gdk_gc_unref(gc);

        return FALSE;
}

gboolean leave_button_callback (GtkWidget *widget, GdkEventCrossing
*event, gpointer data)
{
        GdkGC *gc;
        GdkGCValues v;
        GdkColor color;
        GdkColormap *map;
        
        gc = gdk_gc_new(widget->window);
        map = gdk_gc_get_colormap(gc);
        gdk_gc_get_values(gc,&v);
        gdk_colormap_query_color(map,v.background.pixel,&color);
        
        gdk_gc_set_foreground(gc,&color);
        
    gdk_draw_rectangle(widget->window, gc, FALSE, 0, 0,
widget->allocation.width-1,
                           widget->allocation.height-1);
    gdk_gc_unref(gc);
        return FALSE;
}




- --
Get my public GnuPG key from
http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x7D0BD5D1
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)
Comment: Using GnuPG with Remi - http://enigmail.mozdev.org

iD8DBQFGO7gy6w2kMH0L1dERAqmZAJ0UORbfl3tgr0wRdruDvk8yRNUrOwCbB/LQ
HwpMx+9hMb9iGwEX6WCr+KM=
=hEvS
-----END PGP SIGNATURE-----



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