]> git.lyx.org Git - lyx.git/blobdiff - src/TextMetrics.cpp
de.po
[lyx.git] / src / TextMetrics.cpp
index c5784070d26cc8692735b45318802cb7fef60cd8..c4ed9ca4af607d7ae46a2c71d108410b8dd643f5 100644 (file)
@@ -43,6 +43,7 @@
 
 #include "frontends/FontMetrics.h"
 #include "frontends/Painter.h"
+#include "frontends/NullPainter.h"
 
 #include "support/debug.h"
 #include "support/lassert.h"
@@ -198,6 +199,14 @@ bool TextMetrics::metrics(MetricsInfo & mi, Dimension & dim, int min_width)
 }
 
 
+void TextMetrics::updatePosCache(pit_type pit) const
+{
+       frontend::NullPainter np;
+       PainterInfo pi(bv_, np);
+       drawParagraph(pi, pit, origin_.x_, par_metrics_[pit].position());
+}
+
+
 int TextMetrics::rightMargin(ParagraphMetrics const & pm) const
 {
        return text_->isMainText() ? pm.rightMargin(*bv_) : 0;
@@ -640,8 +649,10 @@ void TextMetrics::computeRowMetrics(Row & row, int width) const
                        break;
                case LYX_ALIGN_LEFT:
                        // a displayed inset that is flushed
-                       if (Inset const * inset = par.getInset(row.pos()))
+                       if (Inset const * inset = par.getInset(row.pos())) {
                                row.left_margin += inset->indent(*bv_);
+                               row.dimension().wid += inset->indent(*bv_);
+                       }
                        break;
                case LYX_ALIGN_RIGHT:
                        if (Inset const * inset = par.getInset(row.pos())) {
@@ -966,7 +977,8 @@ bool TextMetrics::breakRow(Row & row, int const right_margin) const
        int const next_width = max_width_ - leftMargin(row.pit(), row.endpos())
                - rightMargin(row.pit());
 
-       row.shortenIfNeeded(body_pos, width, next_width);
+       if (row.shortenIfNeeded(body_pos, width, next_width))
+               row.flushed(false);
        row.right_boundary(!row.empty() && row.endpos() < end
                           && row.back().endpos == row.endpos());
        // Last row in paragraph is flushed
@@ -1219,6 +1231,7 @@ void TextMetrics::newParMetricsDown()
        redoParagraph(pit);
        par_metrics_[pit].setPosition(last.second.position()
                + last.second.descent() + par_metrics_[pit].ascent());
+       updatePosCache(pit);
 }
 
 
@@ -1233,6 +1246,7 @@ void TextMetrics::newParMetricsUp()
        redoParagraph(pit);
        par_metrics_[pit].setPosition(first.second.position()
                - first.second.ascent() - par_metrics_[pit].descent());
+       updatePosCache(pit);
 }
 
 // y is screen coordinate
@@ -1881,7 +1895,8 @@ void TextMetrics::drawParagraph(PainterInfo & pi, pit_type const pit, int const
                // Row signature; has row changed since last paint?
                row.setCrc(pm.computeRowSignature(row, *bv_));
                bool row_has_changed = row.changed()
-                       || bv_->hadHorizScrollOffset(text_, pit, row.pos());
+                       || bv_->hadHorizScrollOffset(text_, pit, row.pos())
+                       || bv_->needRepaint(text_, row);
 
                // Take this opportunity to spellcheck the row contents.
                if (row_has_changed && pi.do_spellcheck && lyxrc.spellcheck_continuously) {
@@ -1913,10 +1928,10 @@ void TextMetrics::drawParagraph(PainterInfo & pi, pit_type const pit, int const
                // Instrumentation for testing row cache (see also
                // 12 lines lower):
                if (lyxerr.debugging(Debug::PAINTING)
-                       && (row.selection() || pi.full_repaint || row_has_changed)) {
-                               string const foreword = text_->isMainText() ?
-                                       "main text redraw " : "inset text redraw: ";
-                       LYXERR(Debug::PAINTING, foreword << "pit=" << pit << " row=" << i
+                   && (row.selection() || pi.full_repaint || row_has_changed)) {
+                       string const foreword = text_->isMainText() ? "main text redraw "
+                               : "inset text redraw: ";
+                       LYXERR0(foreword << "pit=" << pit << " row=" << i
                                << " row_selection="    << row.selection()
                                << " full_repaint="     << pi.full_repaint
                                << " row_has_changed="  << row_has_changed