Re: How to use the GdkColor.pixel



On Thu, 2003-12-11 at 11:02, Tom Liu wrote:
I use the gdk_color_alloc to get the pixel for a color. 
When I use the pixel to set the color, it doesn't work, 
When I just set red,green,blue, it will work.

        GdkColormap* sysmap=gdk_colormap_get_system();
        GdkColor color;
        if (gdk_color_parse   ("#FF0000",&color)) {
                gdk_color_alloc (sysmap,&color) ;
        }
        color.red=0;color.blue=0;color.green=0;
        printf("color:%d\n",color.pixel);
        gtk_widget_modify_bg(widg,GTK_STATE_NORMAL,&color);

looks color.pixel is useless, is that true?

General rule (with a few exceptions is):

 GTK+ functions take unallocated colors
 GDK functions take allocated colors 

An unallocated color means that the 'pixel' field is unused
and will be determined by GTK+.

E.g., the docs for gtk_widget_modify_bg say:

 * @color: the color to assign (does not need to be allocated),
 *         or %NULL to undo the effect of previous calls to
 *         of gtk_widget_modify_bg().

Regards,
                                                Owen





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