Re: [gtkmm] A small doc question



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]