Remove unused size_request-for_text helpers
This commit is contained in:
parent
1b7b3543e8
commit
5ef2d04cd8
@ -67,36 +67,11 @@ namespace Gtkmm2ext {
|
||||
int& width, int& height);
|
||||
|
||||
|
||||
LIBGTKMM2EXT_API void get_pixel_size (Glib::RefPtr<Pango::Layout>,
|
||||
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<std::string>&,
|
||||
gint hpadding,
|
||||
gint vpadding);
|
||||
|
||||
LIBGTKMM2EXT_API void set_size_request_to_display_given_text (Gtk::Widget& w,
|
||||
const std::vector<std::string>&,
|
||||
const std::string& hpadding,
|
||||
gint vpadding);
|
||||
|
||||
|
||||
LIBGTKMM2EXT_API Glib::RefPtr<Gdk::Pixbuf> pixbuf_from_string (const std::string& name,
|
||||
const Pango::FontDescription& font,
|
||||
|
@ -66,135 +66,16 @@ Gtkmm2ext::get_ink_pixel_size (Glib::RefPtr<Pango::Layout> layout,
|
||||
}
|
||||
|
||||
void
|
||||
Gtkmm2ext::get_pixel_size (Glib::RefPtr<Pango::Layout> 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<std::string>& strings,
|
||||
gint hpadding, gint vpadding)
|
||||
{
|
||||
int width, height;
|
||||
int width_max = 0;
|
||||
int height_max = 0;
|
||||
w.ensure_style ();
|
||||
vector<string> copy;
|
||||
const vector<string>* to_use;
|
||||
vector<string>::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<string>::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<std::string>& strings,
|
||||
const std::string& hpadding,
|
||||
gint vpadding)
|
||||
{
|
||||
int width_max = 0;
|
||||
int height_max = 0;
|
||||
w.ensure_style ();
|
||||
|
||||
for (vector<string>::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)
|
||||
|
Loading…
Reference in New Issue
Block a user