From 70cf40ccef0dc2d6441c03e239f0d8fa33bb386c Mon Sep 17 00:00:00 2001 From: Michael Schmitt Date: Tue, 6 Sep 2005 16:27:24 +0000 Subject: [PATCH] insetcharstyle.C (metrics,draw): consider inset label for width computation; fix drawing of labels of undefined char styles git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10412 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/insets/ChangeLog | 5 +++++ src/insets/insetcharstyle.C | 18 +++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index 02035aa757..774e90364f 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,8 @@ +2005-09-05 Michael Gerz + + * insetcharstyle.C (metrics,draw): consider inset label for + width computation; fix drawing of labels of undefined char styles + 2005-08-07 Martin Vermeer * insettabular.C (getStatus): fix Helge's bug that a number of insets diff --git a/src/insets/insetcharstyle.C b/src/insets/insetcharstyle.C index 76b60b7385..1963e0aa6e 100644 --- a/src/insets/insetcharstyle.C +++ b/src/insets/insetcharstyle.C @@ -38,6 +38,7 @@ using std::string; using std::auto_ptr; using std::istringstream; +using std::max; using std::ostream; using std::ostringstream; @@ -139,6 +140,21 @@ void InsetCharStyle::metrics(MetricsInfo & mi, Dimension & dim) const mi.base.textwidth -= 2 * TEXT_TO_INSET_OFFSET; InsetText::metrics(mi, dim); mi.base.font = tmpfont; + if (has_label_) { + // consider width of the inset label + LyXFont font(params_.labelfont); + font.realize(LyXFont(LyXFont::ALL_SANE)); + font.decSize(); + font.decSize(); + int w = 0; + int a = 0; + int d = 0; + string s(params_.type); + if (undefined()) + s = _("Undef: ") + s; + font_metrics::rectText(s, font, w, a, d); + dim.wid = max(dim.wid, w); + } dim.asc += TEXT_TO_INSET_OFFSET; dim.des += TEXT_TO_INSET_OFFSET; dim.wid += 2 * TEXT_TO_INSET_OFFSET; @@ -182,7 +198,7 @@ void InsetCharStyle::draw(PainterInfo & pi, int x, int y) const string s(params_.type); if (undefined()) s = _("Undef: ") + s; - font_metrics::rectText(params_.type, font, w, a, d); + font_metrics::rectText(s, font, w, a, d); pi.pain.rectText(x + (dim_.wid - w) / 2, y + desc + a, s, font, LColor::none, LColor::none); } -- 2.39.2