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/Painter.h"
39 #include "insets/insettext.h"
41 #include "support/textutils.h"
43 #include <boost/crc.hpp>
46 using lyx::frontend::Painter;
47 using lyx::frontend::NullPainter;
60 /// Flag: do a full redraw of inside text of inset
61 /// Working variable indicating a full screen refresh
65 * A class used for painting an individual row of text.
69 /// initialise and run painter
70 RowPainter(PainterInfo & pi, LyXText const & text,
71 pit_type pit, Row const & row, int x, int y);
73 // paint various parts
76 void paintChangeBar();
82 void paintForeignMark(double orig_x, LyXFont const & font, int desc = 0);
83 void paintHebrewComposeChar(lyx::pos_type & vpos, LyXFont const & font);
84 void paintArabicComposeChar(lyx::pos_type & vpos, LyXFont const & font);
85 void paintChars(lyx::pos_type & vpos, LyXFont font,
86 bool hebrew, bool arabic);
87 int paintAppendixStart(int y);
88 void paintFromPos(lyx::pos_type & vpos);
89 void paintInset(lyx::pos_type const pos, LyXFont const & font);
91 /// return left margin
92 int leftMargin() const;
94 /// return the label font for this row
95 LyXFont const getLabelFont() const;
97 /// bufferview to paint on
98 BufferView const & bv_;
103 /// LyXText for the row
104 LyXText const & text_;
105 ParagraphList const & pars_;
112 Paragraph const & par_;
114 /// is row erased? (change tracking)
119 int const yo_; // current baseline
128 RowPainter::RowPainter(PainterInfo & pi,
129 LyXText const & text, pit_type pit, Row const & row, int x, int y)
130 : bv_(*pi.base.bv), pain_(pi.pain), text_(text), pars_(text.paragraphs()),
131 row_(row), pit_(pit), par_(text.paragraphs()[pit]),
133 xo_(x), yo_(y), width_(text_.width())
135 RowMetrics m = text_.computeRowMetrics(pit, row_);
138 //lyxerr << "RowPainter: x: " << x_ << " xo: " << xo_ << " yo: " << yo_ << endl;
141 separator_ = m.separator;
143 label_hfill_ = m.label_hfill;
145 BOOST_ASSERT(pit >= 0);
146 BOOST_ASSERT(pit < int(text.paragraphs().size()));
150 LyXFont const RowPainter::getLabelFont() const
152 return text_.getLabelFont(par_);
156 int RowPainter::leftMargin() const
158 return text_.leftMargin(pit_, row_.pos());
162 void RowPainter::paintInset(pos_type const pos, LyXFont const & font)
164 InsetBase const * inset = par_.getInset(pos);
166 PainterInfo pi(const_cast<BufferView *>(&bv_), pain_);
167 // FIXME: We should always use font, see documentation of
168 // noFontChange() in insetbase.h.
169 pi.base.font = inset->noFontChange() ?
170 bv_.buffer()->params().getFont() :
172 pi.ltr_pos = (text_.bidi.level(pos) % 2 == 0);
173 pi.erased_ = erased_ || isDeletedText(par_, pos);
174 theCoords.insets().add(inset, int(x_), yo_);
175 InsetText const * const in = inset->asTextInset();
176 // non-wide insets are painted completely. Recursive
177 bool tmp = refreshInside;
178 if (!in || !in->Wide()) {
179 refreshInside = true;
180 lyxerr[Debug::PAINTING] << endl << "Paint inset fully" << endl;
183 inset->drawSelection(pi, int(x_), yo_);
184 inset->draw(pi, int(x_), yo_);
186 x_ += inset->width();
190 void RowPainter::paintHebrewComposeChar(pos_type & vpos, LyXFont const & font)
192 pos_type pos = text_.bidi.vis2log(vpos);
197 char_type c = par_.getChar(pos);
201 int const width = font_metrics::width(c, font);
204 for (pos_type i = pos - 1; i >= 0; --i) {
206 if (!Encodings::isComposeChar_hebrew(c)) {
207 if (isPrintableNonspace(c)) {
209 text_.singleWidth(par_, i, c, text_.getFont(par_, i));
211 dx = (c == 'ø' || c == 'ã')
213 : (width2 - width) / 2;
220 docstring dstr(str.begin(), str.end());
221 pain_.text(int(x_) + dx, yo_, dstr, font);
225 void RowPainter::paintArabicComposeChar(pos_type & vpos, LyXFont const & font)
227 pos_type pos = text_.bidi.vis2log(vpos);
231 char_type c = par_.getChar(pos);
232 c = par_.transformChar(c, pos);
236 int const width = font_metrics::width(c, font);
239 for (pos_type i = pos - 1; i >= 0; --i) {
241 if (!Encodings::isComposeChar_arabic(c)) {
242 if (isPrintableNonspace(c)) {
244 text_.singleWidth(par_, i, c, text_.getFont(par_, i));
245 dx = (width2 - width) / 2;
251 docstring dstr(str.begin(), str.end());
252 pain_.text(int(x_) + dx, yo_, dstr, font);
256 void RowPainter::paintChars(pos_type & vpos, LyXFont font,
257 bool hebrew, bool arabic)
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;
267 str += par_.getChar(pos);
269 std::vector<char_type> str;
270 str.push_back(par_.getChar(pos));
273 char_type c = str[0];
274 str[0] = par_.transformChar(c, pos);
277 // collect as much similar chars as we can
278 for (++vpos ; vpos < end ; ++vpos) {
279 pos = text_.bidi.vis2log(vpos);
280 if (pos < font_span.first || pos > font_span.last)
283 if (prev_change != par_.lookupChange(pos))
286 char_type c = par_.getChar(pos);
288 if (!isPrintableNonspace(c))
291 if (arabic && Encodings::isComposeChar_arabic(c))
294 if (hebrew && Encodings::isComposeChar_hebrew(c))
298 c = par_.transformChar(c, pos);
307 if (prev_change == Change::DELETED)
308 font.setColor(LColor::strikeout);
309 else if (prev_change == Change::INSERTED)
310 font.setColor(LColor::newtext);
312 // Draw text and set the new x position
313 //lyxerr << "paint row: yo_ " << yo_ << "\n";
315 pain_.text(int(x_), yo_, str, font);
316 x_ += font_metrics::width(str, font);
318 pain_.text(int(x_), yo_, &str[0], str.size(), font);
319 x_ += font_metrics::width(&str[0], str.size(), font);
324 void RowPainter::paintForeignMark(double orig_x, LyXFont const & font, int desc)
326 if (!lyxrc.mark_foreign_language)
328 if (font.language() == latex_language)
330 if (font.language() == bv_.buffer()->params().language)
333 int const y = yo_ + 1 + desc;
334 pain_.line(int(orig_x), y, int(x_), y, LColor::language);
338 void RowPainter::paintFromPos(pos_type & vpos)
340 pos_type const pos = text_.bidi.vis2log(vpos);
341 LyXFont orig_font = text_.getFont(par_, pos);
343 double const orig_x = x_;
345 if (par_.isInset(pos)) {
346 paintInset(pos, orig_font);
348 paintForeignMark(orig_x, orig_font,
349 par_.getInset(pos)->descent());
353 // usual characters, no insets
354 char_type const c = par_.getChar(pos);
356 // special case languages
357 std::string const & lang = orig_font.language()->lang();
358 bool const hebrew = lang == "hebrew";
359 bool const arabic = lang == "arabic" &&
360 (lyxrc.font_norm_type == LyXRC::ISO_8859_6_8 ||
361 lyxrc.font_norm_type == LyXRC::ISO_10646_1);
363 // draw as many chars as we can
364 if ((!hebrew && !arabic)
365 || (hebrew && !Encodings::isComposeChar_hebrew(c))
366 || (arabic && !Encodings::isComposeChar_arabic(c))) {
367 paintChars(vpos, orig_font, hebrew, arabic);
369 paintHebrewComposeChar(vpos, orig_font);
371 paintArabicComposeChar(vpos, orig_font);
374 paintForeignMark(orig_x, orig_font);
378 void RowPainter::paintChangeBar()
380 pos_type const start = row_.pos();
381 pos_type const end = row_.endpos();
383 if (start == end || !par_.isChanged(start, end))
386 int const height = text_.isLastRow(pit_, row_)
390 pain_.fillRectangle(5, yo_ - row_.ascent(), 3, height, LColor::changebar);
394 void RowPainter::paintAppendix()
396 if (!par_.params().appendix())
399 int y = yo_ - row_.ascent();
401 if (par_.params().startOfAppendix())
402 y += 2 * defaultRowHeight();
404 pain_.line(1, y, 1, yo_ + row_.height(), LColor::appendix);
405 pain_.line(width_ - 2, y, width_ - 2, yo_ + row_.height(), LColor::appendix);
409 void RowPainter::paintDepthBar()
411 Paragraph::depth_type const depth = par_.getDepth();
416 Paragraph::depth_type prev_depth = 0;
417 if (!text_.isFirstRow(pit_, row_)) {
418 pit_type pit2 = pit_;
421 prev_depth = pars_[pit2].getDepth();
424 Paragraph::depth_type next_depth = 0;
425 if (!text_.isLastRow(pit_, row_)) {
426 pit_type pit2 = pit_;
427 if (row_.endpos() >= pars_[pit2].size())
429 next_depth = pars_[pit2].getDepth();
432 for (Paragraph::depth_type i = 1; i <= depth; ++i) {
433 int const w = nestMargin() / 5;
434 int x = int(xo_) + w * i;
435 // only consider the changebar space if we're drawing outermost text
436 if (text_.isMainText())
437 x += changebarMargin();
439 int const starty = yo_ - row_.ascent();
440 int const h = row_.height() - 1 - (i - next_depth - 1) * 3;
442 pain_.line(x, starty, x, starty + h, LColor::depthbar);
445 pain_.fillRectangle(x, starty, w, 2, LColor::depthbar);
447 pain_.fillRectangle(x, starty + h, w, 2, LColor::depthbar);
452 int RowPainter::paintAppendixStart(int y)
455 pb_font.setColor(LColor::appendix);
458 string const label = lyx::to_utf8(_("Appendix"));
462 docstring dlab(label.begin(), label.end());
463 font_metrics::rectText(dlab, pb_font, w, a, d);
465 int const text_start = int(xo_ + (width_ - w) / 2);
466 int const text_end = text_start + w;
468 pain_.rectText(text_start, y + d, dlab, pb_font, LColor::none, LColor::none);
470 pain_.line(int(xo_ + 1), y, text_start, y, LColor::appendix);
471 pain_.line(text_end, y, int(xo_ + width_ - 2), y, LColor::appendix);
473 return 3 * defaultRowHeight();
477 void RowPainter::paintFirst()
479 ParagraphParameters const & parparams = par_.params();
483 // start of appendix?
484 if (parparams.startOfAppendix())
485 y_top += paintAppendixStart(yo_ - row_.ascent() + 2 * defaultRowHeight());
487 Buffer const & buffer = *bv_.buffer();
489 LyXLayout_ptr const & layout = par_.layout();
491 if (buffer.params().paragraph_separation == BufferParams::PARSEP_SKIP) {
493 if (layout->latextype == LATEX_PARAGRAPH
494 && !par_.getDepth()) {
495 y_top += buffer.params().getDefSkip().inPixels(bv_);
497 LyXLayout_ptr const & playout = pars_[pit_ - 1].layout();
498 if (playout->latextype == LATEX_PARAGRAPH
499 && !pars_[pit_ - 1].getDepth()) {
500 // is it right to use defskip here, too? (AS)
501 y_top += buffer.params().getDefSkip().inPixels(bv_);
507 bool const is_rtl = text_.isRTL(par_);
508 bool const is_seq = isFirstInSequence(pit_, text_.paragraphs());
509 //lyxerr << "paintFirst: " << par_.id() << " is_seq: " << is_seq << std::endl;
511 // should we print a label?
512 if (layout->labeltype >= LABEL_STATIC
513 && (layout->labeltype != LABEL_STATIC
514 || layout->latextype != LATEX_ENVIRONMENT
517 LyXFont const font = getLabelFont();
518 string const str = par_.getLabelstring();
521 docstring dstr(str.begin(), str.end());
523 // this is special code for the chapter layout. This is
524 // printed in an extra row and has a pagebreak at
526 if (layout->counter == "chapter") {
527 double spacing_val = 1.0;
528 if (!parparams.spacing().isDefault()) {
529 spacing_val = parparams.spacing().getValue();
531 spacing_val = buffer.params().spacing().getValue();
534 int const labeladdon = int(font_metrics::maxHeight(font) * layout->spacing.getValue() * spacing_val);
536 int const maxdesc = int(font_metrics::maxDescent(font) * layout->spacing.getValue() * spacing_val)
537 + int(layout->parsep) * defaultRowHeight();
540 x = width_ - leftMargin() -
541 font_metrics::width(dstr, font);
544 pain_.text(int(x), yo_ - maxdesc - labeladdon, dstr, font);
546 string lab = layout->labelsep;
547 docstring dlab(lab.begin(), lab.end());
549 x = width_ - leftMargin()
550 + font_metrics::width(dlab, font);
552 x = x_ - font_metrics::width(dlab, font)
553 - font_metrics::width(dstr, font);
556 pain_.text(int(x), yo_, dstr, font);
560 // the labels at the top of an environment.
561 // More or less for bibliography
563 (layout->labeltype == LABEL_TOP_ENVIRONMENT ||
564 layout->labeltype == LABEL_BIBLIO ||
565 layout->labeltype == LABEL_CENTERED_TOP_ENVIRONMENT)) {
566 LyXFont font = getLabelFont();
567 if (!par_.getLabelstring().empty()) {
568 string const str = par_.getLabelstring();
569 docstring dstr(str.begin(), str.end());
570 double spacing_val = 1.0;
571 if (!parparams.spacing().isDefault())
572 spacing_val = parparams.spacing().getValue();
574 spacing_val = buffer.params().spacing().getValue();
576 int const labeladdon = int(font_metrics::maxHeight(font) * layout->spacing.getValue() * spacing_val);
579 int(font_metrics::maxDescent(font) * layout->spacing.getValue() * spacing_val
580 + (layout->labelbottomsep * defaultRowHeight()));
583 if (layout->labeltype == LABEL_CENTERED_TOP_ENVIRONMENT) {
586 x += (width_ - text_.rightMargin(par_) - leftMargin()) / 2;
587 x -= font_metrics::width(dstr, font) / 2;
589 x = width_ - leftMargin() -
590 font_metrics::width(dstr, font);
592 pain_.text(int(x), yo_ - maxdesc - labeladdon, dstr, font);
598 void RowPainter::paintLast()
600 bool const is_rtl = text_.isRTL(par_);
601 int const endlabel = getEndLabel(pit_, text_.paragraphs());
606 case END_LABEL_FILLED_BOX: {
607 LyXFont const font = getLabelFont();
608 int const size = int(0.75 * font_metrics::maxAscent(font));
609 int const y = yo_ - size;
610 int x = is_rtl ? nestMargin() + changebarMargin() : width_ - size;
612 if (width_ - int(row_.width()) <= size)
613 x += (size - width_ + row_.width() + 1) * (is_rtl ? -1 : 1);
615 if (endlabel == END_LABEL_BOX)
616 pain_.rectangle(x, y, size, size, LColor::eolmarker);
618 pain_.fillRectangle(x, y, size, size, LColor::eolmarker);
622 case END_LABEL_STATIC: {
623 LyXFont font = getLabelFont();
624 string const & str = par_.layout()->endlabelstring();
625 docstring dstr(str.begin(), str.end());
626 double const x = is_rtl ?
627 x_ - font_metrics::width(dstr, font)
628 : - text_.rightMargin(par_) - row_.width();
629 pain_.text(int(x), yo_, dstr, font);
633 case END_LABEL_NO_LABEL:
639 void RowPainter::paintText()
641 pos_type const end = row_.endpos();
642 pos_type body_pos = par_.beginOfBody();
644 (body_pos > end || !par_.isLineSeparator(body_pos - 1))) {
648 LyXLayout_ptr const & layout = par_.layout();
650 bool running_strikeout = false;
651 bool is_struckout = false;
652 int last_strikeout_x = 0;
654 // Use font span to speed things up, see below
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(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 = isDeletedText(par_, 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
700 font_metrics::maxAscent(bv_.buffer()->params().getFont()) / 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) {
707 string lab = layout->labelsep;
708 docstring dlab(lab.begin(), lab.end());
709 int const lwidth = font_metrics::width(dlab,
712 x_ += label_hfill_ + lwidth - width_pos;
715 if (par_.isHfill(pos)) {
719 int const y1 = y0 - defaultRowHeight() / 2;
721 pain_.line(int(x_), y1, int(x_), y0, LColor::added_space);
723 if (hfillExpansion(par_, row_, pos)) {
724 int const y2 = (y0 + y1) / 2;
726 if (pos >= body_pos) {
727 pain_.line(int(x_), y2, int(x_ + hfill_), y2,
729 Painter::line_onoffdash);
732 pain_.line(int(x_), y2, int(x_ + label_hfill_), y2,
734 Painter::line_onoffdash);
737 pain_.line(int(x_), y1, int(x_), y0, LColor::added_space);
741 } else if (par_.isSeparator(pos)) {
751 // if we reach the end of a struck out range, paint it
752 if (running_strikeout) {
753 // calculate 1/3 height of the buffer's default font
756 font_metrics::maxAscent(bv_.buffer()->params().getFont()) / 3;
757 pain_.line(last_strikeout_x, middle, int(x_), middle,
758 LColor::strikeout, Painter::line_solid, Painter::line_thin);
759 running_strikeout = false;
764 lyx::size_type calculateRowSignature(Row const & row, Paragraph const & par,
767 boost::crc_32_type crc;
768 for (lyx::pos_type i = row.pos(); i < row.endpos(); ++i) {
769 const unsigned char b[] = { par.getChar(i) };
770 crc.process_bytes(b, 1);
772 const unsigned char b[] = { x, y, row.width() };
773 crc.process_bytes(b, 3);
774 return crc.checksum();
778 bool CursorOnRow(PainterInfo & pi, pit_type const pit,
779 RowList::const_iterator rit, LyXText const & text)
781 // Is there a cursor on this row (or inside inset on row)
782 LCursor & cur = pi.base.bv->cursor();
783 for (lyx::size_type d = 0; d < cur.depth(); d++) {
784 CursorSlice const & sl = cur[d];
785 if (sl.text() == &text
787 && sl.pos() >= rit->pos()
788 && sl.pos() <= rit->endpos())
795 bool innerCursorOnRow(PainterInfo & pi, pit_type pit,
796 RowList::const_iterator rit, LyXText const & text)
798 // Is there a cursor inside an inset on this row, and is this inset
799 // the only "character" on this row
800 LCursor & cur = pi.base.bv->cursor();
801 if (rit->pos() + 1 != rit->endpos())
803 for (lyx::size_type d = 0; d < cur.depth(); d++) {
804 CursorSlice const & sl = cur[d];
805 if (sl.text() == &text
807 && sl.pos() == rit->pos())
808 return d < cur.depth() - 1;
815 (PainterInfo & pi, LyXText const & text, pit_type pit, int x, int y,
818 // lyxerr << " paintPar: pit: " << pit << " at y: " << y << endl;
819 static NullPainter nop;
820 static PainterInfo nullpi(pi.base.bv, nop);
821 int const ww = pi.base.bv->workHeight();
823 theCoords.parPos()[&text][pit] = Point(x, y);
825 Paragraph const & par = text.paragraphs()[pit];
826 if (par.rows().empty())
829 RowList::const_iterator const rb = par.rows().begin();
830 RowList::const_iterator const re = par.rows().end();
833 lyx::size_type rowno(0);
834 for (RowList::const_iterator rit = rb; rit != re; ++rit, ++rowno) {
836 // Allow setting of refreshInside for nested insets in
838 bool tmp = refreshInside;
840 // Row signature; has row changed since last paint?
841 lyx::size_type const row_sig = calculateRowSignature(*rit, par, x, y);
842 bool row_has_changed = par.rowSignature()[rowno] != row_sig;
844 bool cursor_on_row = CursorOnRow(pi, pit, rit, text);
845 bool in_inset_alone_on_row = innerCursorOnRow(pi, pit, rit,
848 // If this is the only object on the row, we can make it wide
849 for (pos_type i = rit->pos() ; i != rit->endpos(); ++i) {
850 InsetBase const * const in = par.getInset(i);
852 InsetText const * const t = in->asTextInset();
854 t->Wide() = in_inset_alone_on_row;
858 // If selection is on, the current row signature differs
859 // from cache, or cursor is inside an inset _on this row_,
860 // then paint the row
861 if (repaintAll || row_has_changed || cursor_on_row) {
862 // Add to row signature cache
863 par.rowSignature()[rowno] = row_sig;
865 bool const inside = (y + rit->descent() >= 0
866 && y - rit->ascent() < ww);
867 RowPainter rp(inside ? pi : nullpi, text, pit, *rit, x, y);
868 // Clear background of this row
869 // (if paragraph background was not cleared)
871 (!in_inset_alone_on_row || row_has_changed)) {
872 pi.pain.fillRectangle(x, y - rit->ascent(),
873 text.maxwidth_, rit->height(),
874 text.backgroundColor());
875 // If outer row has changed, force nested
876 // insets to repaint completely
878 refreshInside = true;
881 // Instrumentation for testing row cache (see also
883 if (text.isMainText())
884 lyxerr[Debug::PAINTING] << "#";
886 lyxerr[Debug::PAINTING] << "[" <<
887 repaintAll << row_has_changed <<
888 cursor_on_row << "]";
899 // Restore, see above
902 lyxerr[Debug::PAINTING] << "." << endl;
908 void paintText(BufferView const & bv, ViewMetricsInfo const & vi,
911 LyXText & text = bv.buffer()->text();
912 bool const select = bv.cursor().selection();
914 PainterInfo pi(const_cast<BufferView *>(&bv), pain);
915 // Should the whole screen, including insets, be refreshed?
916 bool repaintAll = select || !vi.singlepar;
919 // Clear background (if not delegated to rows)
920 pain.fillRectangle(0, vi.y1, bv.workWidth(), vi.y2 - vi.y1,
921 text.backgroundColor());
924 text.drawSelection(pi, 0, 0);
929 for (pit_type pit = vi.p1; pit <= vi.p2; ++pit) {
930 refreshInside = repaintAll;
931 Paragraph const & par = text.getPar(pit);
933 paintPar(pi, text, pit, 0, yy, repaintAll);
937 // Cache one paragraph above and one below
938 // Note MV: this cannot be suppressed even for singlepar.
939 // Try viewing the User Guide Mobius figure
942 text.redoParagraph(vi.p1 - 1);
943 theCoords.parPos()[&text][vi.p1 - 1] =
944 Point(0, vi.y1 - text.getPar(vi.p1 - 1).descent());
947 if (vi.p2 < lyx::pit_type(text.paragraphs().size()) - 1) {
948 text.redoParagraph(vi.p2 + 1);
949 theCoords.parPos()[&text][vi.p2 + 1] =
950 Point(0, vi.y2 + text.getPar(vi.p2 + 1).ascent());
953 // and grey out above (should not happen later)
954 // lyxerr << "par ascent: " << text.getPar(vi.p1).ascent() << endl;
955 if (vi.y1 > 0 && !vi.singlepar)
956 pain.fillRectangle(0, 0, bv.workWidth(), vi.y1, LColor::bottomarea);
958 // and possibly grey out below
959 // lyxerr << "par descent: " << text.getPar(vi.p1).ascent() << endl;
960 if (vi.y2 < bv.workHeight() && !vi.singlepar)
961 pain.fillRectangle(0, vi.y2, bv.workWidth(), bv.workHeight() - vi.y2, LColor::bottomarea);
965 void paintTextInset(LyXText const & text, PainterInfo & pi, int x, int y)
967 // lyxerr << " paintTextInset: y: " << y << endl;
969 y -= text.getPar(0).ascent();
970 // This flag can not be set from within same inset:
971 bool repaintAll = refreshInside;
972 for (int pit = 0; pit < int(text.paragraphs().size()); ++pit) {
973 y += text.getPar(pit).ascent();
974 paintPar(pi, text, pit, x, y, repaintAll);
975 y += text.getPar(pit).descent();