447 |
* the assumption that EVERY word of the text had a line break, which would |
* the assumption that EVERY word of the text had a line break, which would |
448 |
* cause the label to claim much more vertical space than actually required for |
* cause the label to claim much more vertical space than actually required for |
449 |
* the text. |
* the text. |
450 |
|
* |
451 |
|
* NOTE: This class only works with Gtk 3 and higher. For Gtk 2 and younger it |
452 |
|
* does nothing different than a normal Gtk::Label right now. See TODO comment |
453 |
|
* on get_preferred_height_for_width_vfunc() below for details. |
454 |
*/ |
*/ |
455 |
class MultiLineLabel : public Gtk::Label { |
class MultiLineLabel : public Gtk::Label { |
456 |
public: |
public: |
465 |
m_markup = s; |
m_markup = s; |
466 |
} |
} |
467 |
|
|
468 |
|
//TODO: get_preferred_height_for_width_vfunc() did not exist in Gtk 2, nor |
469 |
|
// did get_margin_top() and get_margin_bottom() and consequently I'm |
470 |
|
// unsure whether the issue MultiLineLabel addresses could actually be |
471 |
|
// fixed for Gtk 2 as well. For now this code is simply commented out |
472 |
|
// which means MultiLineLabel behaves as Gtk::Label on Gtk 2 & older. |
473 |
|
#if GTKMM_MAJOR_VERSION >= 3 |
474 |
void get_preferred_height_for_width_vfunc(int width, int& minimum_height, int& natural_height) const { |
void get_preferred_height_for_width_vfunc(int width, int& minimum_height, int& natural_height) const { |
475 |
Gtk::Label::get_preferred_height_for_width_vfunc(width, minimum_height, natural_height); |
Gtk::Label::get_preferred_height_for_width_vfunc(width, minimum_height, natural_height); |
476 |
//printf("super suggests minimum_height=%d natural_height=%d\n", minimum_height, natural_height); |
//printf("super suggests minimum_height=%d natural_height=%d\n", minimum_height, natural_height); |
488 |
if (natural_height < h) |
if (natural_height < h) |
489 |
natural_height = h; |
natural_height = h; |
490 |
} |
} |
491 |
|
#endif // GTKMM_MAJOR_VERSION >= 3 |
492 |
|
|
493 |
private: |
private: |
494 |
Glib::ustring m_markup; |
Glib::ustring m_markup; |