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/Application.h"
36 #include "frontends/FontLoader.h"
37 #include "frontends/FontMetrics.h"
38 #include "frontends/nullpainter.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;
50 using lyx::frontend::FontMetrics;
64 /// Flag: do a full redraw of inside text of inset
65 /// Working variable indicating a full screen refresh
69 * A class used for painting an individual row of text.
73 /// initialise and run painter
74 RowPainter(PainterInfo & pi, LyXText const & text,
75 pit_type pit, Row const & row, int x, int y);
77 // paint various parts
80 void paintChangeBar();
86 void paintForeignMark(double orig_x, LyXFont const & font, int desc = 0);
87 void paintHebrewComposeChar(lyx::pos_type & vpos, LyXFont const & font);
88 void paintArabicComposeChar(lyx::pos_type & vpos, LyXFont const & font);
89 void paintChars(lyx::pos_type & vpos, LyXFont font,
90 bool hebrew, bool arabic);
91 int paintAppendixStart(int y);
92 void paintFromPos(lyx::pos_type & vpos);
93 void paintInset(lyx::pos_type const pos, LyXFont const & font);
95 /// return left margin
96 int leftMargin() const;
98 /// return the label font for this row
99 LyXFont const getLabelFont() const;
101 /// bufferview to paint on
102 BufferView const & bv_;
107 /// LyXText for the row
108 LyXText const & text_;
109 ParagraphList const & pars_;
116 Paragraph const & par_;
118 /// is row erased? (change tracking)
123 int const yo_; // current baseline
132 RowPainter::RowPainter(PainterInfo & pi,
133 LyXText const & text, pit_type pit, Row const & row, int x, int y)
134 : bv_(*pi.base.bv), pain_(pi.pain), text_(text), pars_(text.paragraphs()),
135 row_(row), pit_(pit), par_(text.paragraphs()[pit]),
137 xo_(x), yo_(y), width_(text_.width())
139 RowMetrics m = text_.computeRowMetrics(pit, row_);
142 //lyxerr << "RowPainter: x: " << x_ << " xo: " << xo_ << " yo: " << yo_ << endl;
145 separator_ = m.separator;
147 label_hfill_ = m.label_hfill;
149 BOOST_ASSERT(pit >= 0);
150 BOOST_ASSERT(pit < int(text.paragraphs().size()));
154 LyXFont const RowPainter::getLabelFont() const
156 return text_.getLabelFont(par_);
160 int RowPainter::leftMargin() const
162 return text_.leftMargin(pit_, row_.pos());
166 void RowPainter::paintInset(pos_type const pos, LyXFont const & font)
168 InsetBase const * inset = par_.getInset(pos);
170 PainterInfo pi(const_cast<BufferView *>(&bv_), pain_);
171 // FIXME: We should always use font, see documentation of
172 // noFontChange() in insetbase.h.
173 pi.base.font = inset->noFontChange() ?
174 bv_.buffer()->params().getFont() :
176 pi.ltr_pos = (text_.bidi.level(pos) % 2 == 0);
177 pi.erased_ = erased_ || isDeletedText(par_, pos);
178 theCoords.insets().add(inset, int(x_), yo_);
179 InsetText const * const in = inset->asTextInset();
180 // non-wide insets are painted completely. Recursive
181 bool tmp = refreshInside;
182 if (!in || !in->Wide()) {
183 refreshInside = true;
184 lyxerr[Debug::PAINTING] << endl << "Paint inset fully" << endl;
187 inset->drawSelection(pi, int(x_), yo_);
188 inset->draw(pi, int(x_), yo_);
190 x_ += inset->width();
194 void RowPainter::paintHebrewComposeChar(pos_type & vpos, LyXFont const & font)
196 pos_type pos = text_.bidi.vis2log(vpos);
201 char_type c = par_.getChar(pos);
205 int const width = theApp->fontLoader().metrics(font).width(c);
208 for (pos_type i = pos - 1; i >= 0; --i) {
210 if (!Encodings::isComposeChar_hebrew(c)) {
211 if (isPrintableNonspace(c)) {
213 text_.singleWidth(par_, i, c, text_.getFont(par_, i));
215 dx = (c == 'ø' || c == 'ã')
217 : (width2 - width) / 2;
224 docstring dstr(str.begin(), str.end());
225 pain_.text(int(x_) + dx, yo_, dstr, font);
229 void RowPainter::paintArabicComposeChar(pos_type & vpos, LyXFont const & font)
231 pos_type pos = text_.bidi.vis2log(vpos);
235 char_type c = par_.getChar(pos);
236 c = par_.transformChar(c, pos);
240 int const width = theApp->fontLoader().metrics(font).width(c);
243 for (pos_type i = pos - 1; i >= 0; --i) {
245 if (!Encodings::isComposeChar_arabic(c)) {
246 if (isPrintableNonspace(c)) {
248 text_.singleWidth(par_, i, c, text_.getFont(par_, i));
249 dx = (width2 - width) / 2;
255 docstring dstr(str.begin(), str.end());
256 pain_.text(int(x_) + dx, yo_, dstr, font);
260 void RowPainter::paintChars(pos_type & vpos, LyXFont font,
261 bool hebrew, bool arabic)
263 pos_type pos = text_.bidi.vis2log(vpos);
264 pos_type const end = row_.endpos();
265 FontSpan const font_span = par_.fontSpan(pos);
266 Change::Type const prev_change = par_.lookupChange(pos).type;
271 str += par_.getChar(pos);
273 std::vector<char_type> str;
274 str.push_back(par_.getChar(pos));
277 char_type c = str[0];
278 str[0] = par_.transformChar(c, pos);
281 // collect as much similar chars as we can
282 for (++vpos ; vpos < end ; ++vpos) {
283 pos = text_.bidi.vis2log(vpos);
284 if (pos < font_span.first || pos > font_span.last)
287 if (prev_change != par_.lookupChange(pos))
290 char_type c = par_.getChar(pos);
292 if (!isPrintableNonspace(c))
295 if (arabic && Encodings::isComposeChar_arabic(c))
298 if (hebrew && Encodings::isComposeChar_hebrew(c))
302 c = par_.transformChar(c, pos);
311 if (prev_change == Change::DELETED)
312 font.setColor(LColor::strikeout);
313 else if (prev_change == Change::INSERTED)
314 font.setColor(LColor::newtext);
316 // Draw text and set the new x position
317 //lyxerr << "paint row: yo_ " << yo_ << "\n";
319 pain_.text(int(x_), yo_, str, font);
320 x_ += theApp->fontLoader().metrics(font).width(str);
322 pain_.text(int(x_), yo_, &str[0], str.size(), font);
323 x_ += theApp->fontLoader().metrics(font).width(&str[0], str.size());
328 void RowPainter::paintForeignMark(double orig_x, LyXFont const & font, int desc)
330 if (!lyxrc.mark_foreign_language)
332 if (font.language() == latex_language)
334 if (font.language() == bv_.buffer()->params().language)
337 int const y = yo_ + 1 + desc;
338 pain_.line(int(orig_x), y, int(x_), y, LColor::language);
342 void RowPainter::paintFromPos(pos_type & vpos)
344 pos_type const pos = text_.bidi.vis2log(vpos);
345 LyXFont orig_font = text_.getFont(par_, pos);
347 double const orig_x = x_;
349 if (par_.isInset(pos)) {
350 paintInset(pos, orig_font);
352 paintForeignMark(orig_x, orig_font,
353 par_.getInset(pos)->descent());
357 // usual characters, no insets
358 char_type const c = par_.getChar(pos);
360 // special case languages
361 std::string const & lang = orig_font.language()->lang();
362 bool const hebrew = lang == "hebrew";
363 bool const arabic = lang == "arabic" &&
364 (lyxrc.font_norm_type == LyXRC::ISO_8859_6_8 ||
365 lyxrc.font_norm_type == LyXRC::ISO_10646_1);
367 // draw as many chars as we can
368 if ((!hebrew && !arabic)
369 || (hebrew && !Encodings::isComposeChar_hebrew(c))
370 || (arabic && !Encodings::isComposeChar_arabic(c))) {
371 paintChars(vpos, orig_font, hebrew, arabic);
373 paintHebrewComposeChar(vpos, orig_font);
375 paintArabicComposeChar(vpos, orig_font);
378 paintForeignMark(orig_x, orig_font);
382 void RowPainter::paintChangeBar()
384 pos_type const start = row_.pos();
385 pos_type const end = row_.endpos();
387 if (start == end || !par_.isChanged(start, end))
390 int const height = text_.isLastRow(pit_, row_)
394 pain_.fillRectangle(5, yo_ - row_.ascent(), 3, height, LColor::changebar);
398 void RowPainter::paintAppendix()
400 if (!par_.params().appendix())
403 int y = yo_ - row_.ascent();
405 if (par_.params().startOfAppendix())
406 y += 2 * defaultRowHeight();
408 pain_.line(1, y, 1, yo_ + row_.height(), LColor::appendix);
409 pain_.line(width_ - 2, y, width_ - 2, yo_ + row_.height(), LColor::appendix);
413 void RowPainter::paintDepthBar()
415 Paragraph::depth_type const depth = par_.getDepth();
420 Paragraph::depth_type prev_depth = 0;
421 if (!text_.isFirstRow(pit_, row_)) {
422 pit_type pit2 = pit_;
425 prev_depth = pars_[pit2].getDepth();
428 Paragraph::depth_type next_depth = 0;
429 if (!text_.isLastRow(pit_, row_)) {
430 pit_type pit2 = pit_;
431 if (row_.endpos() >= pars_[pit2].size())
433 next_depth = pars_[pit2].getDepth();
436 for (Paragraph::depth_type i = 1; i <= depth; ++i) {
437 int const w = nestMargin() / 5;
438 int x = int(xo_) + w * i;
439 // only consider the changebar space if we're drawing outermost text
440 if (text_.isMainText())
441 x += changebarMargin();
443 int const starty = yo_ - row_.ascent();
444 int const h = row_.height() - 1 - (i - next_depth - 1) * 3;
446 pain_.line(x, starty, x, starty + h, LColor::depthbar);
449 pain_.fillRectangle(x, starty, w, 2, LColor::depthbar);
451 pain_.fillRectangle(x, starty + h, w, 2, LColor::depthbar);
456 int RowPainter::paintAppendixStart(int y)
459 pb_font.setColor(LColor::appendix);
462 string const label = lyx::to_utf8(_("Appendix"));
466 docstring dlab(label.begin(), label.end());
467 theApp->fontLoader().metrics(pb_font).rectText(dlab, w, a, d);
469 int const text_start = int(xo_ + (width_ - w) / 2);
470 int const text_end = text_start + w;
472 pain_.rectText(text_start, y + d, dlab, pb_font, LColor::none, LColor::none);
474 pain_.line(int(xo_ + 1), y, text_start, y, LColor::appendix);
475 pain_.line(text_end, y, int(xo_ + width_ - 2), y, LColor::appendix);
477 return 3 * defaultRowHeight();
481 void RowPainter::paintFirst()
483 ParagraphParameters const & parparams = par_.params();
487 // start of appendix?
488 if (parparams.startOfAppendix())
489 y_top += paintAppendixStart(yo_ - row_.ascent() + 2 * defaultRowHeight());
491 Buffer const & buffer = *bv_.buffer();
493 LyXLayout_ptr const & layout = par_.layout();
495 if (buffer.params().paragraph_separation == BufferParams::PARSEP_SKIP) {
497 if (layout->latextype == LATEX_PARAGRAPH
498 && !par_.getDepth()) {
499 y_top += buffer.params().getDefSkip().inPixels(bv_);
501 LyXLayout_ptr const & playout = pars_[pit_ - 1].layout();
502 if (playout->latextype == LATEX_PARAGRAPH
503 && !pars_[pit_ - 1].getDepth()) {
504 // is it right to use defskip here, too? (AS)
505 y_top += buffer.params().getDefSkip().inPixels(bv_);
511 bool const is_rtl = text_.isRTL(par_);
512 bool const is_seq = isFirstInSequence(pit_, text_.paragraphs());
513 //lyxerr << "paintFirst: " << par_.id() << " is_seq: " << is_seq << std::endl;
515 // should we print a label?
516 if (layout->labeltype >= LABEL_STATIC
517 && (layout->labeltype != LABEL_STATIC
518 || layout->latextype != LATEX_ENVIRONMENT
521 LyXFont const font = getLabelFont();
522 FontMetrics const & fm =
523 theApp->fontLoader().metrics(font);
525 string const str = par_.getLabelstring();
528 docstring dstr(str.begin(), str.end());
530 // this is special code for the chapter layout. This is
531 // printed in an extra row and has a pagebreak at
533 if (layout->counter == "chapter") {
534 double spacing_val = 1.0;
535 if (!parparams.spacing().isDefault()) {
536 spacing_val = parparams.spacing().getValue();
538 spacing_val = buffer.params().spacing().getValue();
541 int const labeladdon = int(fm.maxHeight() * layout->spacing.getValue() * spacing_val);
543 int const maxdesc = int(fm.maxDescent() * layout->spacing.getValue() * spacing_val)
544 + int(layout->parsep) * defaultRowHeight();
547 x = width_ - leftMargin() -
551 pain_.text(int(x), yo_ - maxdesc - labeladdon, dstr, font);
553 string lab = layout->labelsep;
554 docstring dlab(lab.begin(), lab.end());
556 x = width_ - leftMargin()
559 x = x_ - fm.width(dlab)
563 pain_.text(int(x), yo_, dstr, font);
567 // the labels at the top of an environment.
568 // More or less for bibliography
570 (layout->labeltype == LABEL_TOP_ENVIRONMENT ||
571 layout->labeltype == LABEL_BIBLIO ||
572 layout->labeltype == LABEL_CENTERED_TOP_ENVIRONMENT)) {
573 LyXFont font = getLabelFont();
574 if (!par_.getLabelstring().empty()) {
575 string const str = par_.getLabelstring();
576 docstring dstr(str.begin(), str.end());
577 double spacing_val = 1.0;
578 if (!parparams.spacing().isDefault())
579 spacing_val = parparams.spacing().getValue();
581 spacing_val = buffer.params().spacing().getValue();
583 FontMetrics const & fm =
584 theApp->fontLoader().metrics(font);
586 int const labeladdon = int(fm.maxHeight()
587 * layout->spacing.getValue() * spacing_val);
590 int(fm.maxDescent() * layout->spacing.getValue() * spacing_val
591 + (layout->labelbottomsep * defaultRowHeight()));
594 if (layout->labeltype == LABEL_CENTERED_TOP_ENVIRONMENT) {
597 x += (width_ - text_.rightMargin(par_) - leftMargin()) / 2;
598 x -= fm.width(dstr) / 2;
600 x = width_ - leftMargin() - fm.width(dstr);
602 pain_.text(int(x), yo_ - maxdesc - labeladdon, dstr, font);
608 void RowPainter::paintLast()
610 bool const is_rtl = text_.isRTL(par_);
611 int const endlabel = getEndLabel(pit_, text_.paragraphs());
616 case END_LABEL_FILLED_BOX: {
617 LyXFont const font = getLabelFont();
618 FontMetrics const & fm = theApp->fontLoader().metrics(font);
619 int const size = int(0.75 * fm.maxAscent());
620 int const y = yo_ - size;
621 int x = is_rtl ? nestMargin() + changebarMargin() : width_ - size;
623 if (width_ - int(row_.width()) <= size)
624 x += (size - width_ + row_.width() + 1) * (is_rtl ? -1 : 1);
626 if (endlabel == END_LABEL_BOX)
627 pain_.rectangle(x, y, size, size, LColor::eolmarker);
629 pain_.fillRectangle(x, y, size, size, LColor::eolmarker);
633 case END_LABEL_STATIC: {
634 LyXFont font = getLabelFont();
635 FontMetrics const & fm = theApp->fontLoader().metrics(font);
636 string const & str = par_.layout()->endlabelstring();
637 docstring dstr(str.begin(), str.end());
638 double const x = is_rtl ?
640 : - text_.rightMargin(par_) - row_.width();
641 pain_.text(int(x), yo_, dstr, font);
645 case END_LABEL_NO_LABEL:
651 void RowPainter::paintText()
653 pos_type const end = row_.endpos();
654 pos_type body_pos = par_.beginOfBody();
656 (body_pos > end || !par_.isLineSeparator(body_pos - 1))) {
660 LyXLayout_ptr const & layout = par_.layout();
662 bool running_strikeout = false;
663 bool is_struckout = false;
664 int last_strikeout_x = 0;
666 // Use font span to speed things up, see below
670 for (pos_type vpos = row_.pos(); vpos < end; ) {
671 if (x_ > bv_.workWidth())
674 pos_type const pos = text_.bidi.vis2log(vpos);
676 if (pos >= par_.size()) {
681 // Use font span to speed things up, see above
682 if (vpos < font_span.first || vpos > font_span.last) {
683 font_span = par_.fontSpan(vpos);
684 font = text_.getFont(par_, vpos);
687 const int width_pos =
688 text_.singleWidth(par_, pos, par_.getChar(pos), font);
690 if (x_ + width_pos < 0) {
696 is_struckout = isDeletedText(par_, pos);
698 if (is_struckout && !running_strikeout) {
699 running_strikeout = true;
700 last_strikeout_x = int(x_);
703 bool const highly_editable_inset = par_.isInset(pos)
704 && isHighlyEditableInset(par_.getInset(pos));
706 // If we reach the end of a struck out range, paint it.
707 // We also don't paint across things like tables
708 if (running_strikeout && (highly_editable_inset || !is_struckout)) {
709 // Calculate 1/3 height of the buffer's default font
710 FontMetrics const & fm = theApp->fontLoader().metrics(
711 bv_.buffer()->params().getFont());
712 int const middle = yo_ - fm.maxAscent() / 3;
713 pain_.line(last_strikeout_x, middle, int(x_), middle,
714 LColor::strikeout, Painter::line_solid, Painter::line_thin);
715 running_strikeout = false;
718 if (body_pos > 0 && pos == body_pos - 1) {
719 string lab = layout->labelsep;
720 docstring dlab(lab.begin(), lab.end());
722 theApp->fontLoader().metrics(getLabelFont()).width(dlab);
724 x_ += label_hfill_ + lwidth - width_pos;
727 if (par_.isHfill(pos)) {
731 int const y1 = y0 - defaultRowHeight() / 2;
733 pain_.line(int(x_), y1, int(x_), y0, LColor::added_space);
735 if (hfillExpansion(par_, row_, pos)) {
736 int const y2 = (y0 + y1) / 2;
738 if (pos >= body_pos) {
739 pain_.line(int(x_), y2, int(x_ + hfill_), y2,
741 Painter::line_onoffdash);
744 pain_.line(int(x_), y2, int(x_ + label_hfill_), y2,
746 Painter::line_onoffdash);
749 pain_.line(int(x_), y1, int(x_), y0, LColor::added_space);
753 } else if (par_.isSeparator(pos)) {
763 // if we reach the end of a struck out range, paint it
764 if (running_strikeout) {
765 // calculate 1/3 height of the buffer's default font
766 FontMetrics const & fm = theApp->fontLoader().metrics(
767 bv_.buffer()->params().getFont());
768 int const middle = yo_ - fm.maxAscent() / 3;
769 pain_.line(last_strikeout_x, middle, int(x_), middle,
770 LColor::strikeout, Painter::line_solid, Painter::line_thin);
771 running_strikeout = false;
776 lyx::size_type calculateRowSignature(Row const & row, Paragraph const & par,
779 boost::crc_32_type crc;
780 for (lyx::pos_type i = row.pos(); i < row.endpos(); ++i) {
781 const unsigned char b[] = { par.getChar(i) };
782 crc.process_bytes(b, 1);
784 const unsigned char b[] = { x, y, row.width() };
785 crc.process_bytes(b, 3);
786 return crc.checksum();
790 bool CursorOnRow(PainterInfo & pi, pit_type const pit,
791 RowList::const_iterator rit, LyXText const & text)
793 // Is there a cursor on this row (or inside inset on row)
794 LCursor & cur = pi.base.bv->cursor();
795 for (lyx::size_type d = 0; d < cur.depth(); d++) {
796 CursorSlice const & sl = cur[d];
797 if (sl.text() == &text
799 && sl.pos() >= rit->pos()
800 && sl.pos() <= rit->endpos())
807 bool innerCursorOnRow(PainterInfo & pi, pit_type pit,
808 RowList::const_iterator rit, LyXText const & text)
810 // Is there a cursor inside an inset on this row, and is this inset
811 // the only "character" on this row
812 LCursor & cur = pi.base.bv->cursor();
813 if (rit->pos() + 1 != rit->endpos())
815 for (lyx::size_type d = 0; d < cur.depth(); d++) {
816 CursorSlice const & sl = cur[d];
817 if (sl.text() == &text
819 && sl.pos() == rit->pos())
820 return d < cur.depth() - 1;
827 (PainterInfo & pi, LyXText const & text, pit_type pit, int x, int y,
830 // lyxerr << " paintPar: pit: " << pit << " at y: " << y << endl;
831 static NullPainter nop;
832 static PainterInfo nullpi(pi.base.bv, nop);
833 int const ww = pi.base.bv->workHeight();
835 theCoords.parPos()[&text][pit] = Point(x, y);
837 Paragraph const & par = text.paragraphs()[pit];
838 if (par.rows().empty())
841 RowList::const_iterator const rb = par.rows().begin();
842 RowList::const_iterator const re = par.rows().end();
845 lyx::size_type rowno(0);
846 for (RowList::const_iterator rit = rb; rit != re; ++rit, ++rowno) {
848 // Allow setting of refreshInside for nested insets in
850 bool tmp = refreshInside;
852 // Row signature; has row changed since last paint?
853 lyx::size_type const row_sig = calculateRowSignature(*rit, par, x, y);
854 bool row_has_changed = par.rowSignature()[rowno] != row_sig;
856 bool cursor_on_row = CursorOnRow(pi, pit, rit, text);
857 bool in_inset_alone_on_row = innerCursorOnRow(pi, pit, rit,
860 // If this is the only object on the row, we can make it wide
861 for (pos_type i = rit->pos() ; i != rit->endpos(); ++i) {
862 InsetBase const * const in = par.getInset(i);
864 InsetText const * const t = in->asTextInset();
866 t->Wide() = in_inset_alone_on_row;
870 // If selection is on, the current row signature differs
871 // from cache, or cursor is inside an inset _on this row_,
872 // then paint the row
873 if (repaintAll || row_has_changed || cursor_on_row) {
874 // Add to row signature cache
875 par.rowSignature()[rowno] = row_sig;
877 bool const inside = (y + rit->descent() >= 0
878 && y - rit->ascent() < ww);
879 RowPainter rp(inside ? pi : nullpi, text, pit, *rit, x, y);
880 // Clear background of this row
881 // (if paragraph background was not cleared)
883 (!in_inset_alone_on_row || row_has_changed)) {
884 pi.pain.fillRectangle(x, y - rit->ascent(),
885 text.maxwidth_, rit->height(),
886 text.backgroundColor());
887 // If outer row has changed, force nested
888 // insets to repaint completely
890 refreshInside = true;
893 // Instrumentation for testing row cache (see also
895 if (text.isMainText())
896 lyxerr[Debug::PAINTING] << "#";
898 lyxerr[Debug::PAINTING] << "[" <<
899 repaintAll << row_has_changed <<
900 cursor_on_row << "]";
911 // Restore, see above
914 lyxerr[Debug::PAINTING] << "." << endl;
920 void paintText(BufferView const & bv, ViewMetricsInfo const & vi,
923 LyXText & text = bv.buffer()->text();
924 bool const select = bv.cursor().selection();
926 PainterInfo pi(const_cast<BufferView *>(&bv), pain);
927 // Should the whole screen, including insets, be refreshed?
928 bool repaintAll = select || !vi.singlepar;
931 // Clear background (if not delegated to rows)
932 pain.fillRectangle(0, vi.y1, bv.workWidth(), vi.y2 - vi.y1,
933 text.backgroundColor());
936 text.drawSelection(pi, 0, 0);
941 for (pit_type pit = vi.p1; pit <= vi.p2; ++pit) {
942 refreshInside = repaintAll;
943 Paragraph const & par = text.getPar(pit);
945 paintPar(pi, text, pit, 0, yy, repaintAll);
949 // Cache one paragraph above and one below
950 // Note MV: this cannot be suppressed even for singlepar.
951 // Try viewing the User Guide Mobius figure
954 text.redoParagraph(vi.p1 - 1);
955 theCoords.parPos()[&text][vi.p1 - 1] =
956 Point(0, vi.y1 - text.getPar(vi.p1 - 1).descent());
959 if (vi.p2 < lyx::pit_type(text.paragraphs().size()) - 1) {
960 text.redoParagraph(vi.p2 + 1);
961 theCoords.parPos()[&text][vi.p2 + 1] =
962 Point(0, vi.y2 + text.getPar(vi.p2 + 1).ascent());
965 // and grey out above (should not happen later)
966 // lyxerr << "par ascent: " << text.getPar(vi.p1).ascent() << endl;
967 if (vi.y1 > 0 && !vi.singlepar)
968 pain.fillRectangle(0, 0, bv.workWidth(), vi.y1, LColor::bottomarea);
970 // and possibly grey out below
971 // lyxerr << "par descent: " << text.getPar(vi.p1).ascent() << endl;
972 if (vi.y2 < bv.workHeight() && !vi.singlepar)
973 pain.fillRectangle(0, vi.y2, bv.workWidth(), bv.workHeight() - vi.y2, LColor::bottomarea);
977 void paintTextInset(LyXText const & text, PainterInfo & pi, int x, int y)
979 // lyxerr << " paintTextInset: y: " << y << endl;
981 y -= text.getPar(0).ascent();
982 // This flag can not be set from within same inset:
983 bool repaintAll = refreshInside;
984 for (int pit = 0; pit < int(text.paragraphs().size()); ++pit) {
985 y += text.getPar(pit).ascent();
986 paintPar(pi, text, pit, x, y, repaintAll);
987 y += text.getPar(pit).descent();