RE: How to use the GdkColor.pixel
- From: "Tom Liu" <tom liu flextrade com>
- To: "'Owen Taylor'" <otaylor redhat com>
- Cc: <gtk-app-devel-list gnome org>
- Subject: RE: How to use the GdkColor.pixel
- Date: Thu, 11 Dec 2003 12:14:12 -0500
Thanks!, I understand now.
But, how to get the rgb value of a allocated color? In my application, I
allocated a lot of color when I start program, should I use RGB value?
How about for performance? Every time to use GdkColor in GTK+,
internally it need to go alloc the color, will this slow down?
-----Original Message-----
From: gtk-app-devel-list-admin gnome org
[mailto:gtk-app-devel-list-admin gnome org] On Behalf Of Owen Taylor
Sent: Thursday, December 11, 2003 11:53 AM
To: Tom Liu
Cc: gtk-app-devel-list gnome org
Subject: 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
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]