Re: [gtk-list] Setting Widget Attributes (Half Solution)
- From: johannes nada kth se (Johannes Keukelaar)
- To: gtk-list redhat com
- Subject: Re: [gtk-list] Setting Widget Attributes (Half Solution)
- Date: Tue, 02 Jun 1998 17:14:28 +0200
//foreGroundColor->red = 0;
//foreGroundColor->green = 200 * (65535/255);
//foreGroundColor->blue = 0;
//
//backGroundColor->red = 0;
//backGroundColor->green = 0;
//backGroundColor->blue = 0;
//
//LabelStyle->fg[0] = *foreGroundColor;
//LabelStyle->bg[0] = *backGroundColor;
You'll probably want to do gdk_color_alloc, as well. (You may have to
initialize the pixel value before calling gdk_color_alloc, I'm kind of vague
about that.) I quote the following from the FAQ:
/* the color we want to use */
color = (GdkColor *)malloc(sizeof(GdkColor));
/* red, green, and blue are passed values, indicating the RGB triple
* of the color we want to draw. Note that the values of the RGB components
* within the GdkColor are taken from 0 to 65535, not 0 to 255.
*/
color->red = red * (65535/255);
color->green = green * (65535/255);
color->blue = blue * (65535/255);
/* the pixel value indicates the index in the colormap of the color.
* it is simply a combination of the RGB values we set earlier
*/
color->pixel = (gulong)(red*65536 + green*256 + blue);
/* However, the pixel valule is only truly valid on 24-bit (TrueColor)
* displays. Therefore, this call is required so that GDK and X can
* give us the closest color available in the colormap
*/
gdk_color_alloc(gtk_widget_get_colormap(widget), color);
Regards,
Johannes.
--
"The older I grow, the more I distrust the familiar doctrine that age
brings wisdom." -- H.L. Mencken
<insert funny description here>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]