Re: why i can't set background of widget?
- From: Olexiy Avramchenko <olexiy irtech cn ua>
- To: gxw <szg309 sina com>
- Cc: gtk-app-devel <gtk-app-devel-list gnome org>
- Subject: Re: why i can't set background of widget?
- Date: Wed, 11 Feb 2004 10:39:59 +0200
gxw wrote:
After run the following simple code,the button background is black,and can't see "Hello World",who can tell
me the reason?
style=gtk_style_new();
style->bg[GTK_STATE_NORMAL].red=0;
style->bg[GTK_STATE_NORMAL].green=0;
style->bg[GTK_STATE_NORMAL].blue=255;
gtk_widget_set_style(button,style);
You just specifying r/g/b components of the color, try allocate color
before (this will set the pixel value). Better solution is to use
gtk_widget_modify_bg() function:
http://developer.gnome.org/doc/API/2.0/gtk/GtkWidget.html#gtk-widget-modify-bg
You can pass non-allocated color as parameter.
As for color allocation, look at:
http://developer.gnome.org/doc/API/2.0/gdk/gdk-Colormaps-and-Colors.html
Olexiy
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]