GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Fri Apr 25, 2014 1:31 am

All times are UTC




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: [SOLVED] How do I change the color of a frame label?
PostPosted: Sat Dec 29, 2012 4:23 am 
Offline
Familiar Face

Joined: Sun Aug 12, 2012 7:11 pm
Posts: 5
I am creating an simple gtkmm program that han an Gtk::Entry inside an Gtk::Frame. I want the frame label to go red when the text in the entry is changed.

I already know how to deal with the signals. I just need to know whan method shoud I call in order to change the color of the frame label.

Thank you!


Last edited by Colgax on Wed Jan 02, 2013 8:52 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: How do I change the color of a frame label?
PostPosted: Wed Jan 02, 2013 1:19 am 
Offline
Familiar Face

Joined: Sun Aug 12, 2012 7:11 pm
Posts: 5
No one?


Top
 Profile  
 
 Post subject: Re: How do I change the color of a frame label?
PostPosted: Wed Jan 02, 2013 8:20 am 
Offline
Never Seen the Sunlight

Joined: Mon Apr 28, 2008 5:52 am
Posts: 709
Location: UK
Hello,

If all you want to do is set the text of the label on the frame to red then, my thought is to do some thing like this.
Code:
...
  Gtk::Label * frame_label = dynamic_cast<Gtk::Label *>(frame_widget.get_label_widget());
  if (frame_label)
    frame_label->set_markup("<span foreground="red">Red Text</span>");
...
Note that I have not tested this

As an additional note do not depend on the colour of an object to give all the feedback to the user. In this case the user may have colour blindness which affects red so would not see any visible change.

_________________
E.


Top
 Profile  
 
 Post subject: Re: How do I change the color of a frame label?
PostPosted: Wed Jan 02, 2013 8:50 am 
Offline
Familiar Face

Joined: Sun Aug 12, 2012 7:11 pm
Posts: 5
Hello

Thank you for your answer. It didn't work quite like that because get_label returns a const, but it made me find out that I could set the label widget directly using set_label_widget, which solved my problem.

Also, thank you for the tip about the color blindness. Now it also adds an asterisk in the end of the label when the entry is changed.

Thank you! =D


Top
 Profile  
 
 Post subject: Re: [SOLVED] How do I change the color of a frame label?
PostPosted: Wed Jan 02, 2013 9:05 am 
Offline
Never Seen the Sunlight

Joined: Mon Apr 28, 2008 5:52 am
Posts: 709
Location: UK
Sorry,

get_label() should have read get_label_widget().

_________________
E.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group