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 "metricsinfo.h"
29 #include "paragraph.h"
30 #include "paragraph_funcs.h"
31 #include "ParagraphParameters.h"
34 #include "frontends/FontMetrics.h"
35 #include "frontends/Painter.h"
37 #include "insets/insettext.h"
39 #include "support/textutils.h"
41 #include <boost/crc.hpp>
46 using frontend::Painter;
47 using frontend::FontMetrics;
57 /// Flag: do a full redraw of inside text of inset
58 /// Working variable indicating a full screen refresh
62 * A class used for painting an individual row of text.
66 /// initialise and run painter
67 RowPainter(PainterInfo & pi, LyXText const & text,
68 pit_type pit, Row const & row, int x, int y);
70 // paint various parts
73 void paintChangeBar();
79 void paintForeignMark(double orig_x, LyXFont const & font, int desc = 0);
80 void paintHebrewComposeChar(pos_type & vpos, LyXFont const & font);
81 void paintArabicComposeChar(pos_type & vpos, LyXFont const & font);
82 void paintChars(pos_type & vpos, LyXFont const & font,
83 bool hebrew, bool arabic);
84 int paintAppendixStart(int y);
85 void paintFromPos(pos_type & vpos);
86 void paintInset(pos_type const pos, LyXFont const & font);
88 /// return left margin
89 int leftMargin() const;
91 /// return the label font for this row
92 LyXFont const getLabelFont() const;
94 /// bufferview to paint on
100 /// LyXText for the row
101 LyXText const & text_;
102 ParagraphList const & pars_;
109 Paragraph const & par_;
111 /// is row erased? (change tracking)
116 int const yo_; // current baseline
125 RowPainter::RowPainter(PainterInfo & pi,
126 LyXText const & text, pit_type pit, Row const & row, int x, int y)
127 : bv_(*pi.base.bv), pain_(pi.pain), text_(text), pars_(text.paragraphs()),
128 row_(row), pit_(pit), par_(text.paragraphs()[pit]),
130 xo_(x), yo_(y), width_(text_.width())
132 RowMetrics m = text_.computeRowMetrics(*bv_.buffer(), pit, row_);
135 //lyxerr << "RowPainter: x: " << x_ << " xo: " << xo_ << " yo: " << yo_ << endl;
138 separator_ = m.separator;
140 label_hfill_ = m.label_hfill;
142 BOOST_ASSERT(pit >= 0);
143 BOOST_ASSERT(pit < int(text.paragraphs().size()));
147 LyXFont const RowPainter::getLabelFont() const
149 return text_.getLabelFont(*bv_.buffer(), par_);
153 int RowPainter::leftMargin() const
155 return text_.leftMargin(*bv_.buffer(), pit_, row_.pos());
159 void RowPainter::paintInset(pos_type const pos, LyXFont const & font)
161 InsetBase const * inset = par_.getInset(pos);
163 PainterInfo pi(const_cast<BufferView *>(&bv_), pain_);
164 // FIXME: We should always use font, see documentation of
165 // noFontChange() in insetbase.h.
166 pi.base.font = inset->noFontChange() ?
167 bv_.buffer()->params().getFont() :
169 pi.ltr_pos = (text_.bidi.level(pos) % 2 == 0);
170 pi.erased_ = erased_ || par_.isDeleted(pos);
171 bv_.coordCache().insets().add(inset, int(x_), yo_);
172 InsetText const * const in = inset->asTextInset();
173 // non-wide insets are painted completely. Recursive
174 bool tmp = refreshInside;
175 if (!in || !in->Wide()) {
176 refreshInside = true;
177 lyxerr[Debug::PAINTING] << endl << "Paint inset fully" << endl;
180 inset->drawSelection(pi, int(x_), yo_);
181 inset->draw(pi, int(x_), yo_);
183 x_ += inset->width();
187 void RowPainter::paintHebrewComposeChar(pos_type & vpos, LyXFont const & font)
189 pos_type pos = text_.bidi.vis2log(vpos);
194 char_type c = par_.getChar(pos);
198 int const width = theFontMetrics(font).width(c);
201 for (pos_type i = pos - 1; i >= 0; --i) {
203 if (!Encodings::isComposeChar_hebrew(c)) {
204 if (isPrintableNonspace(c)) {
205 int const width2 = text_.singleWidth(par_, i, c,
206 text_.getFont(*bv_.buffer(), par_, i));
208 // This does not work anymore, and non-ascii
209 // characters in source files are forbidden
212 dx = (c == 'ø' || c == 'ã')
214 : (width2 - width) / 2;
222 pain_.text(int(x_) + dx, yo_, str, font);
226 void RowPainter::paintArabicComposeChar(pos_type & vpos, LyXFont const & font)
228 pos_type pos = text_.bidi.vis2log(vpos);
232 char_type c = par_.getChar(pos);
233 c = par_.transformChar(c, pos);
237 int const width = theFontMetrics(font).width(c);
240 for (pos_type i = pos - 1; i >= 0; --i) {
242 if (!Encodings::isComposeChar_arabic(c)) {
243 if (isPrintableNonspace(c)) {
244 int const width2 = text_.singleWidth(par_, i, c,
245 text_.getFont(*bv_.buffer(), par_, i));
246 dx = (width2 - width) / 2;
252 pain_.text(int(x_) + dx, yo_, str, font);
255 void RowPainter::paintChars(pos_type & vpos, LyXFont const & font,
256 bool hebrew, bool arabic)
258 // This method takes up 70% of time when typing
259 pos_type pos = text_.bidi.vis2log(vpos);
260 pos_type const end = row_.endpos();
261 FontSpan const font_span = par_.fontSpan(pos);
262 Change::Type const prev_change = par_.lookupChange(pos).type;
265 std::vector<char_type> str;
267 str.push_back(par_.getChar(pos));
270 char_type c = str[0];
271 str[0] = par_.transformChar(c, pos);
274 // collect as much similar chars as we can
275 for (++vpos ; vpos < end ; ++vpos) {
276 pos = text_.bidi.vis2log(vpos);
277 if (pos < font_span.first || pos > font_span.last)
280 if (prev_change != par_.lookupChange(pos).type)
283 char_type c = par_.getChar(pos);
285 if (!isPrintableNonspace(c))
288 if (arabic && Encodings::isComposeChar_arabic(c))
291 if (hebrew && Encodings::isComposeChar_hebrew(c))
295 c = par_.transformChar(c, pos);
300 if (prev_change != Change::UNCHANGED) {
302 if (prev_change == Change::DELETED) {
303 copy.setColor(LColor::strikeout);
304 } else if (prev_change == Change::INSERTED) {
305 copy.setColor(LColor::newtext);
307 x_ += pain_.text(int(x_), yo_, &str[0], str.size(), copy);
309 x_ += pain_.text(int(x_), yo_, &str[0], str.size(), font);
314 void RowPainter::paintForeignMark(double orig_x, LyXFont const & font, int desc)
316 if (!lyxrc.mark_foreign_language)
318 if (font.language() == latex_language)
320 if (font.language() == bv_.buffer()->params().language)
323 int const y = yo_ + 1 + desc;
324 pain_.line(int(orig_x), y, int(x_), y, LColor::language);
328 void RowPainter::paintFromPos(pos_type & vpos)
330 pos_type const pos = text_.bidi.vis2log(vpos);
331 LyXFont orig_font = text_.getFont(*bv_.buffer(), par_, pos);
333 double const orig_x = x_;
335 if (par_.isInset(pos)) {
336 paintInset(pos, orig_font);
338 paintForeignMark(orig_x, orig_font,
339 par_.getInset(pos)->descent());
343 // usual characters, no insets
344 char_type const c = par_.getChar(pos);
346 // special case languages
347 std::string const & lang = orig_font.language()->lang();
348 bool const hebrew = lang == "hebrew";
349 bool const arabic = lang == "arabic" &&
350 (lyxrc.font_norm_type == LyXRC::ISO_8859_6_8 ||
351 lyxrc.font_norm_type == LyXRC::ISO_10646_1);
353 // draw as many chars as we can
354 if ((!hebrew && !arabic)
355 || (hebrew && !Encodings::isComposeChar_hebrew(c))
356 || (arabic && !Encodings::isComposeChar_arabic(c))) {
357 paintChars(vpos, orig_font, hebrew, arabic);
359 paintHebrewComposeChar(vpos, orig_font);
361 paintArabicComposeChar(vpos, orig_font);
364 paintForeignMark(orig_x, orig_font);
368 void RowPainter::paintChangeBar()
370 pos_type const start = row_.pos();
371 pos_type end = row_.endpos();
373 if (par_.size() == end) {
374 // this is the last row of the paragraph;
375 // thus, we must also consider the imaginary end-of-par character
379 if (start == end || !par_.isChanged(start, end))
382 int const height = text_.isLastRow(pit_, row_)
386 pain_.fillRectangle(5, yo_ - row_.ascent(), 3, height, LColor::changebar);
390 void RowPainter::paintAppendix()
392 if (!par_.params().appendix())
395 int y = yo_ - row_.ascent();
397 if (par_.params().startOfAppendix())
398 y += 2 * defaultRowHeight();
400 pain_.line(1, y, 1, yo_ + row_.height(), LColor::appendix);
401 pain_.line(width_ - 2, y, width_ - 2, yo_ + row_.height(), LColor::appendix);
405 void RowPainter::paintDepthBar()
407 depth_type const depth = par_.getDepth();
412 depth_type prev_depth = 0;
413 if (!text_.isFirstRow(pit_, row_)) {
414 pit_type pit2 = pit_;
417 prev_depth = pars_[pit2].getDepth();
420 depth_type next_depth = 0;
421 if (!text_.isLastRow(pit_, row_)) {
422 pit_type pit2 = pit_;
423 if (row_.endpos() >= pars_[pit2].size())
425 next_depth = pars_[pit2].getDepth();
428 for (depth_type i = 1; i <= depth; ++i) {
429 int const w = nestMargin() / 5;
430 int x = int(xo_) + w * i;
431 // only consider the changebar space if we're drawing outermost text
432 if (text_.isMainText(*bv_.buffer()))
433 x += changebarMargin();
435 int const starty = yo_ - row_.ascent();
436 int const h = row_.height() - 1 - (i - next_depth - 1) * 3;
438 pain_.line(x, starty, x, starty + h, LColor::depthbar);
441 pain_.fillRectangle(x, starty, w, 2, LColor::depthbar);
443 pain_.fillRectangle(x, starty + h, w, 2, LColor::depthbar);
448 int RowPainter::paintAppendixStart(int y)
451 pb_font.setColor(LColor::appendix);
458 docstring const label = _("Appendix");
459 theFontMetrics(pb_font).rectText(label, w, a, d);
461 int const text_start = int(xo_ + (width_ - w) / 2);
462 int const text_end = text_start + w;
464 pain_.rectText(text_start, y + d, label, pb_font, LColor::none, LColor::none);
466 pain_.line(int(xo_ + 1), y, text_start, y, LColor::appendix);
467 pain_.line(text_end, y, int(xo_ + width_ - 2), y, LColor::appendix);
469 return 3 * defaultRowHeight();
473 void RowPainter::paintFirst()
475 ParagraphParameters const & parparams = par_.params();
479 // start of appendix?
480 if (parparams.startOfAppendix())
481 y_top += paintAppendixStart(yo_ - row_.ascent() + 2 * defaultRowHeight());
483 Buffer const & buffer = *bv_.buffer();
485 LyXLayout_ptr const & layout = par_.layout();
487 if (buffer.params().paragraph_separation == BufferParams::PARSEP_SKIP) {
489 if (layout->latextype == LATEX_PARAGRAPH
490 && !par_.getDepth()) {
491 y_top += buffer.params().getDefSkip().inPixels(bv_);
493 LyXLayout_ptr const & playout = pars_[pit_ - 1].layout();
494 if (playout->latextype == LATEX_PARAGRAPH
495 && !pars_[pit_ - 1].getDepth()) {
496 // is it right to use defskip here, too? (AS)
497 y_top += buffer.params().getDefSkip().inPixels(bv_);
503 bool const is_rtl = text_.isRTL(buffer, par_);
504 bool const is_seq = isFirstInSequence(pit_, text_.paragraphs());
505 //lyxerr << "paintFirst: " << par_.id() << " is_seq: " << is_seq << std::endl;
507 // should we print a label?
508 if (layout->labeltype >= LABEL_STATIC
509 && (layout->labeltype != LABEL_STATIC
510 || layout->latextype != LATEX_ENVIRONMENT
513 LyXFont const font = getLabelFont();
514 FontMetrics const & fm = theFontMetrics(font);
516 docstring const str = par_.getLabelstring();
520 // this is special code for the chapter layout. This is
521 // printed in an extra row and has a pagebreak at
523 if (layout->counter == "chapter") {
524 double spacing_val = 1.0;
525 if (!parparams.spacing().isDefault()) {
526 spacing_val = parparams.spacing().getValue();
528 spacing_val = buffer.params().spacing().getValue();
531 int const labeladdon = int(fm.maxHeight() * layout->spacing.getValue() * spacing_val);
533 int const maxdesc = int(fm.maxDescent() * layout->spacing.getValue() * spacing_val)
534 + int(layout->parsep) * defaultRowHeight();
537 x = width_ - leftMargin() -
541 pain_.text(int(x), yo_ - maxdesc - labeladdon, str, font);
544 docstring lab = from_utf8(layout->labelsep);
546 x = width_ - leftMargin()
549 x = x_ - fm.width(lab)
553 pain_.text(int(x), yo_, str, font);
557 // the labels at the top of an environment.
558 // More or less for bibliography
560 (layout->labeltype == LABEL_TOP_ENVIRONMENT ||
561 layout->labeltype == LABEL_BIBLIO ||
562 layout->labeltype == LABEL_CENTERED_TOP_ENVIRONMENT)) {
563 LyXFont font = getLabelFont();
564 if (!par_.getLabelstring().empty()) {
565 docstring const str = par_.getLabelstring();
566 double spacing_val = 1.0;
567 if (!parparams.spacing().isDefault())
568 spacing_val = parparams.spacing().getValue();
570 spacing_val = buffer.params().spacing().getValue();
572 FontMetrics const & fm = theFontMetrics(font);
574 int const labeladdon = int(fm.maxHeight()
575 * layout->spacing.getValue() * spacing_val);
578 int(fm.maxDescent() * layout->spacing.getValue() * spacing_val
579 + (layout->labelbottomsep * defaultRowHeight()));
582 if (layout->labeltype == LABEL_CENTERED_TOP_ENVIRONMENT) {
585 x += (width_ - text_.rightMargin(buffer, par_) - leftMargin()) / 2;
586 x -= fm.width(str) / 2;
588 x = width_ - leftMargin() - fm.width(str);
590 pain_.text(int(x), yo_ - maxdesc - labeladdon, str, font);
596 void RowPainter::paintLast()
598 bool const is_rtl = text_.isRTL(*bv_.buffer(), par_);
599 int const endlabel = getEndLabel(pit_, text_.paragraphs());
604 case END_LABEL_FILLED_BOX: {
605 LyXFont const font = getLabelFont();
606 FontMetrics const & fm = theFontMetrics(font);
607 int const size = int(0.75 * fm.maxAscent());
608 int const y = yo_ - size;
609 int x = is_rtl ? nestMargin() + changebarMargin() : width_ - size;
611 if (width_ - int(row_.width()) <= size)
612 x += (size - width_ + row_.width() + 1) * (is_rtl ? -1 : 1);
614 if (endlabel == END_LABEL_BOX)
615 pain_.rectangle(x, y, size, size, LColor::eolmarker);
617 pain_.fillRectangle(x, y, size, size, LColor::eolmarker);
621 case END_LABEL_STATIC: {
622 LyXFont font = getLabelFont();
623 FontMetrics const & fm = theFontMetrics(font);
624 docstring const & str = par_.layout()->endlabelstring();
625 double const x = is_rtl ?
627 : - text_.rightMargin(*bv_.buffer(), par_) - row_.width();
628 pain_.text(int(x), yo_, str, font);
632 case END_LABEL_NO_LABEL:
638 void RowPainter::paintText()
640 pos_type const end = row_.endpos();
641 pos_type body_pos = par_.beginOfBody();
643 (body_pos > end || !par_.isLineSeparator(body_pos - 1))) {
647 LyXLayout_ptr const & layout = par_.layout();
649 bool running_strikeout = false;
650 bool is_struckout = false;
651 int last_strikeout_x = 0;
653 // Use font span to speed things up, see below
656 Buffer const & buffer = *bv_.buffer();
658 for (pos_type vpos = row_.pos(); vpos < end; ) {
659 if (x_ > bv_.workWidth())
662 pos_type const pos = text_.bidi.vis2log(vpos);
664 if (pos >= par_.size()) {
669 // Use font span to speed things up, see above
670 if (vpos < font_span.first || vpos > font_span.last) {
671 font_span = par_.fontSpan(vpos);
672 font = text_.getFont(buffer, par_, vpos);
675 const int width_pos =
676 text_.singleWidth(par_, pos, par_.getChar(pos), font);
678 if (x_ + width_pos < 0) {
684 is_struckout = par_.isDeleted(pos);
686 if (is_struckout && !running_strikeout) {
687 running_strikeout = true;
688 last_strikeout_x = int(x_);
691 bool const highly_editable_inset = par_.isInset(pos)
692 && isHighlyEditableInset(par_.getInset(pos));
694 // If we reach the end of a struck out range, paint it.
695 // We also don't paint across things like tables
696 if (running_strikeout && (highly_editable_inset || !is_struckout)) {
697 // Calculate 1/3 height of the buffer's default font
698 FontMetrics const & fm
699 = theFontMetrics(bv_.buffer()->params().getFont());
700 int const middle = yo_ - fm.maxAscent() / 3;
701 pain_.line(last_strikeout_x, middle, int(x_), middle,
702 LColor::strikeout, Painter::line_solid, Painter::line_thin);
703 running_strikeout = false;
706 if (body_pos > 0 && pos == body_pos - 1) {
708 int const lwidth = theFontMetrics(getLabelFont())
709 .width(from_utf8(layout->labelsep));
711 x_ += label_hfill_ + lwidth - width_pos;
714 if (par_.isHfill(pos)) {
718 int const y1 = y0 - defaultRowHeight() / 2;
720 pain_.line(int(x_), y1, int(x_), y0, LColor::added_space);
722 if (par_.hfillExpansion(row_, pos)) {
723 int const y2 = (y0 + y1) / 2;
725 if (pos >= body_pos) {
726 pain_.line(int(x_), y2, int(x_ + hfill_), y2,
728 Painter::line_onoffdash);
731 pain_.line(int(x_), y2, int(x_ + label_hfill_), y2,
733 Painter::line_onoffdash);
736 pain_.line(int(x_), y1, int(x_), y0, LColor::added_space);
740 } else if (par_.isSeparator(pos)) {
750 // if we reach the end of a struck out range, paint it
751 if (running_strikeout) {
752 // calculate 1/3 height of the buffer's default font
753 FontMetrics const & fm
754 = theFontMetrics(bv_.buffer()->params().getFont());
755 int const middle = yo_ - fm.maxAscent() / 3;
756 pain_.line(last_strikeout_x, middle, int(x_), middle,
757 LColor::strikeout, Painter::line_solid, Painter::line_thin);
758 running_strikeout = false;
763 size_type calculateRowSignature(Row const & row, Paragraph const & par,
766 boost::crc_32_type crc;
767 for (pos_type i = row.pos(); i < row.endpos(); ++i) {
768 char_type const b[] = { par.getChar(i) };
769 crc.process_bytes(b, 1);
771 char_type const b[] = { x, y, row.width() };
772 crc.process_bytes(b, 3);
773 return crc.checksum();
777 bool CursorOnRow(PainterInfo & pi, pit_type const pit,
778 RowList::const_iterator rit, LyXText const & text)
780 // Is there a cursor on this row (or inside inset on row)
781 LCursor & cur = pi.base.bv->cursor();
782 for (size_type d = 0; d < cur.depth(); ++d) {
783 CursorSlice const & sl = cur[d];
784 if (sl.text() == &text
786 && sl.pos() >= rit->pos()
787 && sl.pos() <= rit->endpos())
794 bool innerCursorOnRow(PainterInfo & pi, pit_type pit,
795 RowList::const_iterator rit, LyXText const & text)
797 // Is there a cursor inside an inset on this row, and is this inset
798 // the only "character" on this row
799 LCursor & cur = pi.base.bv->cursor();
800 if (rit->pos() + 1 != rit->endpos())
802 for (size_type d = 0; d < cur.depth(); d++) {
803 CursorSlice const & sl = cur[d];
804 if (sl.text() == &text
806 && sl.pos() == rit->pos())
807 return d < cur.depth() - 1;
814 (PainterInfo & pi, LyXText const & text, pit_type pit, int x, int y,
817 // lyxerr << " paintPar: pit: " << pit << " at y: " << y << endl;
818 int const ww = pi.base.bv->workHeight();
820 pi.base.bv->coordCache().parPos()[&text][pit] = Point(x, y);
822 Paragraph const & par = text.paragraphs()[pit];
823 if (par.rows().empty())
826 RowList::const_iterator const rb = par.rows().begin();
827 RowList::const_iterator const re = par.rows().end();
831 for (RowList::const_iterator rit = rb; rit != re; ++rit, ++rowno) {
833 // Allow setting of refreshInside for nested insets in
835 bool tmp = refreshInside;
837 // Row signature; has row changed since last paint?
838 size_type const row_sig = calculateRowSignature(*rit, par, x, y);
839 bool row_has_changed = par.rowSignature()[rowno] != row_sig;
841 bool cursor_on_row = CursorOnRow(pi, pit, rit, text);
842 bool in_inset_alone_on_row = innerCursorOnRow(pi, pit, rit,
845 // If this is the only object on the row, we can make it wide
846 for (pos_type i = rit->pos() ; i != rit->endpos(); ++i) {
847 InsetBase const * const in = par.getInset(i);
849 InsetText const * const t = in->asTextInset();
851 t->Wide() = in_inset_alone_on_row;
855 // If selection is on, the current row signature differs
856 // from cache, or cursor is inside an inset _on this row_,
857 // then paint the row
858 if (repaintAll || row_has_changed || cursor_on_row) {
859 // Add to row signature cache
860 par.rowSignature()[rowno] = row_sig;
862 bool const inside = (y + rit->descent() >= 0
863 && y - rit->ascent() < ww);
864 // it is not needed to draw on screen if we are not inside.
865 pi.pain.setDrawingEnabled(inside);
866 RowPainter rp(pi, text, pit, *rit, x, y);
867 // Clear background of this row
868 // (if paragraph background was not cleared)
870 (!in_inset_alone_on_row || row_has_changed)) {
871 pi.pain.fillRectangle(x, y - rit->ascent(),
872 text.maxwidth_, rit->height(),
873 text.backgroundColor());
874 // If outer row has changed, force nested
875 // insets to repaint completely
877 refreshInside = true;
880 // Instrumentation for testing row cache (see also
882 if (text.isMainText(*pi.base.bv->buffer()))
883 lyxerr[Debug::PAINTING] << "#";
885 lyxerr[Debug::PAINTING] << "[" <<
886 repaintAll << row_has_changed <<
887 cursor_on_row << "]";
898 // Restore, see above
901 // Re-enable screen drawing for future use of the painter.
902 pi.pain.setDrawingEnabled(true);
904 lyxerr[Debug::PAINTING] << "." << endl;
910 void paintText(BufferView & bv,
913 BOOST_ASSERT(bv.buffer());
914 Buffer const & buffer = *bv.buffer();
915 LyXText & text = buffer.text();
916 bool const select = bv.cursor().selection();
917 ViewMetricsInfo const & vi = bv.viewMetricsInfo();
919 PainterInfo pi(const_cast<BufferView *>(&bv), pain);
920 // Should the whole screen, including insets, be refreshed?
921 bool repaintAll = select || !vi.singlepar;
924 // Clear background (if not delegated to rows)
925 pain.fillRectangle(0, vi.y1, bv.workWidth(), vi.y2 - vi.y1,
926 text.backgroundColor());
929 text.drawSelection(pi, 0, 0);
934 for (pit_type pit = vi.p1; pit <= vi.p2; ++pit) {
935 refreshInside = repaintAll;
936 Paragraph const & par = text.getPar(pit);
938 paintPar(pi, text, pit, 0, yy, repaintAll);
942 // Cache one paragraph above and one below
943 // Note MV: this cannot be suppressed even for singlepar.
944 // Try viewing the User Guide Mobius figure
947 text.redoParagraph(bv, vi.p1 - 1);
948 bv.coordCache().parPos()[&text][vi.p1 - 1] =
949 Point(0, vi.y1 - text.getPar(vi.p1 - 1).descent());
952 if (vi.p2 < pit_type(text.paragraphs().size()) - 1) {
953 text.redoParagraph(bv, vi.p2 + 1);
954 bv.coordCache().parPos()[&text][vi.p2 + 1] =
955 Point(0, vi.y2 + text.getPar(vi.p2 + 1).ascent());
958 // and grey out above (should not happen later)
959 // lyxerr << "par ascent: " << text.getPar(vi.p1).ascent() << endl;
960 if (vi.y1 > 0 && !vi.singlepar)
961 pain.fillRectangle(0, 0, bv.workWidth(), vi.y1, LColor::bottomarea);
963 // and possibly grey out below
964 // lyxerr << "par descent: " << text.getPar(vi.p1).ascent() << endl;
965 if (vi.y2 < bv.workHeight() && !vi.singlepar)
966 pain.fillRectangle(0, vi.y2, bv.workWidth(), bv.workHeight() - vi.y2, LColor::bottomarea);
970 void paintTextInset(LyXText const & text, PainterInfo & pi, int x, int y)
972 // lyxerr << " paintTextInset: y: " << y << endl;
974 y -= text.getPar(0).ascent();
975 // This flag can not be set from within same inset:
976 bool repaintAll = refreshInside;
977 for (int pit = 0; pit < int(text.paragraphs().size()); ++pit) {
978 y += text.getPar(pit).ascent();
979 paintPar(pi, text, pit, x, y, repaintAll);
980 y += text.getPar(pit).descent();