Re: [gtkmm] A small doc question
- From: Daniel Elstner <daniel elstner gmx net>
- To: Paul Davis <pbd op net>
- Cc: gtkmm-list gnome org
- Subject: Re: [gtkmm] A small doc question
- Date: 25 Oct 2002 04:07:35 +0200
Am Don, 2002-10-17 um 03.31 schrieb Paul Davis:
>
> not only that, but GTK+ still doesn't seem to have a simple way to say
> "make this widget big enough to display this particular text". at some
> point, karl or murray added my gtk+ 1.2-based utility function to the
> codebase but i suspect its been dropped for gtkmm2. it might be rather
> different with pango etc. as well, though i'd expect
> gdk_string_extents() to still exist and work.
I needed this functionality recently, and found it to be quite easy to
implement. Do this in the label's signal_style_changed() handler:
{
const Glib::ustring max_text = "fooooooooooooo";
int width = 0, height;
label->create_pango_layout(max_text)->get_pixel_size(width, height);
int pad_x = 0, pad_y;
label->get_padding(pad_x, pad_y);
label->set_size_request(width + 2 * pad_x, -1);
}
--Daniel
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]