add (commented) new version of fit-to-pixels function, from Company on #gtk+

git-svn-id: svn://localhost/ardour2/branches/3.0@10248 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis 2011-10-20 11:43:48 +00:00
parent a9e5c95bd2
commit d25ef5d2fd

View file

@ -488,3 +488,26 @@ Gtkmm2ext::window_to_draw_on (Gtk::Widget& w, Gtk::Widget** parent)
return Glib::RefPtr<Gdk::Window> ();
}
#if 0
string
fit_to_pixels (const string& str, int pixel_width, Pango::FontDescription& font, int& actual_width, bool with_ellipses)
{
Label foo;
Glib::RefPtr<Pango::Layout> layout = foo.create_pango_layout (str);
Glib::RefPtr<Pango::LayoutLine> line;
layout->set_font_description (font);
layout->set_width (pixel_width * PANGO_SCALE);
if (with_ellipsis)
layout->set_ellipsize (PANGO_ELLIPSIZE_END);
else
layout->set_wrap_mode (PANGO_WRAP_CHAR);
line = layout->get_line_readonly (0);
/* XXX: might need special care to get the ellipsis character, not sure
how that works */
return strdup (layout->get_text () + line->start_index, line->length);
}
#endif