Angus Leeming wrote:
I suspect that you mean to pass "s" to rectText, no?
+ string const s = undefined() ?
+ _("Undef: ") + params_.type : params_.type;
+ font_metrics::rectText(s, font, w, a, d);
Oops, you are right! Which means that there was another bug in the code,
since I copied these statements from method "draw".
I fixed the code in both metrics() and draw().
Lars, OK? Do you accept this as a bug fix?
Michael
Index: src/insets/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/ChangeLog,v
retrieving revision 1.1179
diff -u -r1.1179 ChangeLog
--- src/insets/ChangeLog 7 Aug 2005 18:36:20 -0000 1.1179
+++ src/insets/ChangeLog 6 Sep 2005 15:58:06 -0000
@@ -1,3 +1,8 @@
+2005-09-05 Michael Gerz <[EMAIL PROTECTED]>
+
+ * insetcharstyle.C (metrics,draw): consider inset label for
+ width computation; fix drawing of labels of undefined char styles
+
2005-08-07 Martin Vermeer <[EMAIL PROTECTED]>
* insettabular.C (getStatus): fix Helge's bug that a number of insets
Index: src/insets/insetcharstyle.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetcharstyle.C,v
retrieving revision 1.36
diff -u -r1.36 insetcharstyle.C
--- src/insets/insetcharstyle.C 9 Jun 2005 09:58:07 -0000 1.36
+++ src/insets/insetcharstyle.C 6 Sep 2005 15:58:07 -0000
@@ -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 @@
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 @@
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);
}