can't change color of label



Hello!

I am new to GTK, and GTKmm.
I use gtkmm 2.4 on windows-xp.
I'm trying to change the color of a label.
I managed to do it using the C interface using the code:

GtkLabel* gtkLabel = label->gobj();
GdkColor color;
gdk_color_parse ("red", &color);
gtk_widget_modify_fg ((GtkWidget*)gtkLabel, GTK_STATE_NORMAL, &color);


but when I try to use the c++ interface the label remains black, using this code:

Gdk::Color* color = new Gdk::Color("red");
Glib::RefPtr<Gdk::Colormap> colorMap=Gdk::Colormap::get_system();
colorMap->alloc_color(*color, true, true);
label->modify_fg(Gtk::STATE_NORMAL, color);

I tried also to inilize the color using set_rgb, or without allocating it, or to use modify_text, and modify_base, or to create a style and use modify_style, or use label->set_state(Gtk::STATE_NORMAL); or use label->set_use_markup(false);
but to no avail, it still remains black.

Thanks,

Oded.



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