Re: modify_style(Gtk::rcStyle) --VS-- set_style(Gtk::Style)

On Tue, 2008-01-22 at 10:05 +0100, Yannick Barbeaux wrote:
> Hello
> i am working with gtkmm 2.4 and i am trying to modify the colors of
> given widgets in my application,
> the gtkmm documentation advices to use 
> widget->modify_style(Gtk::RcStyle myRcStyle)
> function instead of 
> widget->set_style(Gtk::Style myStyle) 
> (because "it interacts badly with themes"?)
> the strange behaviour I found out is that using the modify_style has
> no effects in my application:
> e.g.: 
> I create a new rcStyle with the static create function:
> Glib::RefPtr<Gtk::RcStyle> myRcStyle = Gtk::RcStyle::create();
> then change the colors e.g.:
> myRcStyle->set_bg(Gtk::STATE_NORMAL, anyGdkColor); 
> then set the style to the main window or any widget:
> mainWindow->modify_style(myRcStyle);
> or
> myPushButton->modify_style(myRcStyle);

why not just use Widget::modify_fg() ?

moreover, why do this in code at all? just name the widgets
(Widget::set_name()), and load an app-specific RC file that defines the
styles. that way you can modify the styles without a recompile.

> then change the colors the same way e.g.:
> myStyle->set_bg(Gtk::STATE_NORMAL, anyGdkColor);
> then set the style to the widget ;
> main_window->set_style(myStyle);
> or
> myPushButton->set_style(myStyle);

you are aware, i hope, that many widgets do not have their own window,
and thus setting the bg for them has no effect - they just draw
themselves on an existing bg.

> And to be more general, why do exist two classes Style and RcStyle
> with many common functions?
> What is the specific use of each class? is there a correspondance
> between those 2 classes?

RcStyle represents the definition of a style taken from an RC file. it
is held separately from a Style (the style as used by the widget) so as
to (a) allow for slightly different representation based on its origin
in the file (b) to allow heirarchical inheritance of RcStyles while
compositing a particular widget's Style.

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