3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
9 * Full author contact details are available in file CREDITS.
14 #include "rowpainter.h"
18 #include "CoordCache.h"
21 #include "BufferParams.h"
22 #include "BufferView.h"
29 #include "MetricsInfo.h"
30 #include "Paragraph.h"
31 #include "ParagraphMetrics.h"
32 #include "paragraph_funcs.h"
33 #include "ParagraphParameters.h"
34 #include "TextMetrics.h"
37 #include "frontends/FontMetrics.h"
38 #include "frontends/Painter.h"
40 #include "insets/InsetText.h"
42 #include "support/textutils.h"
44 #include <boost/crc.hpp>
49 using frontend::Painter;
50 using frontend::FontMetrics;
60 * A class used for painting an individual row of text.
64 /// initialise and run painter
65 RowPainter(PainterInfo & pi, Text const & text,
66 pit_type pit, Row const & row, Bidi & bidi, int x, int y);
68 // paint various parts
71 void paintChangeBar();
77 void paintForeignMark(double orig_x, Font const & font, int desc = 0);
78 void paintHebrewComposeChar(pos_type & vpos, Font const & font);
79 void paintArabicComposeChar(pos_type & vpos, Font const & font);
80 void paintChars(pos_type & vpos, Font const & font,
81 bool hebrew, bool arabic);
82 int paintAppendixStart(int y);
83 void paintFromPos(pos_type & vpos);
84 void paintInset(pos_type const pos, Font const & font);
86 /// return left margin
87 int leftMargin() const;
89 /// return the label font for this row
90 Font const getLabelFont() const;
92 /// bufferview to paint on
100 TextMetrics & text_metrics_;
101 ParagraphList const & pars_;
108 Paragraph const & par_;
109 ParagraphMetrics const & pm_;
111 /// bidi cache, comes from outside the rowpainter because
112 /// rowpainters are normally created in a for loop and there only
113 /// one of them is active at a time.
116 /// is row erased? (change tracking)
121 int const yo_; // current baseline
130 RowPainter::RowPainter(PainterInfo & pi,
131 Text const & text, pit_type pit, Row const & row, Bidi & bidi, int x, int y)
132 : bv_(*pi.base.bv), pain_(pi.pain), text_(text),
133 text_metrics_(pi.base.bv->textMetrics(&text)),
134 pars_(text.paragraphs()),
135 row_(row), pit_(pit), par_(text.paragraphs()[pit]),
136 pm_(text_metrics_.parMetrics(pit)),
137 bidi_(bidi), erased_(pi.erased_),
138 xo_(x), yo_(y), width_(text_metrics_.width())
140 RowMetrics m = text_metrics_.computeRowMetrics(pit_, row_);
141 bidi_.computeTables(par_, bv_.buffer(), row_);
144 //lyxerr << "RowPainter: x: " << x_ << " xo: " << xo_ << " yo: " << yo_ << endl;
147 separator_ = m.separator;
149 label_hfill_ = m.label_hfill;
151 BOOST_ASSERT(pit >= 0);
152 BOOST_ASSERT(pit < int(text.paragraphs().size()));
156 Font const RowPainter::getLabelFont() const
158 return text_.getLabelFont(bv_.buffer(), par_);
162 int RowPainter::leftMargin() const
164 return text_.leftMargin(bv_.buffer(), text_metrics_.width(), pit_,
169 // If you want to debug inset metrics uncomment the following line:
170 // #define DEBUG_METRICS
171 // This draws green lines around each inset.
174 void RowPainter::paintInset(pos_type const pos, Font const & font)
176 Inset const * inset = par_.getInset(pos);
178 PainterInfo pi(const_cast<BufferView *>(&bv_), pain_);
179 // FIXME: We should always use font, see documentation of
180 // noFontChange() in Inset.h.
181 pi.base.font = inset->noFontChange() ?
182 bv_.buffer().params().getFont() :
184 pi.ltr_pos = (bidi_.level(pos) % 2 == 0);
185 pi.erased_ = erased_ || par_.isDeleted(pos);
187 int const x1 = int(x_);
189 bv_.coordCache().insets().add(inset, int(x_), yo_);
190 // insets are painted completely. Recursive
191 inset->drawSelection(pi, int(x_), yo_);
192 inset->draw(pi, int(x_), yo_);
193 x_ += inset->width();
196 BOOST_ASSERT(max_witdh_ > 0);
197 int right_margin = text_metrics_.rightMargin(pm_);
198 int const w = max_witdh_ - leftMargin() - right_margin;
199 MetricsInfo mi(&bv_, font, w);
200 inset->metrics(mi, dim);
201 if (inset->width() > dim.wid)
202 lyxerr << "Error: inset " << to_ascii(inset->getInsetName())
203 << " draw width " << inset->width()
204 << "> metrics width " << dim.wid << "." << std::endl;
205 if (inset->ascent() > dim.asc)
206 lyxerr << "Error: inset " << to_ascii(inset->getInsetName())
207 << " draw ascent " << inset->ascent()
208 << "> metrics ascent " << dim.asc << "." << std::endl;
209 if (inset->descent() > dim.des)
210 lyxerr << "Error: inset " << to_ascii(inset->getInsetName())
211 << " draw ascent " << inset->descent()
212 << "> metrics descent " << dim.des << "." << std::endl;
213 BOOST_ASSERT(inset->width() <= dim.wid);
214 BOOST_ASSERT(inset->ascent() <= dim.asc);
215 BOOST_ASSERT(inset->descent() <= dim.des);
216 int const x2 = x1 + dim.wid;
217 int const y1 = yo_ + dim.des;
218 int const y2 = yo_ - dim.asc;
219 pi.pain.line(x1, y1, x1, y2, Color::green);
220 pi.pain.line(x1, y1, x2, y1, Color::green);
221 pi.pain.line(x2, y1, x2, y2, Color::green);
222 pi.pain.line(x1, y2, x2, y2, Color::green);
227 void RowPainter::paintHebrewComposeChar(pos_type & vpos, Font const & font)
229 pos_type pos = bidi_.vis2log(vpos);
234 char_type c = par_.getChar(pos);
238 int const width = theFontMetrics(font).width(c);
241 for (pos_type i = pos - 1; i >= 0; --i) {
243 if (!Encodings::isComposeChar_hebrew(c)) {
244 if (isPrintableNonspace(c)) {
245 int const width2 = pm_.singleWidth(i,
246 text_.getFont(bv_.buffer(), par_, i));
247 dx = (c == 0x05e8 || // resh
248 c == 0x05d3) // dalet
250 : (width2 - width) / 2;
257 pain_.text(int(x_) + dx, yo_, str, font);
261 void RowPainter::paintArabicComposeChar(pos_type & vpos, Font const & font)
263 pos_type pos = bidi_.vis2log(vpos);
267 char_type c = par_.getChar(pos);
268 c = par_.transformChar(c, pos);
272 int const width = theFontMetrics(font).width(c);
275 for (pos_type i = pos - 1; i >= 0; --i) {
277 if (!Encodings::isComposeChar_arabic(c)) {
278 if (isPrintableNonspace(c)) {
279 int const width2 = pm_.singleWidth(i,
280 text_.getFont(bv_.buffer(), par_, i));
281 dx = (width2 - width) / 2;
287 pain_.text(int(x_) + dx, yo_, str, font);
291 void RowPainter::paintChars(pos_type & vpos, Font const & font,
292 bool hebrew, bool arabic)
294 // This method takes up 70% of time when typing
295 pos_type pos = bidi_.vis2log(vpos);
296 pos_type const end = row_.endpos();
297 FontSpan const font_span = par_.fontSpan(pos);
298 Change::Type const prev_change = par_.lookupChange(pos).type;
301 std::vector<char_type> str;
303 str.push_back(par_.getChar(pos));
306 char_type c = str[0];
311 str[0] = par_.transformChar(c, pos);
314 // collect as much similar chars as we can
315 for (++vpos ; vpos < end ; ++vpos) {
316 pos = bidi_.vis2log(vpos);
317 if (pos < font_span.first || pos > font_span.last)
320 if (prev_change != par_.lookupChange(pos).type)
323 char_type c = par_.getChar(pos);
325 if (!isPrintableNonspace(c))
328 /* Because we do our own bidi, at this point the strings are
329 * already in visual order. However, Qt also applies its own
330 * bidi algorithm to strings that it paints to the screen.
331 * Therefore, if we were to paint Hebrew/Arabic words as a
332 * single string, the letters in the words would get reversed
333 * again. In order to avoid that, we don't collect Hebrew/
334 * Arabic characters, but rather paint them one at a time.
335 * See also http://thread.gmane.org/gmane.editors.lyx.devel/79740
340 /* FIXME: these checks are irrelevant, since 'arabic' and
341 * 'hebrew' alone are already going to trigger a break.
342 * However, this should not be removed completely, because
343 * if an alternative solution is found which allows grouping
344 * of arabic and hebrew characters, then these breaks may have
347 if (arabic && Encodings::isComposeChar_arabic(c))
350 if (hebrew && Encodings::isComposeChar_hebrew(c))
359 c = par_.transformChar(c, pos);
360 /* see comment in hebrew, explaining why we break */
367 docstring s(&str[0], str.size());
369 if (prev_change != Change::UNCHANGED) {
371 if (prev_change == Change::DELETED) {
372 copy.setColor(Color::deletedtext);
373 } else if (prev_change == Change::INSERTED) {
374 copy.setColor(Color::addedtext);
376 x_ += pain_.text(int(x_), yo_, s, copy);
378 x_ += pain_.text(int(x_), yo_, s, font);
383 void RowPainter::paintForeignMark(double orig_x, Font const & font, int desc)
385 if (!lyxrc.mark_foreign_language)
387 if (font.language() == latex_language)
389 if (font.language() == bv_.buffer().params().language)
392 int const y = yo_ + 1 + desc;
393 pain_.line(int(orig_x), y, int(x_), y, Color::language);
397 void RowPainter::paintFromPos(pos_type & vpos)
399 pos_type const pos = bidi_.vis2log(vpos);
400 Font orig_font = text_.getFont(bv_.buffer(), par_, pos);
402 double const orig_x = x_;
404 if (par_.isInset(pos)) {
405 // If outer row has changed, nested insets are repaint completely.
406 paintInset(pos, orig_font);
408 paintForeignMark(orig_x, orig_font,
409 par_.getInset(pos)->descent());
413 // usual characters, no insets
414 char_type const c = par_.getChar(pos);
416 // special case languages
417 std::string const & lang = orig_font.language()->lang();
418 bool const hebrew = lang == "hebrew";
419 bool const arabic = lang == "arabic_arabtex" || lang == "arabic_arabi" ||
422 // draw as many chars as we can
423 if ((!hebrew && !arabic)
424 || (hebrew && !Encodings::isComposeChar_hebrew(c))
425 || (arabic && !Encodings::isComposeChar_arabic(c))) {
426 paintChars(vpos, orig_font, hebrew, arabic);
428 paintHebrewComposeChar(vpos, orig_font);
430 paintArabicComposeChar(vpos, orig_font);
433 paintForeignMark(orig_x, orig_font);
437 void RowPainter::paintChangeBar()
439 pos_type const start = row_.pos();
440 pos_type end = row_.endpos();
442 if (par_.size() == end) {
443 // this is the last row of the paragraph;
444 // thus, we must also consider the imaginary end-of-par character
448 if (start == end || !par_.isChanged(start, end))
451 int const height = text_.isLastRow(pit_, row_)
455 pain_.fillRectangle(5, yo_ - row_.ascent(), 3, height, Color::changebar);
459 void RowPainter::paintAppendix()
461 // only draw the appendix frame once (for the main text)
462 if (!par_.params().appendix() || !text_.isMainText(bv_.buffer()))
465 int y = yo_ - row_.ascent();
467 if (par_.params().startOfAppendix())
468 y += 2 * defaultRowHeight();
470 pain_.line(1, y, 1, yo_ + row_.height(), Color::appendix);
471 pain_.line(width_ - 2, y, width_ - 2, yo_ + row_.height(), Color::appendix);
475 void RowPainter::paintDepthBar()
477 depth_type const depth = par_.getDepth();
482 depth_type prev_depth = 0;
483 if (!text_.isFirstRow(pit_, row_)) {
484 pit_type pit2 = pit_;
487 prev_depth = pars_[pit2].getDepth();
490 depth_type next_depth = 0;
491 if (!text_.isLastRow(pit_, row_)) {
492 pit_type pit2 = pit_;
493 if (row_.endpos() >= pars_[pit2].size())
495 next_depth = pars_[pit2].getDepth();
498 for (depth_type i = 1; i <= depth; ++i) {
499 int const w = nestMargin() / 5;
500 int x = int(xo_) + w * i;
501 // only consider the changebar space if we're drawing outermost text
502 if (text_.isMainText(bv_.buffer()))
503 x += changebarMargin();
505 int const starty = yo_ - row_.ascent();
506 int const h = row_.height() - 1 - (i - next_depth - 1) * 3;
508 pain_.line(x, starty, x, starty + h, Color::depthbar);
511 pain_.fillRectangle(x, starty, w, 2, Color::depthbar);
513 pain_.fillRectangle(x, starty + h, w, 2, Color::depthbar);
518 int RowPainter::paintAppendixStart(int y)
521 pb_font.setColor(Color::appendix);
528 docstring const label = _("Appendix");
529 theFontMetrics(pb_font).rectText(label, w, a, d);
531 int const text_start = int(xo_ + (width_ - w) / 2);
532 int const text_end = text_start + w;
534 pain_.rectText(text_start, y + d, label, pb_font, Color::none, Color::none);
536 pain_.line(int(xo_ + 1), y, text_start, y, Color::appendix);
537 pain_.line(text_end, y, int(xo_ + width_ - 2), y, Color::appendix);
539 return 3 * defaultRowHeight();
543 void RowPainter::paintFirst()
545 ParagraphParameters const & parparams = par_.params();
549 // start of appendix?
550 if (parparams.startOfAppendix())
551 y_top += paintAppendixStart(yo_ - row_.ascent() + 2 * defaultRowHeight());
553 Buffer const & buffer = bv_.buffer();
555 LayoutPtr const & layout = par_.layout();
557 if (buffer.params().paragraph_separation == BufferParams::PARSEP_SKIP) {
559 if (layout->latextype == LATEX_PARAGRAPH
560 && !par_.getDepth()) {
561 y_top += buffer.params().getDefSkip().inPixels(bv_);
563 LayoutPtr const & playout = pars_[pit_ - 1].layout();
564 if (playout->latextype == LATEX_PARAGRAPH
565 && !pars_[pit_ - 1].getDepth()) {
566 // is it right to use defskip here, too? (AS)
567 y_top += buffer.params().getDefSkip().inPixels(bv_);
573 bool const is_rtl = text_.isRTL(buffer, par_);
574 bool const is_seq = isFirstInSequence(pit_, text_.paragraphs());
575 //lyxerr << "paintFirst: " << par_.id() << " is_seq: " << is_seq << std::endl;
577 // should we print a label?
578 if (layout->labeltype >= LABEL_STATIC
579 && (layout->labeltype != LABEL_STATIC
580 || layout->latextype != LATEX_ENVIRONMENT
583 Font const font = getLabelFont();
584 FontMetrics const & fm = theFontMetrics(font);
586 docstring const str = par_.getLabelstring();
590 // this is special code for the chapter layout. This is
591 // printed in an extra row and has a pagebreak at
593 if (layout->counter == "chapter") {
594 double spacing_val = 1.0;
595 if (!parparams.spacing().isDefault()) {
596 spacing_val = parparams.spacing().getValue();
598 spacing_val = buffer.params().spacing().getValue();
601 int const labeladdon = int(fm.maxHeight() * layout->spacing.getValue() * spacing_val);
603 int const maxdesc = int(fm.maxDescent() * layout->spacing.getValue() * spacing_val)
604 + int(layout->parsep) * defaultRowHeight();
607 x = width_ - leftMargin() -
611 pain_.text(int(x), yo_ - maxdesc - labeladdon, str, font);
614 x = width_ - leftMargin()
615 + fm.width(layout->labelsep);
617 x = x_ - fm.width(layout->labelsep)
621 pain_.text(int(x), yo_, str, font);
625 // the labels at the top of an environment.
626 // More or less for bibliography
628 (layout->labeltype == LABEL_TOP_ENVIRONMENT ||
629 layout->labeltype == LABEL_BIBLIO ||
630 layout->labeltype == LABEL_CENTERED_TOP_ENVIRONMENT)) {
631 Font font = getLabelFont();
632 if (!par_.getLabelstring().empty()) {
633 docstring const str = par_.getLabelstring();
634 double spacing_val = 1.0;
635 if (!parparams.spacing().isDefault())
636 spacing_val = parparams.spacing().getValue();
638 spacing_val = buffer.params().spacing().getValue();
640 FontMetrics const & fm = theFontMetrics(font);
642 int const labeladdon = int(fm.maxHeight()
643 * layout->spacing.getValue() * spacing_val);
646 int(fm.maxDescent() * layout->spacing.getValue() * spacing_val
647 + (layout->labelbottomsep * defaultRowHeight()));
650 if (layout->labeltype == LABEL_CENTERED_TOP_ENVIRONMENT) {
653 x += (width_ - text_metrics_.rightMargin(pm_) - leftMargin()) / 2;
654 x -= fm.width(str) / 2;
656 x = width_ - leftMargin() - fm.width(str);
658 pain_.text(int(x), yo_ - maxdesc - labeladdon, str, font);
664 void RowPainter::paintLast()
666 bool const is_rtl = text_.isRTL(bv_.buffer(), par_);
667 int const endlabel = getEndLabel(pit_, text_.paragraphs());
669 // paint imaginary end-of-paragraph character
671 if (par_.isInserted(par_.size()) || par_.isDeleted(par_.size())) {
672 FontMetrics const & fm = theFontMetrics(bv_.buffer().params().getFont());
673 int const length = fm.maxAscent() / 2;
674 Color::color col = par_.isInserted(par_.size()) ? Color::addedtext : Color::deletedtext;
676 pain_.line(int(x_) + 1, yo_ + 2, int(x_) + 1, yo_ + 2 - length, col,
677 Painter::line_solid, Painter::line_thick);
678 pain_.line(int(x_) + 1 - length, yo_ + 2, int(x_) + 1, yo_ + 2, col,
679 Painter::line_solid, Painter::line_thick);
686 case END_LABEL_FILLED_BOX: {
687 Font const font = getLabelFont();
688 FontMetrics const & fm = theFontMetrics(font);
689 int const size = int(0.75 * fm.maxAscent());
690 int const y = yo_ - size;
691 int x = is_rtl ? nestMargin() + changebarMargin() : width_ - size;
693 if (width_ - int(row_.width()) <= size)
694 x += (size - width_ + row_.width() + 1) * (is_rtl ? -1 : 1);
696 if (endlabel == END_LABEL_BOX)
697 pain_.rectangle(x, y, size, size, Color::eolmarker);
699 pain_.fillRectangle(x, y, size, size, Color::eolmarker);
703 case END_LABEL_STATIC: {
704 Font font = getLabelFont();
705 FontMetrics const & fm = theFontMetrics(font);
706 docstring const & str = par_.layout()->endlabelstring();
707 double const x = is_rtl ?
709 : - text_metrics_.rightMargin(pm_) - row_.width();
710 pain_.text(int(x), yo_, str, font);
714 case END_LABEL_NO_LABEL:
720 void RowPainter::paintText()
722 pos_type const end = row_.endpos();
723 // Spaces at logical line breaks in bidi text must be skipped during
724 // painting. However, they may appear visually in the middle
725 // of a row; they must be skipped, wherever they are...
726 // * logically "abc_[HEBREW_\nHEBREW]"
727 // * visually "abc_[_WERBEH\nWERBEH]"
728 pos_type skipped_sep_vpos = -1;
729 pos_type body_pos = par_.beginOfBody();
731 (body_pos > end || !par_.isLineSeparator(body_pos - 1))) {
735 LayoutPtr const & layout = par_.layout();
737 bool running_strikeout = false;
738 bool is_struckout = false;
739 int last_strikeout_x = 0;
741 // Use font span to speed things up, see below
744 Buffer const & buffer = bv_.buffer();
746 // If the last logical character is a separator, don't paint it, unless
747 // it's in the last row of a paragraph; see skipped_sep_vpos declaration
748 if (end > 0 && end < par_.size() && par_.isSeparator(end - 1))
749 skipped_sep_vpos = bidi_.log2vis(end - 1);
751 for (pos_type vpos = row_.pos(); vpos < end; ) {
752 if (x_ > bv_.workWidth())
755 // Skip the separator at the logical end of the row
756 if (vpos == skipped_sep_vpos) {
761 pos_type const pos = bidi_.vis2log(vpos);
763 if (pos >= par_.size()) {
768 // Use font span to speed things up, see above
769 if (vpos < font_span.first || vpos > font_span.last) {
770 font_span = par_.fontSpan(vpos);
771 font = text_.getFont(buffer, par_, vpos);
774 const int width_pos = pm_.singleWidth(pos, font);
776 if (x_ + width_pos < 0) {
782 is_struckout = par_.isDeleted(pos);
784 if (is_struckout && !running_strikeout) {
785 running_strikeout = true;
786 last_strikeout_x = int(x_);
789 bool const highly_editable_inset = par_.isInset(pos)
790 && isHighlyEditableInset(par_.getInset(pos));
792 // If we reach the end of a struck out range, paint it.
793 // We also don't paint across things like tables
794 if (running_strikeout && (highly_editable_inset || !is_struckout)) {
795 // Calculate 1/3 height of the buffer's default font
796 FontMetrics const & fm
797 = theFontMetrics(bv_.buffer().params().getFont());
798 int const middle = yo_ - fm.maxAscent() / 3;
799 pain_.line(last_strikeout_x, middle, int(x_), middle,
800 Color::deletedtext, Painter::line_solid, Painter::line_thin);
801 running_strikeout = false;
804 if (body_pos > 0 && pos == body_pos - 1) {
805 int const lwidth = theFontMetrics(getLabelFont())
806 .width(layout->labelsep);
808 x_ += label_hfill_ + lwidth - width_pos;
811 if (par_.isHfill(pos)) {
815 int const y1 = y0 - defaultRowHeight() / 2;
817 pain_.line(int(x_), y1, int(x_), y0, Color::added_space);
819 if (par_.hfillExpansion(row_, pos)) {
820 int const y2 = (y0 + y1) / 2;
822 if (pos >= body_pos) {
823 pain_.line(int(x_), y2, int(x_ + hfill_), y2,
825 Painter::line_onoffdash);
828 pain_.line(int(x_), y2, int(x_ + label_hfill_), y2,
830 Painter::line_onoffdash);
833 pain_.line(int(x_), y1, int(x_), y0, Color::added_space);
837 } else if (par_.isSeparator(pos)) {
838 Font orig_font = text_.getFont(bv_.buffer(), par_, pos);
839 double const orig_x = x_;
844 paintForeignMark(orig_x, orig_font);
850 // if we reach the end of a struck out range, paint it
851 if (running_strikeout) {
852 // calculate 1/3 height of the buffer's default font
853 FontMetrics const & fm
854 = theFontMetrics(bv_.buffer().params().getFont());
855 int const middle = yo_ - fm.maxAscent() / 3;
856 pain_.line(last_strikeout_x, middle, int(x_), middle,
857 Color::deletedtext, Painter::line_solid, Painter::line_thin);
858 running_strikeout = false;
863 bool CursorOnRow(PainterInfo & pi, pit_type const pit,
864 RowList::const_iterator rit, Text const & text)
866 // Is there a cursor on this row (or inside inset on row)
867 Cursor & cur = pi.base.bv->cursor();
868 for (size_type d = 0; d < cur.depth(); ++d) {
869 CursorSlice const & sl = cur[d];
870 if (sl.text() == &text
872 && sl.pos() >= rit->pos()
873 && sl.pos() <= rit->endpos())
883 (PainterInfo & pi, Text const & text, pit_type pit, int x, int y,
886 // lyxerr << " paintPar: pit: " << pit << " at y: " << y << endl;
887 int const ww = pi.base.bv->workHeight();
889 pi.base.bv->coordCache().parPos()[&text][pit] = Point(x, y);
891 TextMetrics const & tm = pi.base.bv->textMetrics(&text);
892 ParagraphMetrics const & pm = tm.parMetrics(pit);
893 if (pm.rows().empty())
896 RowList::const_iterator const rb = pm.rows().begin();
897 RowList::const_iterator const re = pm.rows().end();
903 for (RowList::const_iterator rit = rb; rit != re; ++rit, ++rowno) {
905 // Row signature; has row changed since last paint?
906 bool row_has_changed = pm.rowChangeStatus()[rowno];
908 bool cursor_on_row = CursorOnRow(pi, pit, rit, text);
910 // If selection is on, the current row signature differs
911 // from cache, or cursor is inside an inset _on this row_,
912 // then paint the row
913 if (repaintAll || row_has_changed || cursor_on_row) {
914 bool const inside = (y + rit->descent() >= 0
915 && y - rit->ascent() < ww);
916 // it is not needed to draw on screen if we are not inside.
917 pi.pain.setDrawingEnabled(inside);
918 RowPainter rp(pi, text, pit, *rit, bidi, x, y);
919 // Clear background of this row
920 // (if paragraph background was not cleared)
921 if (!repaintAll && row_has_changed)
922 pi.pain.fillRectangle(x, y - rit->ascent(),
923 tm.width(), rit->height(),
924 text.backgroundColor());
926 // Instrumentation for testing row cache (see also
928 if (lyxerr.debugging(Debug::PAINTING)) {
929 if (text.isMainText(pi.base.bv->buffer()))
930 LYXERR(Debug::PAINTING) << "#";
932 LYXERR(Debug::PAINTING) << "[" <<
933 repaintAll << row_has_changed <<
934 cursor_on_row << "]";
947 // Re-enable screen drawing for future use of the painter.
948 pi.pain.setDrawingEnabled(true);
950 LYXERR(Debug::PAINTING) << "." << endl;