Re: Changing background colors



There is a link on Gtk website for the documet: 
http://ometer.com/gtk-colors.html. However, there probably doesn't exist  a 
detailed document about which UI property(fg, bg, text, etc) is valid for 
which widget, and how to change each of them. 

As described in that document, if you want to change background of a label, 
you can place the label into somethinkg like GtkEventBox or GtkFixed(with 
has_window flag set true), and change the bg color of the container. A more 
neat way, I think, can be writing a customized label widget by encapsulating 
the above details.

Another example is text color of button. GtkButton doesn't has built in 
support for text, instead, it does that by placing a GtkLabel into the 
button. So if you want to change the color of text, you need to change the 
text color for that label. I found this method is very inconvenient, because 
it conflicts user(app developer)'s intuitive thinking and forces them to 
check widget implementation details. 

As for the method gdk_gc_set_background(), my understanding is that it is 
useless at all. The reason is that when you pass a GC to drawing primitives 
like gdk_draw_rectangle/lines/points, they all use the "foreground" color of 
that GC to draw, so the "background" value set by gdk_gc_set_background() is 
never used. (gtk_widget_modify_bg() works indeed, because it first "caches" 
the bg value into style->bg[state}, and then assign it to "forground" color 
of background GC associated with this style object.)

Hope it helps.

On Tuesday 11 May 2004 07:07, lrcgtk red4est com wrote:
> I'm working on a project at work, and writing the user interface in gtk.
>
> The specifications for the program include that it look like the previous
> generation program. Therefore, the software has to have black background.
>
> Gtk seems to REALLY  want grey backgrounds. I've tried playing around with
> my .gtkrc file, but can only get some of the fields to turn black.
> A lot of times I can get the foreground color to change, but not the
> background color.
>
> I've seen hints that some widgets (like labels) don't have a background
> color and that you have to change the background on the parent.
> However, I can't seem to find anything that documents which
> characteristics: fg, bg, base, text are active on which widgets. Since I've
> now spent about two weeks on something that should have taken me about two
> hours, I'm in a bit of trouble, and would greatly appreciate some pointers
> to documentation.
>
> I tried doing a test program of just some of the plotting features
> that I'm trying to implement, and while gtk_gc_set_foreground() works
>  just fine, gtk_gc_set_background has no apparent effect.
>
> Thanks
>    Larry Colen
>    lrc red4est com
> _______________________________________________
> gtk-list mailing list
> gtk-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtk-list



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