Re: Changing the background color of a window



On Tue, Feb 25, 2003 at 11:21:56PM -0500, José Vitor de Santana wrote:
 
>      color.red = g_rand_int_range(my_rand,0,256);
>      color.green = g_rand_int_range(my_rand,0,256);
>      color.blue = g_rand_int_range(my_rand,0,256);

You still have 256 here not 65536

>      gdk_rgb_find_color(gtk_widget_get_colormap(w),
>         &color);
> 
>      g_print("color: pixel=%08X red=%02X green=%02X"
>         "blue=%02X\n",color.pixel,color.red,
>         color.green,color.blue);
> 
>      gdk_gc_set_foreground(
>          w->style->bg_gc[GTK_STATE_NORMAL],&color);

instead of find_color then gdk_gc_set_foreground, 
you could just use gdk_gc_set_rgb_fg_color().

>      gtk_widget_queue_draw_area(w,0,0,cfg->width,
>         cfg->height);

The bg_gc color will be reset by GTK before drawing. 
To make setting a GC color do something, you have to 
do your own drawing (with the gdk_draw_* functions).
 
>   Pixel.color always gets zero after
>      gdk_rgb_find_color.

Because you do 0-256 so you are pretty much always asking for "black"

Havoc



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