This moves the inset metrics update from the (very frequent) singleWidth() function into rowBreakPoint(). This has two advantages :
o no metrics recalculation for something that should be const-like o we can work out the remaining width in order to break inset contents properly Please test it. Note that this only ensures that the text contents itself doesn't extend past the right of the screen (try insert footnote on clean CVS for comparison). The actual red frame drawing itself is a bit tougher. I'm looking into it. Andre, comments ? regards john
Index: text.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text.C,v retrieving revision 1.383 diff -u -p -r1.383 text.C --- text.C 18 Jul 2003 12:05:48 -0000 1.383 +++ text.C 21 Jul 2003 18:18:41 -0000 @@ -311,19 +311,8 @@ int LyXText::singleWidth(ParagraphList:: // Because of the representation as vertical lines return 3; } -#if 1 -#warning inset->update FIXME - // this IS needed otherwise on initialitation we don't get the fill - // of the row right (ONLY on initialization if we read a file!) - // should be changed! (Jug 20011204) - //tmpinset->update(bv()); - Dimension dim; - MetricsInfo mi(bv(), font, workWidth()); - tmpinset->metrics(mi, dim); - return dim.wid; -#else + return tmpinset->width(); -#endif } return 0; } @@ -826,26 +815,38 @@ pos_type LyXText::rowBreakPoint(Row cons char const c = pit->getChar(i); - int thiswidth; + int labeladdwidth = 0; // add the auto-hfill from label end to the body if (body_pos && i == body_pos) { - thiswidth = font_metrics::width(layout->labelsep, + labeladdwidth = font_metrics::width(layout->labelsep, getLabelFont(bv()->buffer(), pit)); if (pit->isLineSeparator(i - 1)) - thiswidth -= singleWidth(pit, i - 1); + labeladdwidth -= singleWidth(pit, i - 1); int left_margin = labelEnd(row); - if (thiswidth + x < left_margin) - thiswidth = left_margin - x; - thiswidth += singleWidth(pit, i, c); + if (labeladdwidth + x < left_margin) + labeladdwidth = left_margin - x; + } + + int thiswidth; + + Inset * in = pit->isInset(i) ? pit->getInset(i) : 0; + /* update the metrics */ + if (in) { + LyXFont const font = getFont(bv()->buffer(), pit, pos); + Dimension dim; + MetricsInfo mi(bv(), font, workWidth() - (x + labeladdwidth)); + in->metrics(mi, dim); + thiswidth = dim.wid; } else { thiswidth = singleWidth(pit, i, c); } + thiswidth += labeladdwidth; + x += thiswidth; chunkwidth += thiswidth; - Inset * in = pit->isInset(i) ? pit->getInset(i) : 0; fullrow = (in && (in->display() || in->needFullRow())); // break before a character that will fall off