Hello.
I have question - how to change color of checkbutton background properly
(background of small square where check-sign is placed)?
Look at this function:
void CustomCheckBox::set_background( const Gdk::Color& color )
{
if( Gtk::Widget* w = get_focus_widget() )
{
static Glib::RefPtr< Gtk::RcStyle > default_style( 0 );
const Glib::RefPtr< Gtk::RcStyle > modifier_style =
w->get_modifier_style();
if( !default_style )
{
default_style = modifier_style->copy();
default_style->reference();
}
if( color != Gdk::Color() )
{
modifier_style->set_color_flags( Gtk::STATE_NORMAL,
Gtk::RC_BG );
modifier_style->set_bg( Gtk::STATE_NORMAL, color );
w->modify_style( modifier_style );
// this row used only for checkbutton, otherwise set_bg has no effect
w->get_style()->set_white( color );
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
}
else
{
w->modify_style( default_style );
}
}
}
It works well for any widget except checkbutton. Of course I am using
Gtk::RcStyle::set_base() for widgets that derived from Entry. The
problem with checkbutton is that it won't change background just on
widget creation, some later (when window "completelly" shown) it works
well.
I tried to override on_style_changed() method to call set_background
from there on widget creation - no luck.
Any help would be appreciated.
thanks in advance,
-andrew
_______________________________________________
gtkmm-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/gtkmm-list