diff --git a/libs/gtkmm2ext/gtkmm2ext/utils.h b/libs/gtkmm2ext/gtkmm2ext/utils.h index 9f14c667b5..2554fe27ac 100644 --- a/libs/gtkmm2ext/gtkmm2ext/utils.h +++ b/libs/gtkmm2ext/gtkmm2ext/utils.h @@ -67,36 +67,11 @@ namespace Gtkmm2ext { int& width, int& height); - LIBGTKMM2EXT_API void get_pixel_size (Glib::RefPtr, - int& width, int& height); - - LIBGTKMM2EXT_API void set_size_request_to_display_given_text (Gtk::Widget& w, - const gchar* text, - gint hpadding, - gint vpadding); - - LIBGTKMM2EXT_API void set_size_request_to_display_given_text_width (Gtk::Widget& w, - const gchar* htext, - gint hpadding, - gint vpadding); - - LIBGTKMM2EXT_API void set_height_request_to_display_any_text (Gtk::Widget& w, gint vpadding); - LIBGTKMM2EXT_API void set_size_request_to_display_given_text (Gtk::Widget& w, std::string const& text, gint hpadding, gint vpadding); - LIBGTKMM2EXT_API void set_size_request_to_display_given_text (Gtk::Widget& w, - const std::vector&, - gint hpadding, - gint vpadding); - - LIBGTKMM2EXT_API void set_size_request_to_display_given_text (Gtk::Widget& w, - const std::vector&, - const std::string& hpadding, - gint vpadding); - LIBGTKMM2EXT_API Glib::RefPtr pixbuf_from_string (const std::string& name, const Pango::FontDescription& font, diff --git a/libs/gtkmm2ext/utils.cc b/libs/gtkmm2ext/utils.cc index 28880870e1..694c5c9455 100644 --- a/libs/gtkmm2ext/utils.cc +++ b/libs/gtkmm2ext/utils.cc @@ -66,135 +66,16 @@ Gtkmm2ext::get_ink_pixel_size (Glib::RefPtr layout, } void -Gtkmm2ext::get_pixel_size (Glib::RefPtr layout, - int& width, - int& height) -{ - layout->get_pixel_size (width, height); -} - -void -Gtkmm2ext::set_size_request_to_display_given_text (Gtk::Widget &w, const gchar *text, +Gtkmm2ext::set_size_request_to_display_given_text (Gtk::Widget &w, std::string const& text, gint hpadding, gint vpadding) { int width, height; w.ensure_style (); - get_pixel_size (w.create_pango_layout (text), width, height); + w.create_pango_layout (text)->get_pixel_size (width, height); w.set_size_request(width + hpadding, height + vpadding); } -/** Set width request to display given text, and height to display anything. - * This is useful for setting many widgets to the same height for consistency. */ -void -Gtkmm2ext::set_size_request_to_display_given_text_width (Gtk::Widget& w, - const gchar* htext, - gint hpadding, - gint vpadding) -{ - static const gchar* vtext = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; - - w.ensure_style (); - - int hwidth, hheight; - get_pixel_size (w.create_pango_layout (htext), hwidth, hheight); - - int vwidth, vheight; - get_pixel_size (w.create_pango_layout (vtext), vwidth, vheight); - - w.set_size_request(hwidth + hpadding, vheight + vpadding); -} - -void -Gtkmm2ext::set_height_request_to_display_any_text (Gtk::Widget& w, gint vpadding) -{ - static const gchar* vtext = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; - - w.ensure_style (); - - int width, height; - get_pixel_size (w.create_pango_layout (vtext), width, height); - - w.set_size_request(-1, height + vpadding); -} - -void -Gtkmm2ext::set_size_request_to_display_given_text (Gtk::Widget &w, std::string const & text, - gint hpadding, gint vpadding) -{ - int width, height; - w.ensure_style (); - - get_pixel_size (w.create_pango_layout (text), width, height); - w.set_size_request(width + hpadding, height + vpadding); -} - -void -Gtkmm2ext::set_size_request_to_display_given_text (Gtk::Widget &w, - const std::vector& strings, - gint hpadding, gint vpadding) -{ - int width, height; - int width_max = 0; - int height_max = 0; - w.ensure_style (); - vector copy; - const vector* to_use; - vector::const_iterator i; - - for (i = strings.begin(); i != strings.end(); ++i) { - if ((*i).find_first_of ("gy") != string::npos) { - /* contains a descender */ - break; - } - } - - if (i == strings.end()) { - /* make a copy of the strings then add one that has a descender */ - copy = strings; - copy.push_back ("g"); - to_use = © - } else { - to_use = &strings; - } - - for (vector::const_iterator i = to_use->begin(); i != to_use->end(); ++i) { - get_pixel_size (w.create_pango_layout (*i), width, height); - width_max = max(width_max,width); - height_max = max(height_max, height); - } - - w.set_size_request(width_max + hpadding, height_max + vpadding); -} - -/** This version specifies horizontal padding in text to avoid assumptions - * about font size. Should be used anywhere padding is used to avoid text, - * like combo boxes. - */ -void -Gtkmm2ext::set_size_request_to_display_given_text (Gtk::Widget& w, - const std::vector& strings, - const std::string& hpadding, - gint vpadding) -{ - int width_max = 0; - int height_max = 0; - w.ensure_style (); - - for (vector::const_iterator i = strings.begin(); i != strings.end(); ++i) { - int width, height; - get_pixel_size (w.create_pango_layout (*i), width, height); - width_max = max(width_max,width); - height_max = max(height_max, height); - } - - int pad_width; - int pad_height; - get_pixel_size (w.create_pango_layout (hpadding), pad_width, pad_height); - - w.set_size_request(width_max + pad_width, height_max + vpadding); -} - static inline guint8 demultiply_alpha (guint8 src, guint8 alpha)