[Gtk-sharp-list] Background Coloring: Tables, HBoxes, VBoxes
Michael Hutchinson
m.j.hutchinson at gmail.com
Tue Mar 21 13:03:20 EST 2006
On 3/21/06, Graham Oneale <graham at resonline.com.au> wrote:
>
> Is it possible to set a background color on any of these widgets?
>
> I have an application in which certain container objects will require a
> background color and foreground color.
http://ometer.com/gtk-colors.html has some useful info.
It can sometimes be tricky to determine where a widget is getting its
colour choice from, whether it's using Fg, Base, or Bg, and which
state it's using.
It's made harder when some widgets simply defer to the background of
the widgets behind them. Tthis is the case with containers' borders.
Try the following code:
using System;
using Gtk;
class WindowTester {
static void Main ()
{
Application.Init ();
Window window = new Window ("This is a window");
window.DeleteEvent += delegate {Application.Quit ();};
window.SetDefaultSize (200, 200);
Table tab = new Table (2, 2, true);
window.Add (tab);
tab.BorderWidth = 10;
tab.Attach (new Button ("One"), 0, 1, 0, 1);
tab.Attach (new Button ("Two"), 0, 1, 1, 2);
tab.Attach (new Button ("Three"), 1, 2, 0, 2);
window.ModifyBg (StateType.Normal, new Gdk.Color(255, 0, 0));
window.ShowAll ();
Application.Run ();
}
}
Hope this helps,
Michael Hutchinson
More information about the Gtk-sharp-list
mailing list