]> git.lyx.org Git - features.git/commitdiff
insetcharstyle.C (metrics,draw): consider inset label for
authorMichael Schmitt <michael.schmitt@teststep.org>
Tue, 6 Sep 2005 16:27:24 +0000 (16:27 +0000)
committerMichael Schmitt <michael.schmitt@teststep.org>
Tue, 6 Sep 2005 16:27:24 +0000 (16:27 +0000)
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
src/insets/insetcharstyle.C

index 02035aa757fdf1cec92a776ae08ec5b20a4cb378..774e90364f3ebb4ee369353d604da23d89aeada4 100644 (file)
@@ -1,3 +1,8 @@
+2005-09-05  Michael Gerz  <michael.gerz@teststep.org>
+
+       * insetcharstyle.C (metrics,draw): consider inset label for
+       width computation; fix drawing of labels of undefined char styles
+
 2005-08-07  Martin Vermeer  <martin.vermeer@hut.fi>
 
        * insettabular.C (getStatus): fix Helge's bug that a number of insets
index 76b60b7385e69c1036a64e23f7cd73e3b65c89f2..1963e0aa6eef34f1707f1234bc964c0e4c4c3c35 100644 (file)
@@ -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);
        }