Re: changing a widget's color at runtime
- From: Paul Barton-Davis <pbd Op Net>
- To: Patrick Schweiger <pks timing com>
- Cc: gtk-list gnome org
- Subject: Re: changing a widget's color at runtime
- Date: Mon, 13 Nov 2000 18:01:09 -0500
>My question was anserwed last time and nobody complained about the fact
>that it was gtk--, please tell me to go away (and preferably where to go)
>if gtk-- questions bug you.
gtkmm-main lists sourceforge net
but this is a GTK level question, even if the code itself is Gtk--.
>I'm changing a widget's (label in particular) color at run time and am
>using the following code to do so:
>
>void some_cute_class_name::set_status_lbl_color(const Gdk_Color &color) {
>
> Gtk::Style *cur_style = status_lbl_1->get_style();
>
> cur_style = cur_style->copy();
> cur_style->set_fg(GTK_STATE_NORMAL, color);
>
> status_lbl_1->set_style(*cur_style);
> status_lbl_2->set_style(*cur_style);
>
>This works, but it leaves me with these questions:
Repeating myself again: please don't do this. Use
status_lbl1->set_name ("StatusLabel");
status_lbl2->set_name ("StatusLabel");
and then load a GTK RC file with:
style "status_label" {
fg[NORMAL] = { 0.93, 0.94, 0.23 }
}
widget "*StatusLabel" style "status_label"
this allows and your users to change the colors at run time without
any recompilation. as a side effect, it also removes a bunch of ugly
code from your app :)
--p
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]