[Gtk-sharp-list] Setting HBox background to white

Clark Endrizzi cendrizzi at gmail.com
Sun Nov 13 12:55:24 EST 2005

Hi all.

In my application I'm trying to set the background of an HBox to white
(currently it is the default theme grey and doesn't look good at all). I am
still very much learning gtk but have asked on IRC and have tried many
different things but it doesn't do anything.

I have a hbox based class that I'm calling this on the contructor:
this.ModifyBase(StateType.Normal, new Gdk.Color(0xff,0xff,0xff));

I was hoping it was as easy as specifying the background color like this but
apparently it isn't (the documentation seems to say this will do this trick)

I've also tried ModifyBG with no luck. I have just been finding bits and
pieces to I'm kinda doing this blindly. For example, I have no idea what
those values are that are used to define the color, is there a way to simply
use RGB (with the normal range used in web development, etc). Could it be
that the theme overides everything?

Libview, from vmware, does something similar but I have no clue how to adapt
BaseBGBox::on_expose_event(GdkEventExpose *event) // IN
if (is_drawable()) {
const Gtk::Allocation allocation(get_allocation());

// Don't cache the gc to avoid worrying about style changes.
Glib::RefPtr<Gtk::Style> style = get_style();
Gtk::StateType state = get_state();
Glib::RefPtr<Gdk::GC> gc;
switch (mPalette) {
case BASE:
gc = style->get_base_gc(state);
case BG:
gc = style->get_bg_gc(state);
case FG:
gc = style->get_fg_gc(state);
get_window()->draw_rectangle(gc, true,
allocation.get_x(), allocation.get_y(),
allocation.get_width(), allocation.get_height());
return Gtk::HBox::on_expose_event(event);

Instead of using a background color they appear to draw a rectangly, kinda
seems hackish but it that's whats required...

Also within this HBox is also several child vboxes, would I have to set each
one with their own color too or are HBoxes and VBoxes trasparent by default?

Thanks a lot!
-Clark Endrizzi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/gtk-sharp-list/attachments/20051113/6ea15c3f/attachment.html

More information about the Gtk-sharp-list mailing list