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)) {
206 text_.singleWidth(*bv_.buffer(), par_, i, c,
207 text_.getFont(*bv_.buffer(), par_, i));
209 // This does not work anymore, and non-ascii
210 // characters in source files are forbidden
213 dx = (c == 'ø' || c == 'ã')
215 : (width2 - width) / 2;
223 pain_.text(int(x_) + dx, yo_, str, 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 = theFontMetrics(font).width(c);
241 for (pos_type i = pos - 1; i >= 0; --i) {
243 if (!Encodings::isComposeChar_arabic(c)) {
244 if (isPrintableNonspace(c)) {
246 text_.singleWidth(*bv_.buffer(), par_, i, c,
247 text_.getFont(*bv_.buffer(), par_, i));
248 dx = (width2 - width) / 2;
254 pain_.text(int(x_) + dx, yo_, str, font);
257 void RowPainter::paintChars(pos_type & vpos, LyXFont const & font,
258 bool hebrew, bool arabic)
260 // This method takes up 70% of time when typing
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;
267 std::vector<char_type> str;
269 str.push_back(par_.getChar(pos));
272 char_type c = str[0];
273 str[0] = par_.transformChar(c, pos);
276 // collect as much similar chars as we can
277 for (++vpos ; vpos < end ; ++vpos) {
278 pos = text_.bidi.vis2log(vpos);
279 if (pos < font_span.first || pos > font_span.last)
282 if (prev_change != par_.lookupChange(pos).type)
285 char_type c = par_.getChar(pos);
287 if (!isPrintableNonspace(c))
290 if (arabic && Encodings::isComposeChar_arabic(c))
293 if (hebrew && Encodings::isComposeChar_hebrew(c))
297 c = par_.transformChar(c, pos);
302 if (prev_change != Change::UNCHANGED) {
304 if (prev_change == Change::DELETED) {
305 copy.setColor(LColor::strikeout);
306 } else if (prev_change == Change::INSERTED) {
307 copy.setColor(LColor::newtext);
309 x_ += pain_.text(int(x_), yo_, &str[0], str.size(), copy);
311 x_ += pain_.text(int(x_), yo_, &str[0], str.size(), font);
316 void RowPainter::paintForeignMark(double orig_x, LyXFont const & font, int desc)
318 if (!lyxrc.mark_foreign_language)
320 if (font.language() == latex_language)
322 if (font.language() == bv_.buffer()->params().language)
325 int const y = yo_ + 1 + desc;
326 pain_.line(int(orig_x), y, int(x_), y, LColor::language);
330 void RowPainter::paintFromPos(pos_type & vpos)
332 pos_type const pos = text_.bidi.vis2log(vpos);
333 LyXFont orig_font = text_.getFont(*bv_.buffer(), par_, pos);
335 double const orig_x = x_;
337 if (par_.isInset(pos)) {
338 paintInset(pos, orig_font);
340 paintForeignMark(orig_x, orig_font,
341 par_.getInset(pos)->descent());
345 // usual characters, no insets
346 char_type const c = par_.getChar(pos);
348 // special case languages
349 std::string const & lang = orig_font.language()->lang();
350 bool const hebrew = lang == "hebrew";
351 bool const arabic = lang == "arabic" &&
352 (lyxrc.font_norm_type == LyXRC::ISO_8859_6_8 ||
353 lyxrc.font_norm_type == LyXRC::ISO_10646_1);
355 // draw as many chars as we can
356 if ((!hebrew && !arabic)
357 || (hebrew && !Encodings::isComposeChar_hebrew(c))
358 || (arabic && !Encodings::isComposeChar_arabic(c))) {
359 paintChars(vpos, orig_font, hebrew, arabic);
361 paintHebrewComposeChar(vpos, orig_font);
363 paintArabicComposeChar(vpos, orig_font);
366 paintForeignMark(orig_x, orig_font);
370 void RowPainter::paintChangeBar()
372 pos_type const start = row_.pos();
373 pos_type const end = row_.endpos();
375 if (start == end || !par_.isChanged(start, end))
378 int const height = text_.isLastRow(pit_, row_)
382 pain_.fillRectangle(5, yo_ - row_.ascent(), 3, height, LColor::changebar);
386 void RowPainter::paintAppendix()
388 if (!par_.params().appendix())
391 int y = yo_ - row_.ascent();
393 if (par_.params().startOfAppendix())
394 y += 2 * defaultRowHeight();
396 pain_.line(1, y, 1, yo_ + row_.height(), LColor::appendix);
397 pain_.line(width_ - 2, y, width_ - 2, yo_ + row_.height(), LColor::appendix);
401 void RowPainter::paintDepthBar()
403 depth_type const depth = par_.getDepth();
408 depth_type prev_depth = 0;
409 if (!text_.isFirstRow(pit_, row_)) {
410 pit_type pit2 = pit_;
413 prev_depth = pars_[pit2].getDepth();
416 depth_type next_depth = 0;
417 if (!text_.isLastRow(pit_, row_)) {
418 pit_type pit2 = pit_;
419 if (row_.endpos() >= pars_[pit2].size())
421 next_depth = pars_[pit2].getDepth();
424 for (depth_type i = 1; i <= depth; ++i) {
425 int const w = nestMargin() / 5;
426 int x = int(xo_) + w * i;
427 // only consider the changebar space if we're drawing outermost text
428 if (text_.isMainText(*bv_.buffer()))
429 x += changebarMargin();
431 int const starty = yo_ - row_.ascent();
432 int const h = row_.height() - 1 - (i - next_depth - 1) * 3;
434 pain_.line(x, starty, x, starty + h, LColor::depthbar);
437 pain_.fillRectangle(x, starty, w, 2, LColor::depthbar);
439 pain_.fillRectangle(x, starty + h, w, 2, LColor::depthbar);
444 int RowPainter::paintAppendixStart(int y)
447 pb_font.setColor(LColor::appendix);
454 docstring const label = _("Appendix");
455 theFontMetrics(pb_font).rectText(label, w, a, d);
457 int const text_start = int(xo_ + (width_ - w) / 2);
458 int const text_end = text_start + w;
460 pain_.rectText(text_start, y + d, label, pb_font, LColor::none, LColor::none);
462 pain_.line(int(xo_ + 1), y, text_start, y, LColor::appendix);
463 pain_.line(text_end, y, int(xo_ + width_ - 2), y, LColor::appendix);
465 return 3 * defaultRowHeight();
469 void RowPainter::paintFirst()
471 ParagraphParameters const & parparams = par_.params();
475 // start of appendix?
476 if (parparams.startOfAppendix())
477 y_top += paintAppendixStart(yo_ - row_.ascent() + 2 * defaultRowHeight());
479 Buffer const & buffer = *bv_.buffer();
481 LyXLayout_ptr const & layout = par_.layout();
483 if (buffer.params().paragraph_separation == BufferParams::PARSEP_SKIP) {
485 if (layout->latextype == LATEX_PARAGRAPH
486 && !par_.getDepth()) {
487 y_top += buffer.params().getDefSkip().inPixels(bv_);
489 LyXLayout_ptr const & playout = pars_[pit_ - 1].layout();
490 if (playout->latextype == LATEX_PARAGRAPH
491 && !pars_[pit_ - 1].getDepth()) {
492 // is it right to use defskip here, too? (AS)
493 y_top += buffer.params().getDefSkip().inPixels(bv_);
499 bool const is_rtl = text_.isRTL(buffer, par_);
500 bool const is_seq = isFirstInSequence(pit_, text_.paragraphs());
501 //lyxerr << "paintFirst: " << par_.id() << " is_seq: " << is_seq << std::endl;
503 // should we print a label?
504 if (layout->labeltype >= LABEL_STATIC
505 && (layout->labeltype != LABEL_STATIC
506 || layout->latextype != LATEX_ENVIRONMENT
509 LyXFont const font = getLabelFont();
510 FontMetrics const & fm = theFontMetrics(font);
512 docstring const str = par_.getLabelstring();
516 // this is special code for the chapter layout. This is
517 // printed in an extra row and has a pagebreak at
519 if (layout->counter == "chapter") {
520 double spacing_val = 1.0;
521 if (!parparams.spacing().isDefault()) {
522 spacing_val = parparams.spacing().getValue();
524 spacing_val = buffer.params().spacing().getValue();
527 int const labeladdon = int(fm.maxHeight() * layout->spacing.getValue() * spacing_val);
529 int const maxdesc = int(fm.maxDescent() * layout->spacing.getValue() * spacing_val)
530 + int(layout->parsep) * defaultRowHeight();
533 x = width_ - leftMargin() -
537 pain_.text(int(x), yo_ - maxdesc - labeladdon, str, font);
540 docstring lab = from_utf8(layout->labelsep);
542 x = width_ - leftMargin()
545 x = x_ - fm.width(lab)
549 pain_.text(int(x), yo_, str, font);
553 // the labels at the top of an environment.
554 // More or less for bibliography
556 (layout->labeltype == LABEL_TOP_ENVIRONMENT ||
557 layout->labeltype == LABEL_BIBLIO ||
558 layout->labeltype == LABEL_CENTERED_TOP_ENVIRONMENT)) {
559 LyXFont font = getLabelFont();
560 if (!par_.getLabelstring().empty()) {
561 docstring const str = par_.getLabelstring();
562 double spacing_val = 1.0;
563 if (!parparams.spacing().isDefault())
564 spacing_val = parparams.spacing().getValue();
566 spacing_val = buffer.params().spacing().getValue();
568 FontMetrics const & fm = theFontMetrics(font);
570 int const labeladdon = int(fm.maxHeight()
571 * layout->spacing.getValue() * spacing_val);
574 int(fm.maxDescent() * layout->spacing.getValue() * spacing_val
575 + (layout->labelbottomsep * defaultRowHeight()));
578 if (layout->labeltype == LABEL_CENTERED_TOP_ENVIRONMENT) {
581 x += (width_ - text_.rightMargin(buffer, par_) - leftMargin()) / 2;
582 x -= fm.width(str) / 2;
584 x = width_ - leftMargin() - fm.width(str);
586 pain_.text(int(x), yo_ - maxdesc - labeladdon, str, font);
592 void RowPainter::paintLast()
594 bool const is_rtl = text_.isRTL(*bv_.buffer(), par_);
595 int const endlabel = getEndLabel(pit_, text_.paragraphs());
600 case END_LABEL_FILLED_BOX: {
601 LyXFont const font = getLabelFont();
602 FontMetrics const & fm = theFontMetrics(font);
603 int const size = int(0.75 * fm.maxAscent());
604 int const y = yo_ - size;
605 int x = is_rtl ? nestMargin() + changebarMargin() : width_ - size;
607 if (width_ - int(row_.width()) <= size)
608 x += (size - width_ + row_.width() + 1) * (is_rtl ? -1 : 1);
610 if (endlabel == END_LABEL_BOX)
611 pain_.rectangle(x, y, size, size, LColor::eolmarker);
613 pain_.fillRectangle(x, y, size, size, LColor::eolmarker);
617 case END_LABEL_STATIC: {
618 LyXFont font = getLabelFont();
619 FontMetrics const & fm = theFontMetrics(font);
620 docstring const & str = par_.layout()->endlabelstring();
621 double const x = is_rtl ?
623 : - text_.rightMargin(*bv_.buffer(), par_) - row_.width();
624 pain_.text(int(x), yo_, str, font);
628 case END_LABEL_NO_LABEL:
634 void RowPainter::paintText()
636 pos_type const end = row_.endpos();
637 pos_type body_pos = par_.beginOfBody();
639 (body_pos > end || !par_.isLineSeparator(body_pos - 1))) {
643 LyXLayout_ptr const & layout = par_.layout();
645 bool running_strikeout = false;
646 bool is_struckout = false;
647 int last_strikeout_x = 0;
649 // Use font span to speed things up, see below
652 Buffer const & buffer = *bv_.buffer();
654 for (pos_type vpos = row_.pos(); vpos < end; ) {
655 if (x_ > bv_.workWidth())
658 pos_type const pos = text_.bidi.vis2log(vpos);
660 if (pos >= par_.size()) {
665 // Use font span to speed things up, see above
666 if (vpos < font_span.first || vpos > font_span.last) {
667 font_span = par_.fontSpan(vpos);
668 font = text_.getFont(buffer, par_, vpos);
671 const int width_pos = text_.singleWidth(buffer, par_, pos,
672 par_.getChar(pos), font);
674 if (x_ + width_pos < 0) {
680 is_struckout = par_.isDeleted(pos);
682 if (is_struckout && !running_strikeout) {
683 running_strikeout = true;
684 last_strikeout_x = int(x_);
687 bool const highly_editable_inset = par_.isInset(pos)
688 && isHighlyEditableInset(par_.getInset(pos));
690 // If we reach the end of a struck out range, paint it.
691 // We also don't paint across things like tables
692 if (running_strikeout && (highly_editable_inset || !is_struckout)) {
693 // Calculate 1/3 height of the buffer's default font
694 FontMetrics const & fm
695 = theFontMetrics(bv_.buffer()->params().getFont());
696 int const middle = yo_ - fm.maxAscent() / 3;
697 pain_.line(last_strikeout_x, middle, int(x_), middle,
698 LColor::strikeout, Painter::line_solid, Painter::line_thin);
699 running_strikeout = false;
702 if (body_pos > 0 && pos == body_pos - 1) {
704 int const lwidth = theFontMetrics(getLabelFont())
705 .width(from_utf8(layout->labelsep));
707 x_ += label_hfill_ + lwidth - width_pos;
710 if (par_.isHfill(pos)) {
714 int const y1 = y0 - defaultRowHeight() / 2;
716 pain_.line(int(x_), y1, int(x_), y0, LColor::added_space);
718 if (par_.hfillExpansion(row_, pos)) {
719 int const y2 = (y0 + y1) / 2;
721 if (pos >= body_pos) {
722 pain_.line(int(x_), y2, int(x_ + hfill_), y2,
724 Painter::line_onoffdash);
727 pain_.line(int(x_), y2, int(x_ + label_hfill_), y2,
729 Painter::line_onoffdash);
732 pain_.line(int(x_), y1, int(x_), y0, LColor::added_space);
736 } else if (par_.isSeparator(pos)) {
746 // if we reach the end of a struck out range, paint it
747 if (running_strikeout) {
748 // calculate 1/3 height of the buffer's default font
749 FontMetrics const & fm
750 = theFontMetrics(bv_.buffer()->params().getFont());
751 int const middle = yo_ - fm.maxAscent() / 3;
752 pain_.line(last_strikeout_x, middle, int(x_), middle,
753 LColor::strikeout, Painter::line_solid, Painter::line_thin);
754 running_strikeout = false;
759 size_type calculateRowSignature(Row const & row, Paragraph const & par,
762 boost::crc_32_type crc;
763 for (pos_type i = row.pos(); i < row.endpos(); ++i) {
764 char_type const b[] = { par.getChar(i) };
765 crc.process_bytes(b, 1);
767 char_type const b[] = { x, y, row.width() };
768 crc.process_bytes(b, 3);
769 return crc.checksum();
773 bool CursorOnRow(PainterInfo & pi, pit_type const pit,
774 RowList::const_iterator rit, LyXText const & text)
776 // Is there a cursor on this row (or inside inset on row)
777 LCursor & cur = pi.base.bv->cursor();
778 for (size_type d = 0; d < cur.depth(); ++d) {
779 CursorSlice const & sl = cur[d];
780 if (sl.text() == &text
782 && sl.pos() >= rit->pos()
783 && sl.pos() <= rit->endpos())
790 bool innerCursorOnRow(PainterInfo & pi, pit_type pit,
791 RowList::const_iterator rit, LyXText const & text)
793 // Is there a cursor inside an inset on this row, and is this inset
794 // the only "character" on this row
795 LCursor & cur = pi.base.bv->cursor();
796 if (rit->pos() + 1 != rit->endpos())
798 for (size_type d = 0; d < cur.depth(); d++) {
799 CursorSlice const & sl = cur[d];
800 if (sl.text() == &text
802 && sl.pos() == rit->pos())
803 return d < cur.depth() - 1;
810 (PainterInfo & pi, LyXText const & text, pit_type pit, int x, int y,
813 // lyxerr << " paintPar: pit: " << pit << " at y: " << y << endl;
814 int const ww = pi.base.bv->workHeight();
816 pi.base.bv->coordCache().parPos()[&text][pit] = Point(x, y);
818 Paragraph const & par = text.paragraphs()[pit];
819 if (par.rows().empty())
822 RowList::const_iterator const rb = par.rows().begin();
823 RowList::const_iterator const re = par.rows().end();
827 for (RowList::const_iterator rit = rb; rit != re; ++rit, ++rowno) {
829 // Allow setting of refreshInside for nested insets in
831 bool tmp = refreshInside;
833 // Row signature; has row changed since last paint?
834 size_type const row_sig = calculateRowSignature(*rit, par, x, y);
835 bool row_has_changed = par.rowSignature()[rowno] != row_sig;
837 bool cursor_on_row = CursorOnRow(pi, pit, rit, text);
838 bool in_inset_alone_on_row = innerCursorOnRow(pi, pit, rit,
841 // If this is the only object on the row, we can make it wide
842 for (pos_type i = rit->pos() ; i != rit->endpos(); ++i) {
843 InsetBase const * const in = par.getInset(i);
845 InsetText const * const t = in->asTextInset();
847 t->Wide() = in_inset_alone_on_row;
851 // If selection is on, the current row signature differs
852 // from cache, or cursor is inside an inset _on this row_,
853 // then paint the row
854 if (repaintAll || row_has_changed || cursor_on_row) {
855 // Add to row signature cache
856 par.rowSignature()[rowno] = row_sig;
858 bool const inside = (y + rit->descent() >= 0
859 && y - rit->ascent() < ww);
860 // it is not needed to draw on screen if we are not inside.
861 pi.pain.setDrawingEnabled(inside);
862 RowPainter rp(pi, text, pit, *rit, x, y);
863 // Clear background of this row
864 // (if paragraph background was not cleared)
866 (!in_inset_alone_on_row || row_has_changed)) {
867 pi.pain.fillRectangle(x, y - rit->ascent(),
868 text.maxwidth_, rit->height(),
869 text.backgroundColor());
870 // If outer row has changed, force nested
871 // insets to repaint completely
873 refreshInside = true;
876 // Instrumentation for testing row cache (see also
878 if (text.isMainText(*pi.base.bv->buffer()))
879 lyxerr[Debug::PAINTING] << "#";
881 lyxerr[Debug::PAINTING] << "[" <<
882 repaintAll << row_has_changed <<
883 cursor_on_row << "]";
894 // Restore, see above
897 // Re-enable screen drawing for future use of the painter.
898 pi.pain.setDrawingEnabled(true);
900 lyxerr[Debug::PAINTING] << "." << endl;
906 void paintText(BufferView & bv,
909 BOOST_ASSERT(bv.buffer());
910 Buffer const & buffer = *bv.buffer();
911 LyXText & text = buffer.text();
912 bool const select = bv.cursor().selection();
913 ViewMetricsInfo const & vi = bv.viewMetricsInfo();
915 PainterInfo pi(const_cast<BufferView *>(&bv), pain);
916 // Should the whole screen, including insets, be refreshed?
917 bool repaintAll = select || !vi.singlepar;
920 // Clear background (if not delegated to rows)
921 pain.fillRectangle(0, vi.y1, bv.workWidth(), vi.y2 - vi.y1,
922 text.backgroundColor());
925 text.drawSelection(pi, 0, 0);
930 for (pit_type pit = vi.p1; pit <= vi.p2; ++pit) {
931 refreshInside = repaintAll;
932 Paragraph const & par = text.getPar(pit);
934 paintPar(pi, text, pit, 0, yy, repaintAll);
938 // Cache one paragraph above and one below
939 // Note MV: this cannot be suppressed even for singlepar.
940 // Try viewing the User Guide Mobius figure
943 text.redoParagraph(bv, vi.p1 - 1);
944 bv.coordCache().parPos()[&text][vi.p1 - 1] =
945 Point(0, vi.y1 - text.getPar(vi.p1 - 1).descent());
948 if (vi.p2 < pit_type(text.paragraphs().size()) - 1) {
949 text.redoParagraph(bv, vi.p2 + 1);
950 bv.coordCache().parPos()[&text][vi.p2 + 1] =
951 Point(0, vi.y2 + text.getPar(vi.p2 + 1).ascent());
954 // and grey out above (should not happen later)
955 // lyxerr << "par ascent: " << text.getPar(vi.p1).ascent() << endl;
956 if (vi.y1 > 0 && !vi.singlepar)
957 pain.fillRectangle(0, 0, bv.workWidth(), vi.y1, LColor::bottomarea);
959 // and possibly grey out below
960 // lyxerr << "par descent: " << text.getPar(vi.p1).ascent() << endl;
961 if (vi.y2 < bv.workHeight() && !vi.singlepar)
962 pain.fillRectangle(0, vi.y2, bv.workWidth(), bv.workHeight() - vi.y2, LColor::bottomarea);
966 void paintTextInset(LyXText const & text, PainterInfo & pi, int x, int y)
968 // lyxerr << " paintTextInset: y: " << y << endl;
970 y -= text.getPar(0).ascent();
971 // This flag can not be set from within same inset:
972 bool repaintAll = refreshInside;
973 for (int pit = 0; pit < int(text.paragraphs().size()); ++pit) {
974 y += text.getPar(pit).ascent();
975 paintPar(pi, text, pit, x, y, repaintAll);
976 y += text.getPar(pit).descent();