diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2011-10-20 11:43:48 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2011-10-20 11:43:48 +0000 |
commit | d25ef5d2fd220b530d1bee1e71d32344dadab803 (patch) | |
tree | fd67b6b01ee234308be85caf6d2bdc5897f3ff06 | |
parent | a9e5c95bd248efac997848341ad617f18540561e (diff) |
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
-rw-r--r-- | libs/gtkmm2ext/utils.cc | 23 |
1 files changed, 23 insertions, 0 deletions
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<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 |