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"
17 #include "coordcache.h"
20 #include "bufferparams.h"
21 #include "BufferView.h"
28 #include "lyxrow_funcs.h"
29 #include "metricsinfo.h"
30 #include "paragraph.h"
31 #include "paragraph_funcs.h"
32 #include "ParagraphParameters.h"
35 #include "frontends/font_metrics.h"
36 #include "frontends/nullpainter.h"
37 #include "frontends/LyXView.h"
38 #include "frontends/WorkArea.h"
39 #include "frontends/Painter.h"
41 #include "insets/insettext.h"
43 #include "support/textutils.h"
45 #include <boost/crc.hpp>
48 using lyx::frontend::Painter;
49 using lyx::frontend::NullPainter;
62 /// Flag: do a full redraw of inside text of inset
63 /// Working variable indicating a full screen refresh
67 * A class used for painting an individual row of text.
71 /// initialise and run painter
72 RowPainter(PainterInfo & pi, LyXText const & text,
73 pit_type pit, Row const & row, int x, int y);
75 // paint various parts
78 void paintChangeBar();
84 void paintForeignMark(double orig_x, LyXFont const & font, int desc = 0);
85 void paintHebrewComposeChar(lyx::pos_type & vpos, LyXFont const & font);
86 void paintArabicComposeChar(lyx::pos_type & vpos, LyXFont const & font);
87 void paintChars(lyx::pos_type & vpos, LyXFont font,
88 bool hebrew, bool arabic);
89 int paintAppendixStart(int y);
90 void paintFromPos(lyx::pos_type & vpos);
91 void paintInset(lyx::pos_type const pos, LyXFont const & font);
93 /// return left margin
94 int leftMargin() const;
96 /// return the label font for this row
97 LyXFont const getLabelFont() const;
99 /// bufferview to paint on
100 BufferView const & bv_;
105 /// LyXText for the row
106 LyXText const & text_;
107 ParagraphList const & pars_;
114 Paragraph const & par_;
116 /// is row erased? (change tracking)
121 int const yo_; // current baseline
130 RowPainter::RowPainter(PainterInfo & pi,
131 LyXText const & text, pit_type pit, Row const & row, int x, int y)
132 : bv_(*pi.base.bv), pain_(pi.pain), text_(text), pars_(text.paragraphs()),
133 row_(row), pit_(pit), par_(text.paragraphs()[pit]),
135 xo_(x), yo_(y), width_(text_.width())
137 RowMetrics m = text_.computeRowMetrics(pit, row_);
140 //lyxerr << "RowPainter: x: " << x_ << " xo: " << xo_ << " yo: " << yo_ << endl;
143 separator_ = m.separator;
145 label_hfill_ = m.label_hfill;
147 BOOST_ASSERT(pit >= 0);
148 BOOST_ASSERT(pit < int(text.paragraphs().size()));
152 LyXFont const RowPainter::getLabelFont() const
154 return text_.getLabelFont(par_);
158 int RowPainter::leftMargin() const
160 return text_.leftMargin(pit_, row_.pos());
164 void RowPainter::paintInset(pos_type const pos, LyXFont const & font)
166 InsetBase const * inset = par_.getInset(pos);
168 PainterInfo pi(const_cast<BufferView *>(&bv_), pain_);
169 // FIXME: We should always use font, see documentation of
170 // noFontChange() in insetbase.h.
171 pi.base.font = inset->noFontChange() ?
172 bv_.buffer()->params().getFont() :
174 pi.ltr_pos = (text_.bidi.level(pos) % 2 == 0);
175 pi.erased_ = erased_ || isDeletedText(par_, pos);
176 theCoords.insets().add(inset, int(x_), yo_);
177 InsetText const * const in = inset->asTextInset();
178 // non-wide insets are painted completely. Recursive
179 bool tmp = refreshInside;
180 if (!in || !in->Wide()) {
181 refreshInside = true;
182 lyxerr[Debug::PAINTING] << endl << "Paint inset fully" << endl;
185 inset->drawSelection(pi, int(x_), yo_);
186 inset->draw(pi, int(x_), yo_);
188 x_ += inset->width();
192 void RowPainter::paintHebrewComposeChar(pos_type & vpos, LyXFont const & font)
194 pos_type pos = text_.bidi.vis2log(vpos);
199 char_type c = par_.getChar(pos);
203 int const width = font_metrics::width(c, font);
206 for (pos_type i = pos - 1; i >= 0; --i) {
208 if (!Encodings::isComposeChar_hebrew(c)) {
209 if (isPrintableNonspace(c)) {
211 text_.singleWidth(par_, i, c, text_.getFont(par_, i));
213 dx = (c == 'ø' || c == 'ã')
215 : (width2 - width) / 2;
222 docstring dstr(str.begin(), str.end());
223 pain_.text(int(x_) + dx, yo_, dstr, font);
227 void RowPainter::paintArabicComposeChar(pos_type & vpos, LyXFont const & font)
229 pos_type pos = text_.bidi.vis2log(vpos);
233 char_type c = par_.getChar(pos);
234 c = par_.transformChar(c, pos);
238 int const width = font_metrics::width(c, font);
241 for (pos_type i = pos - 1; i >= 0; --i) {
243 if (!Encodings::isComposeChar_arabic(c)) {
244 if (isPrintableNonspace(c)) {
246 text_.singleWidth(par_, i, c, text_.getFont(par_, i));
247 dx = (width2 - width) / 2;
253 docstring dstr(str.begin(), str.end());
254 pain_.text(int(x_) + dx, yo_, dstr, font);
258 void RowPainter::paintChars(pos_type & vpos, LyXFont font,
259 bool hebrew, bool arabic)
261 pos_type pos = text_.bidi.vis2log(vpos);
262 pos_type const end = row_.endpos();
263 FontSpan const font_span = par_.fontSpan(pos);
264 Change::Type const prev_change = par_.lookupChange(pos).type;
269 str += par_.getChar(pos);
271 std::vector<char_type> str;
272 str.push_back(par_.getChar(pos));
275 char_type c = str[0];
276 str[0] = par_.transformChar(c, pos);
279 // collect as much similar chars as we can
280 for (++vpos ; vpos < end ; ++vpos) {
281 pos = text_.bidi.vis2log(vpos);
282 if (pos < font_span.first || pos > font_span.last)
285 if (prev_change != par_.lookupChange(pos))
288 char_type c = par_.getChar(pos);
290 if (!isPrintableNonspace(c))
293 if (arabic && Encodings::isComposeChar_arabic(c))
296 if (hebrew && Encodings::isComposeChar_hebrew(c))
300 c = par_.transformChar(c, pos);
309 if (prev_change == Change::DELETED)
310 font.setColor(LColor::strikeout);
311 else if (prev_change == Change::INSERTED)
312 font.setColor(LColor::newtext);
314 // Draw text and set the new x position
315 //lyxerr << "paint row: yo_ " << yo_ << "\n";
317 pain_.text(int(x_), yo_, str, font);
318 x_ += font_metrics::width(str, font);
320 pain_.text(int(x_), yo_, &str[0], str.size(), font);
321 x_ += font_metrics::width(&str[0], str.size(), font);
326 void RowPainter::paintForeignMark(double orig_x, LyXFont const & font, int desc)
328 if (!lyxrc.mark_foreign_language)
330 if (font.language() == latex_language)
332 if (font.language() == bv_.buffer()->params().language)
335 int const y = yo_ + 1 + desc;
336 pain_.line(int(orig_x), y, int(x_), y, LColor::language);
340 void RowPainter::paintFromPos(pos_type & vpos)
342 pos_type const pos = text_.bidi.vis2log(vpos);
343 LyXFont orig_font = text_.getFont(par_, pos);
345 double const orig_x = x_;
347 if (par_.isInset(pos)) {
348 paintInset(pos, orig_font);
350 paintForeignMark(orig_x, orig_font,
351 par_.getInset(pos)->descent());
355 // usual characters, no insets
356 char_type const c = par_.getChar(pos);
358 // special case languages
359 std::string const & lang = orig_font.language()->lang();
360 bool const hebrew = lang == "hebrew";
361 bool const arabic = lang == "arabic" &&
362 (lyxrc.font_norm_type == LyXRC::ISO_8859_6_8 ||
363 lyxrc.font_norm_type == LyXRC::ISO_10646_1);
365 // draw as many chars as we can
366 if ((!hebrew && !arabic)
367 || (hebrew && !Encodings::isComposeChar_hebrew(c))
368 || (arabic && !Encodings::isComposeChar_arabic(c))) {
369 paintChars(vpos, orig_font, hebrew, arabic);
371 paintHebrewComposeChar(vpos, orig_font);
373 paintArabicComposeChar(vpos, orig_font);
376 paintForeignMark(orig_x, orig_font);
380 void RowPainter::paintChangeBar()
382 pos_type const start = row_.pos();
383 pos_type const end = row_.endpos();
385 if (start == end || !par_.isChanged(start, end))
388 int const height = text_.isLastRow(pit_, row_)
392 pain_.fillRectangle(4, yo_ - row_.ascent(), 5, height, LColor::changebar);
396 void RowPainter::paintAppendix()
398 if (!par_.params().appendix())
401 int y = yo_ - row_.ascent();
403 if (par_.params().startOfAppendix())
404 y += 2 * defaultRowHeight();
406 pain_.line(1, y, 1, yo_ + row_.height(), LColor::appendix);
407 pain_.line(width_ - 2, y, width_ - 2, yo_ + row_.height(), LColor::appendix);
411 void RowPainter::paintDepthBar()
413 Paragraph::depth_type const depth = par_.getDepth();
418 Paragraph::depth_type prev_depth = 0;
419 if (!text_.isFirstRow(pit_, row_)) {
420 pit_type pit2 = pit_;
423 prev_depth = pars_[pit2].getDepth();
426 Paragraph::depth_type next_depth = 0;
427 if (!text_.isLastRow(pit_, row_)) {
428 pit_type pit2 = pit_;
429 if (row_.endpos() >= pars_[pit2].size())
431 next_depth = pars_[pit2].getDepth();
434 for (Paragraph::depth_type i = 1; i <= depth; ++i) {
435 int const w = nestMargin() / 5;
436 int x = int(xo_) + w * i;
437 // only consider the changebar space if we're drawing outermost text
438 if (text_.isMainText())
439 x += changebarMargin();
441 int const starty = yo_ - row_.ascent();
442 int const h = row_.height() - 1 - (i - next_depth - 1) * 3;
444 pain_.line(x, starty, x, starty + h, LColor::depthbar);
447 pain_.fillRectangle(x, starty, w, 2, LColor::depthbar);
449 pain_.fillRectangle(x, starty + h, w, 2, LColor::depthbar);
454 int RowPainter::paintAppendixStart(int y)
457 pb_font.setColor(LColor::appendix);
460 string const label = lyx::to_utf8(_("Appendix"));
464 docstring dlab(label.begin(), label.end());
465 font_metrics::rectText(dlab, pb_font, w, a, d);
467 int const text_start = int(xo_ + (width_ - w) / 2);
468 int const text_end = text_start + w;
470 pain_.rectText(text_start, y + d, dlab, pb_font, LColor::none, LColor::none);
472 pain_.line(int(xo_ + 1), y, text_start, y, LColor::appendix);
473 pain_.line(text_end, y, int(xo_ + width_ - 2), y, LColor::appendix);
475 return 3 * defaultRowHeight();
479 void RowPainter::paintFirst()
481 ParagraphParameters const & parparams = par_.params();
485 // start of appendix?
486 if (parparams.startOfAppendix())
487 y_top += paintAppendixStart(yo_ - row_.ascent() + 2 * defaultRowHeight());
489 Buffer const & buffer = *bv_.buffer();
491 LyXLayout_ptr const & layout = par_.layout();
493 if (buffer.params().paragraph_separation == BufferParams::PARSEP_SKIP) {
495 if (layout->latextype == LATEX_PARAGRAPH
496 && !par_.getDepth()) {
497 y_top += buffer.params().getDefSkip().inPixels(bv_);
499 LyXLayout_ptr const & playout = pars_[pit_ - 1].layout();
500 if (playout->latextype == LATEX_PARAGRAPH
501 && !pars_[pit_ - 1].getDepth()) {
502 // is it right to use defskip here, too? (AS)
503 y_top += buffer.params().getDefSkip().inPixels(bv_);
509 bool const is_rtl = text_.isRTL(par_);
510 bool const is_seq = isFirstInSequence(pit_, text_.paragraphs());
511 //lyxerr << "paintFirst: " << par_.id() << " is_seq: " << is_seq << std::endl;
513 // should we print a label?
514 if (layout->labeltype >= LABEL_STATIC
515 && (layout->labeltype != LABEL_STATIC
516 || layout->latextype != LATEX_ENVIRONMENT
519 LyXFont const font = getLabelFont();
520 string const str = par_.getLabelstring();
523 docstring dstr(str.begin(), str.end());
525 // this is special code for the chapter layout. This is
526 // printed in an extra row and has a pagebreak at
528 if (layout->counter == "chapter") {
529 double spacing_val = 1.0;
530 if (!parparams.spacing().isDefault()) {
531 spacing_val = parparams.spacing().getValue();
533 spacing_val = buffer.params().spacing().getValue();
536 int const labeladdon = int(font_metrics::maxHeight(font) * layout->spacing.getValue() * spacing_val);
538 int const maxdesc = int(font_metrics::maxDescent(font) * layout->spacing.getValue() * spacing_val)
539 + int(layout->parsep) * defaultRowHeight();
542 x = width_ - leftMargin() -
543 font_metrics::width(dstr, font);
546 pain_.text(int(x), yo_ - maxdesc - labeladdon, dstr, font);
548 string lab = layout->labelsep;
549 docstring dlab(lab.begin(), lab.end());
551 x = width_ - leftMargin()
552 + font_metrics::width(dlab, font);
554 x = x_ - font_metrics::width(dlab, font)
555 - font_metrics::width(dstr, font);
558 pain_.text(int(x), yo_, dstr, font);
562 // the labels at the top of an environment.
563 // More or less for bibliography
565 (layout->labeltype == LABEL_TOP_ENVIRONMENT ||
566 layout->labeltype == LABEL_BIBLIO ||
567 layout->labeltype == LABEL_CENTERED_TOP_ENVIRONMENT)) {
568 LyXFont font = getLabelFont();
569 if (!par_.getLabelstring().empty()) {
570 string const str = par_.getLabelstring();
571 docstring dstr(str.begin(), str.end());
572 double spacing_val = 1.0;
573 if (!parparams.spacing().isDefault())
574 spacing_val = parparams.spacing().getValue();
576 spacing_val = buffer.params().spacing().getValue();
578 int const labeladdon = int(font_metrics::maxHeight(font) * layout->spacing.getValue() * spacing_val);
581 int(font_metrics::maxDescent(font) * layout->spacing.getValue() * spacing_val
582 + (layout->labelbottomsep * defaultRowHeight()));
585 if (layout->labeltype == LABEL_CENTERED_TOP_ENVIRONMENT) {
588 x += (width_ - text_.rightMargin(par_) - leftMargin()) / 2;
589 x -= font_metrics::width(dstr, font) / 2;
591 x = width_ - leftMargin() -
592 font_metrics::width(dstr, font);
594 pain_.text(int(x), yo_ - maxdesc - labeladdon, dstr, font);
600 void RowPainter::paintLast()
602 bool const is_rtl = text_.isRTL(par_);
603 int const endlabel = getEndLabel(pit_, text_.paragraphs());
608 case END_LABEL_FILLED_BOX: {
609 LyXFont const font = getLabelFont();
610 int const size = int(0.75 * font_metrics::maxAscent(font));
611 int const y = yo_ - size;
612 int x = is_rtl ? nestMargin() + changebarMargin() : width_ - size;
614 if (width_ - int(row_.width()) <= size)
615 x += (size - width_ + row_.width() + 1) * (is_rtl ? -1 : 1);
617 if (endlabel == END_LABEL_BOX)
618 pain_.rectangle(x, y, size, size, LColor::eolmarker);
620 pain_.fillRectangle(x, y, size, size, LColor::eolmarker);
624 case END_LABEL_STATIC: {
625 LyXFont font = getLabelFont();
626 string const & str = par_.layout()->endlabelstring();
627 docstring dstr(str.begin(), str.end());
628 double const x = is_rtl ?
629 x_ - font_metrics::width(dstr, font)
630 : - text_.rightMargin(par_) - row_.width();
631 pain_.text(int(x), yo_, dstr, font);
635 case END_LABEL_NO_LABEL:
641 void RowPainter::paintText()
643 pos_type const end = row_.endpos();
644 pos_type body_pos = par_.beginOfBody();
646 (body_pos > end || !par_.isLineSeparator(body_pos - 1))) {
650 LyXLayout_ptr const & layout = par_.layout();
652 bool running_strikeout = false;
653 bool is_struckout = false;
654 int last_strikeout_x = 0;
656 // Use font span to speed things up, see below
660 for (pos_type vpos = row_.pos(); vpos < end; ) {
661 if (x_ > bv_.workWidth())
664 pos_type const pos = text_.bidi.vis2log(vpos);
666 if (pos >= par_.size()) {
671 // Use font span to speed things up, see above
672 if (vpos < font_span.first || vpos > font_span.last) {
673 font_span = par_.fontSpan(vpos);
674 font = text_.getFont(par_, vpos);
677 const int width_pos =
678 text_.singleWidth(par_, pos, par_.getChar(pos), font);
680 if (x_ + width_pos < 0) {
686 is_struckout = isDeletedText(par_, pos);
688 if (is_struckout && !running_strikeout) {
689 running_strikeout = true;
690 last_strikeout_x = int(x_);
693 bool const highly_editable_inset = par_.isInset(pos)
694 && isHighlyEditableInset(par_.getInset(pos));
696 // If we reach the end of a struck out range, paint it.
697 // We also don't paint across things like tables
698 if (running_strikeout && (highly_editable_inset || !is_struckout)) {
699 // Calculate 1/3 height of the buffer's default font
702 font_metrics::maxAscent(bv_.buffer()->params().getFont()) / 3;
703 pain_.line(last_strikeout_x, middle, int(x_), middle,
704 LColor::strikeout, Painter::line_solid, Painter::line_thin);
705 running_strikeout = false;
708 if (body_pos > 0 && pos == body_pos - 1) {
709 string lab = layout->labelsep;
710 docstring dlab(lab.begin(), lab.end());
711 int const lwidth = font_metrics::width(dlab,
714 x_ += label_hfill_ + lwidth - width_pos;
717 if (par_.isHfill(pos)) {
721 int const y1 = y0 - defaultRowHeight() / 2;
723 pain_.line(int(x_), y1, int(x_), y0, LColor::added_space);
725 if (hfillExpansion(par_, row_, pos)) {
726 int const y2 = (y0 + y1) / 2;
728 if (pos >= body_pos) {
729 pain_.line(int(x_), y2, int(x_ + hfill_), y2,
731 Painter::line_onoffdash);
734 pain_.line(int(x_), y2, int(x_ + label_hfill_), y2,
736 Painter::line_onoffdash);
739 pain_.line(int(x_), y1, int(x_), y0, LColor::added_space);
743 } else if (par_.isSeparator(pos)) {
753 // if we reach the end of a struck out range, paint it
754 if (running_strikeout) {
755 // calculate 1/3 height of the buffer's default font
758 font_metrics::maxAscent(bv_.buffer()->params().getFont()) / 3;
759 pain_.line(last_strikeout_x, middle, int(x_), middle,
760 LColor::strikeout, Painter::line_solid, Painter::line_thin);
761 running_strikeout = false;
766 lyx::size_type calculateRowSignature(Row const & row, Paragraph const & par,
769 boost::crc_32_type crc;
770 for (lyx::pos_type i = row.pos(); i < row.endpos(); ++i) {
771 const unsigned char b[] = { par.getChar(i) };
772 crc.process_bytes(b, 1);
774 const unsigned char b[] = { x, y, row.width() };
775 crc.process_bytes(b, 3);
776 return crc.checksum();
780 bool CursorOnRow(PainterInfo & pi, pit_type const pit,
781 RowList::const_iterator rit, LyXText const & text)
783 // Is there a cursor on this row (or inside inset on row)
784 LCursor & cur = pi.base.bv->cursor();
785 for (lyx::size_type d = 0; d < cur.depth(); d++) {
786 CursorSlice const & sl = cur[d];
787 if (sl.text() == &text
789 && sl.pos() >= rit->pos()
790 && sl.pos() <= rit->endpos())
797 bool innerCursorOnRow(PainterInfo & pi, pit_type pit,
798 RowList::const_iterator rit, LyXText const & text)
800 // Is there a cursor inside an inset on this row, and is this inset
801 // the only "character" on this row
802 LCursor & cur = pi.base.bv->cursor();
803 if (rit->pos() + 1 != rit->endpos())
805 for (lyx::size_type d = 0; d < cur.depth(); d++) {
806 CursorSlice const & sl = cur[d];
807 if (sl.text() == &text
809 && sl.pos() == rit->pos())
810 return d < cur.depth() - 1;
817 (PainterInfo & pi, LyXText const & text, pit_type pit, int x, int y,
820 // lyxerr << " paintPar: pit: " << pit << " at y: " << y << endl;
821 static NullPainter nop;
822 static PainterInfo nullpi(pi.base.bv, nop);
823 int const ww = pi.base.bv->workHeight();
825 theCoords.parPos()[&text][pit] = Point(x, y);
827 Paragraph const & par = text.paragraphs()[pit];
828 if (par.rows().empty())
831 RowList::const_iterator const rb = par.rows().begin();
832 RowList::const_iterator const re = par.rows().end();
835 lyx::size_type rowno(0);
836 for (RowList::const_iterator rit = rb; rit != re; ++rit, ++rowno) {
838 // Allow setting of refreshInside for nested insets in
840 bool tmp = refreshInside;
842 // Row signature; has row changed since last paint?
843 lyx::size_type const row_sig = calculateRowSignature(*rit, par, x, y);
844 bool row_has_changed = par.rowSignature()[rowno] != row_sig;
846 bool cursor_on_row = CursorOnRow(pi, pit, rit, text);
847 bool in_inset_alone_on_row = innerCursorOnRow(pi, pit, rit,
850 // If this is the only object on the row, we can make it wide
851 for (pos_type i = rit->pos() ; i != rit->endpos(); ++i) {
852 InsetBase const * const in = par.getInset(i);
854 InsetText const * const t = in->asTextInset();
856 t->Wide() = in_inset_alone_on_row;
860 // If selection is on, the current row signature differs
861 // from cache, or cursor is inside an inset _on this row_,
862 // then paint the row
863 if (repaintAll || row_has_changed || cursor_on_row) {
864 // Add to row signature cache
865 par.rowSignature()[rowno] = row_sig;
867 bool const inside = (y + rit->descent() >= 0
868 && y - rit->ascent() < ww);
869 RowPainter rp(inside ? pi : nullpi, text, pit, *rit, x, y);
870 // Clear background of this row
871 // (if paragraph background was not cleared)
873 (!in_inset_alone_on_row || row_has_changed)) {
874 pi.pain.fillRectangle(x, y - rit->ascent(),
875 text.maxwidth_, rit->height(),
876 text.backgroundColor());
877 // If outer row has changed, force nested
878 // insets to repaint completely
880 refreshInside = true;
883 // Instrumentation for testing row cache (see also
885 if (text.isMainText())
886 lyxerr[Debug::PAINTING] << "#";
888 lyxerr[Debug::PAINTING] << "[" <<
889 repaintAll << row_has_changed <<
890 cursor_on_row << "]";
901 // Restore, see above
904 lyxerr[Debug::PAINTING] << "." << endl;
910 void paintText(BufferView const & bv, ViewMetricsInfo const & vi,
913 LyXText & text = bv.buffer()->text();
914 bool const select = bv.cursor().selection();
916 PainterInfo pi(const_cast<BufferView *>(&bv), pain);
917 // Should the whole screen, including insets, be refreshed?
918 bool repaintAll = select || !vi.singlepar;
921 // Clear background (if not delegated to rows)
922 pain.fillRectangle(0, vi.y1, bv.workWidth(), vi.y2 - vi.y1,
923 text.backgroundColor());
926 text.drawSelection(pi, 0, 0);
931 for (pit_type pit = vi.p1; pit <= vi.p2; ++pit) {
932 refreshInside = repaintAll;
933 Paragraph const & par = text.getPar(pit);
935 paintPar(pi, text, pit, 0, yy, repaintAll);
939 // Cache one paragraph above and one below
940 // Note MV: this cannot be suppressed even for singlepar.
941 // Try viewing the User Guide Mobius figure
944 text.redoParagraph(vi.p1 - 1);
945 theCoords.parPos()[&text][vi.p1 - 1] =
946 Point(0, vi.y1 - text.getPar(vi.p1 - 1).descent());
949 if (vi.p2 < lyx::pit_type(text.paragraphs().size()) - 1) {
950 text.redoParagraph(vi.p2 + 1);
951 theCoords.parPos()[&text][vi.p2 + 1] =
952 Point(0, vi.y2 + text.getPar(vi.p2 + 1).ascent());
955 // and grey out above (should not happen later)
956 // lyxerr << "par ascent: " << text.getPar(vi.p1).ascent() << endl;
957 if (vi.y1 > 0 && !vi.singlepar)
958 pain.fillRectangle(0, 0, bv.workWidth(), vi.y1, LColor::bottomarea);
960 // and possibly grey out below
961 // lyxerr << "par descent: " << text.getPar(vi.p1).ascent() << endl;
962 if (vi.y2 < bv.workHeight() && !vi.singlepar)
963 pain.fillRectangle(0, vi.y2, bv.workWidth(), bv.workHeight() - vi.y2, LColor::bottomarea);
967 void paintTextInset(LyXText const & text, PainterInfo & pi, int x, int y)
969 // lyxerr << " paintTextInset: y: " << y << endl;
971 y -= text.getPar(0).ascent();
972 // This flag can not be set from within same inset:
973 bool repaintAll = refreshInside;
974 for (int pit = 0; pit < int(text.paragraphs().size()); ++pit) {
975 y += text.getPar(pit).ascent();
976 paintPar(pi, text, pit, x, y, repaintAll);
977 y += text.getPar(pit).descent();