From d25ef5d2fd220b530d1bee1e71d32344dadab803 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 20 Oct 2011 11:43:48 +0000 Subject: [PATCH] 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 --- libs/gtkmm2ext/utils.cc | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/libs/gtkmm2ext/utils.cc b/libs/gtkmm2ext/utils.cc index a5768fad5c..19b6f2c46b 100644 --- a/libs/gtkmm2ext/utils.cc +++ b/libs/gtkmm2ext/utils.cc @@ -488,3 +488,26 @@ Gtkmm2ext::window_to_draw_on (Gtk::Widget& w, Gtk::Widget** parent) return Glib::RefPtr (); } +#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 layout = foo.create_pango_layout (str); + Glib::RefPtr 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