[Gtk-sharp-list] color in widgets

Richard Torkar richard.torkar@htu.se
Wed, 24 Sep 2003 10:19:53 +0200

On Wed, 2003-09-24 at 04:08, Miguel de Icaza wrote:
> Hello,
> > I have a small question about using color with widgets. When I use the
> > following code, I get a button with a red background. But when Button is
> > replaced by Label or Entry in this code, their background color is not
> > changed:
> > =====
> > Button e = new Button("I am a red button");
> > Gdk.Color c = new Gdk.Color();
> > Gdk.Color.Parse("red", ref c);
> > e.ModifyFg(StateType.Normal, c);
> > ========
> > 
> > Am I missing something here? (I compiled the latest Gtk version out of
> > CVS last friday, after the 0.11 release. Mono version= 0.26)
> The color is not allocated.  See the documnetation for T:Gdk.Colormap in
> Monodoc for examples.

I was myself bitten by this just the other day.

Is there any reason for why a developer should use AllocColor or
AllocColors directly? Isn't this something that really should be hidden
from a developer, and automatically performed in the background by the
framework, i.e. Gdk#.

It feels a bit 'amateurish' that a developer needs to do an AllocColor,
since the Gdk.Color object creation should/could be delayed until (s)he
does e.g.
Gdk.Color.Parse (Reflexion.Preferences.BackGroundColor, ref bgcolor);


Any thoughts on this? Couldn't it be hidden? Is there something I've


"UNIX is basically a simple operating system,
but you have to be a genius to understand the simplicity."