|
View:
New views
2 Messages
—
Rating Filter:
Alert me
|
|
|
The width of a Label.Dear all,
After I change the text of a Label I would like to know what the width of the Label is going to become. If I call the get_width() method it only gives the right width if the text is changed is such a way that the width does not change. If the width actually changes by modifying the text then get_width() always returns the value 1. (This may have something to do with the fact that the set_label() method is called from an event handler.) Maybe there is a Pango call to find out the width that some text is going to have? The reason that I want to know this is that I have a Label of which the text needs to change very frequently. The width of this Label is one of the things that determines the width of my window. I don't like the fact that changing the text of the label results in a change of the width of the window all the time. Therefore, I would like to allow the window to grow when the text doesn't fit anymore but not to shrink when the text becomes less wide. I could do this if I know the natural width of the text. Thank you for your information! Chris _______________________________________________ gtkmm-list mailing list gtkmm-list@... http://mail.gnome.org/mailman/listinfo/gtkmm-list |
|
|
Re: The width of a Label.This is basically the "TreeView problem", namely so that TreeView, in order to determine certain drawing parameters, needs to make the cells actually render the text they are going to finally display in order for them to be able to provide the required size.
What you would need to do is to create a Pango::Layout (there's Gtk::Widget::create_pango_layout), set the parameters of that Layout so that they match all the parameters of the Label, then use Pango::Layout::get_pixel_extents() and use the logical extents to determine size and eventually account for any padding the Gtk::Label might use in any way. HTH Milosz 2008/8/18 Chris Dams <chris.dams.nl@gmail.com> Dear all, -- Please note that according to the German law on data retention, information on every electronic information exchange with me is retained for a period of six months. [Bitte beachten Sie, dass dem Gesetz zur Vorratsdatenspeicherung zufolge jeder elektronische Kontakt mit mir sechs Monate lang gespeichert wird.] _______________________________________________ gtkmm-list mailing list gtkmm-list@... http://mail.gnome.org/mailman/listinfo/gtkmm-list |
| Free Forum Powered by Nabble | Forum Help |