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/FontMetrics.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;
48 using lyx::frontend::FontMetrics;
63 /// Flag: do a full redraw of inside text of inset
64 /// Working variable indicating a full screen refresh
68 * A class used for painting an individual row of text.
72 /// initialise and run painter
73 RowPainter(PainterInfo & pi, LyXText const & text,
74 pit_type pit, Row const & row, int x, int y);
76 // paint various parts
79 void paintChangeBar();
85 void paintForeignMark(double orig_x, LyXFont const & font, int desc = 0);
86 void paintHebrewComposeChar(lyx::pos_type & vpos, LyXFont const & font);
87 void paintArabicComposeChar(lyx::pos_type & vpos, LyXFont const & font);
88 void paintChars(lyx::pos_type & vpos, LyXFont font,
89 bool hebrew, bool arabic);
90 int paintAppendixStart(int y);
91 void paintFromPos(lyx::pos_type & vpos);
92 void paintInset(lyx::pos_type const pos, LyXFont const & font);
94 /// return left margin
95 int leftMargin() const;
97 /// return the label font for this row
98 LyXFont const getLabelFont() const;
100 /// bufferview to paint on
106 /// LyXText for the row
107 LyXText const & text_;
108 ParagraphList const & pars_;
115 Paragraph const & par_;
117 /// is row erased? (change tracking)
122 int const yo_; // current baseline
131 RowPainter::RowPainter(PainterInfo & pi,
132 LyXText const & text, pit_type pit, Row const & row, int x, int y)
133 : bv_(*pi.base.bv), pain_(pi.pain), text_(text), pars_(text.paragraphs()),
134 row_(row), pit_(pit), par_(text.paragraphs()[pit]),
136 xo_(x), yo_(y), width_(text_.width())
138 RowMetrics m = text_.computeRowMetrics(pit, row_);
141 //lyxerr << "RowPainter: x: " << x_ << " xo: " << xo_ << " yo: " << yo_ << endl;
144 separator_ = m.separator;
146 label_hfill_ = m.label_hfill;
148 BOOST_ASSERT(pit >= 0);
149 BOOST_ASSERT(pit < int(text.paragraphs().size()));
153 LyXFont const RowPainter::getLabelFont() const
155 return text_.getLabelFont(par_);
159 int RowPainter::leftMargin() const
161 return text_.leftMargin(pit_, row_.pos());
165 void RowPainter::paintInset(pos_type const pos, LyXFont const & font)
167 InsetBase const * inset = par_.getInset(pos);
169 PainterInfo pi(const_cast<BufferView *>(&bv_), pain_);
170 // FIXME: We should always use font, see documentation of
171 // noFontChange() in insetbase.h.
172 pi.base.font = inset->noFontChange() ?
173 bv_.buffer()->params().getFont() :
175 pi.ltr_pos = (text_.bidi.level(pos) % 2 == 0);
176 pi.erased_ = erased_ || isDeletedText(par_, pos);
177 bv_.coordCache().insets().add(inset, int(x_), yo_);
178 InsetText const * const in = inset->asTextInset();
179 // non-wide insets are painted completely. Recursive
180 bool tmp = refreshInside;
181 if (!in || !in->Wide()) {
182 refreshInside = true;
183 lyxerr[Debug::PAINTING] << endl << "Paint inset fully" << endl;
186 inset->drawSelection(pi, int(x_), yo_);
187 inset->draw(pi, int(x_), yo_);
189 x_ += inset->width();
193 void RowPainter::paintHebrewComposeChar(pos_type & vpos, LyXFont const & font)
195 pos_type pos = text_.bidi.vis2log(vpos);
200 char_type c = par_.getChar(pos);
204 int const width = theFontMetrics(font).width(c);
207 for (pos_type i = pos - 1; i >= 0; --i) {
209 if (!Encodings::isComposeChar_hebrew(c)) {
210 if (isPrintableNonspace(c)) {
212 text_.singleWidth(par_, i, c, text_.getFont(par_, i));
214 dx = (c == 'ø' || c == 'ã')
216 : (width2 - width) / 2;
223 docstring dstr(str.begin(), str.end());
224 pain_.text(int(x_) + dx, yo_, dstr, font);
228 void RowPainter::paintArabicComposeChar(pos_type & vpos, LyXFont const & font)
230 pos_type pos = text_.bidi.vis2log(vpos);
234 char_type c = par_.getChar(pos);
235 c = par_.transformChar(c, pos);
239 int const width = theFontMetrics(font).width(c);
242 for (pos_type i = pos - 1; i >= 0; --i) {
244 if (!Encodings::isComposeChar_arabic(c)) {
245 if (isPrintableNonspace(c)) {
247 text_.singleWidth(par_, i, c, text_.getFont(par_, i));
248 dx = (width2 - width) / 2;
254 docstring dstr(str.begin(), str.end());
255 pain_.text(int(x_) + dx, yo_, dstr, font);
259 void RowPainter::paintChars(pos_type & vpos, LyXFont font,
260 bool hebrew, bool arabic)
262 pos_type pos = text_.bidi.vis2log(vpos);
263 pos_type const end = row_.endpos();
264 FontSpan const font_span = par_.fontSpan(pos);
265 Change::Type const prev_change = par_.lookupChange(pos).type;
270 str += par_.getChar(pos);
272 std::vector<char_type> str;
273 str.push_back(par_.getChar(pos));
276 char_type c = str[0];
277 str[0] = par_.transformChar(c, pos);
280 // collect as much similar chars as we can
281 for (++vpos ; vpos < end ; ++vpos) {
282 pos = text_.bidi.vis2log(vpos);
283 if (pos < font_span.first || pos > font_span.last)
286 // FIXME: change tracking (MG)
287 if (Change(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 int width = pain_.text(int(x_), yo_, str, font);
321 int width = pain_.text(int(x_), yo_, &str[0], str.size(), font);
327 void RowPainter::paintForeignMark(double orig_x, LyXFont const & font, int desc)
329 if (!lyxrc.mark_foreign_language)
331 if (font.language() == latex_language)
333 if (font.language() == bv_.buffer()->params().language)
336 int const y = yo_ + 1 + desc;
337 pain_.line(int(orig_x), y, int(x_), y, LColor::language);
341 void RowPainter::paintFromPos(pos_type & vpos)
343 pos_type const pos = text_.bidi.vis2log(vpos);
344 LyXFont orig_font = text_.getFont(par_, pos);
346 double const orig_x = x_;
348 if (par_.isInset(pos)) {
349 paintInset(pos, orig_font);
351 paintForeignMark(orig_x, orig_font,
352 par_.getInset(pos)->descent());
356 // usual characters, no insets
357 char_type const c = par_.getChar(pos);
359 // special case languages
360 std::string const & lang = orig_font.language()->lang();
361 bool const hebrew = lang == "hebrew";
362 bool const arabic = lang == "arabic" &&
363 (lyxrc.font_norm_type == LyXRC::ISO_8859_6_8 ||
364 lyxrc.font_norm_type == LyXRC::ISO_10646_1);
366 // draw as many chars as we can
367 if ((!hebrew && !arabic)
368 || (hebrew && !Encodings::isComposeChar_hebrew(c))
369 || (arabic && !Encodings::isComposeChar_arabic(c))) {
370 paintChars(vpos, orig_font, hebrew, arabic);
372 paintHebrewComposeChar(vpos, orig_font);
374 paintArabicComposeChar(vpos, orig_font);
377 paintForeignMark(orig_x, orig_font);
381 void RowPainter::paintChangeBar()
383 pos_type const start = row_.pos();
384 pos_type const end = row_.endpos();
386 if (start == end || !par_.isChanged(start, end))
389 int const height = text_.isLastRow(pit_, row_)
393 pain_.fillRectangle(5, yo_ - row_.ascent(), 3, height, LColor::changebar);
397 void RowPainter::paintAppendix()
399 if (!par_.params().appendix())
402 int y = yo_ - row_.ascent();
404 if (par_.params().startOfAppendix())
405 y += 2 * defaultRowHeight();
407 pain_.line(1, y, 1, yo_ + row_.height(), LColor::appendix);
408 pain_.line(width_ - 2, y, width_ - 2, yo_ + row_.height(), LColor::appendix);
412 void RowPainter::paintDepthBar()
414 Paragraph::depth_type const depth = par_.getDepth();
419 Paragraph::depth_type prev_depth = 0;
420 if (!text_.isFirstRow(pit_, row_)) {
421 pit_type pit2 = pit_;
424 prev_depth = pars_[pit2].getDepth();
427 Paragraph::depth_type next_depth = 0;
428 if (!text_.isLastRow(pit_, row_)) {
429 pit_type pit2 = pit_;
430 if (row_.endpos() >= pars_[pit2].size())
432 next_depth = pars_[pit2].getDepth();
435 for (Paragraph::depth_type i = 1; i <= depth; ++i) {
436 int const w = nestMargin() / 5;
437 int x = int(xo_) + w * i;
438 // only consider the changebar space if we're drawing outermost text
439 if (text_.isMainText())
440 x += changebarMargin();
442 int const starty = yo_ - row_.ascent();
443 int const h = row_.height() - 1 - (i - next_depth - 1) * 3;
445 pain_.line(x, starty, x, starty + h, LColor::depthbar);
448 pain_.fillRectangle(x, starty, w, 2, LColor::depthbar);
450 pain_.fillRectangle(x, starty + h, w, 2, LColor::depthbar);
455 int RowPainter::paintAppendixStart(int y)
458 pb_font.setColor(LColor::appendix);
461 string const label = lyx::to_utf8(_("Appendix"));
465 docstring dlab(label.begin(), label.end());
466 theFontMetrics(pb_font).rectText(dlab, w, a, d);
468 int const text_start = int(xo_ + (width_ - w) / 2);
469 int const text_end = text_start + w;
471 pain_.rectText(text_start, y + d, dlab, pb_font, LColor::none, LColor::none);
473 pain_.line(int(xo_ + 1), y, text_start, y, LColor::appendix);
474 pain_.line(text_end, y, int(xo_ + width_ - 2), y, LColor::appendix);
476 return 3 * defaultRowHeight();
480 void RowPainter::paintFirst()
482 ParagraphParameters const & parparams = par_.params();
486 // start of appendix?
487 if (parparams.startOfAppendix())
488 y_top += paintAppendixStart(yo_ - row_.ascent() + 2 * defaultRowHeight());
490 Buffer const & buffer = *bv_.buffer();
492 LyXLayout_ptr const & layout = par_.layout();
494 if (buffer.params().paragraph_separation == BufferParams::PARSEP_SKIP) {
496 if (layout->latextype == LATEX_PARAGRAPH
497 && !par_.getDepth()) {
498 y_top += buffer.params().getDefSkip().inPixels(bv_);
500 LyXLayout_ptr const & playout = pars_[pit_ - 1].layout();
501 if (playout->latextype == LATEX_PARAGRAPH
502 && !pars_[pit_ - 1].getDepth()) {
503 // is it right to use defskip here, too? (AS)
504 y_top += buffer.params().getDefSkip().inPixels(bv_);
510 bool const is_rtl = text_.isRTL(par_);
511 bool const is_seq = isFirstInSequence(pit_, text_.paragraphs());
512 //lyxerr << "paintFirst: " << par_.id() << " is_seq: " << is_seq << std::endl;
514 // should we print a label?
515 if (layout->labeltype >= LABEL_STATIC
516 && (layout->labeltype != LABEL_STATIC
517 || layout->latextype != LATEX_ENVIRONMENT
520 LyXFont const font = getLabelFont();
521 FontMetrics const & fm = theFontMetrics(font);
523 string const str = par_.getLabelstring();
526 docstring dstr(str.begin(), str.end());
528 // this is special code for the chapter layout. This is
529 // printed in an extra row and has a pagebreak at
531 if (layout->counter == "chapter") {
532 double spacing_val = 1.0;
533 if (!parparams.spacing().isDefault()) {
534 spacing_val = parparams.spacing().getValue();
536 spacing_val = buffer.params().spacing().getValue();
539 int const labeladdon = int(fm.maxHeight() * layout->spacing.getValue() * spacing_val);
541 int const maxdesc = int(fm.maxDescent() * layout->spacing.getValue() * spacing_val)
542 + int(layout->parsep) * defaultRowHeight();
545 x = width_ - leftMargin() -
549 pain_.text(int(x), yo_ - maxdesc - labeladdon, dstr, font);
551 string lab = layout->labelsep;
552 docstring dlab(lab.begin(), lab.end());
554 x = width_ - leftMargin()
557 x = x_ - fm.width(dlab)
561 pain_.text(int(x), yo_, dstr, font);
565 // the labels at the top of an environment.
566 // More or less for bibliography
568 (layout->labeltype == LABEL_TOP_ENVIRONMENT ||
569 layout->labeltype == LABEL_BIBLIO ||
570 layout->labeltype == LABEL_CENTERED_TOP_ENVIRONMENT)) {
571 LyXFont font = getLabelFont();
572 if (!par_.getLabelstring().empty()) {
573 string const str = par_.getLabelstring();
574 docstring dstr(str.begin(), str.end());
575 double spacing_val = 1.0;
576 if (!parparams.spacing().isDefault())
577 spacing_val = parparams.spacing().getValue();
579 spacing_val = buffer.params().spacing().getValue();
581 FontMetrics const & fm = theFontMetrics(font);
583 int const labeladdon = int(fm.maxHeight()
584 * layout->spacing.getValue() * spacing_val);
587 int(fm.maxDescent() * layout->spacing.getValue() * spacing_val
588 + (layout->labelbottomsep * defaultRowHeight()));
591 if (layout->labeltype == LABEL_CENTERED_TOP_ENVIRONMENT) {
594 x += (width_ - text_.rightMargin(par_) - leftMargin()) / 2;
595 x -= fm.width(dstr) / 2;
597 x = width_ - leftMargin() - fm.width(dstr);
599 pain_.text(int(x), yo_ - maxdesc - labeladdon, dstr, font);
605 void RowPainter::paintLast()
607 bool const is_rtl = text_.isRTL(par_);
608 int const endlabel = getEndLabel(pit_, text_.paragraphs());
613 case END_LABEL_FILLED_BOX: {
614 LyXFont const font = getLabelFont();
615 FontMetrics const & fm = theFontMetrics(font);
616 int const size = int(0.75 * fm.maxAscent());
617 int const y = yo_ - size;
618 int x = is_rtl ? nestMargin() + changebarMargin() : width_ - size;
620 if (width_ - int(row_.width()) <= size)
621 x += (size - width_ + row_.width() + 1) * (is_rtl ? -1 : 1);
623 if (endlabel == END_LABEL_BOX)
624 pain_.rectangle(x, y, size, size, LColor::eolmarker);
626 pain_.fillRectangle(x, y, size, size, LColor::eolmarker);
630 case END_LABEL_STATIC: {
631 LyXFont font = getLabelFont();
632 FontMetrics const & fm = theFontMetrics(font);
633 string const & str = par_.layout()->endlabelstring();
634 docstring dstr(str.begin(), str.end());
635 double const x = is_rtl ?
637 : - text_.rightMargin(par_) - row_.width();
638 pain_.text(int(x), yo_, dstr, font);
642 case END_LABEL_NO_LABEL:
648 void RowPainter::paintText()
650 pos_type const end = row_.endpos();
651 pos_type body_pos = par_.beginOfBody();
653 (body_pos > end || !par_.isLineSeparator(body_pos - 1))) {
657 LyXLayout_ptr const & layout = par_.layout();
659 bool running_strikeout = false;
660 bool is_struckout = false;
661 int last_strikeout_x = 0;
663 // Use font span to speed things up, see below
667 for (pos_type vpos = row_.pos(); vpos < end; ) {
668 if (x_ > bv_.workWidth())
671 pos_type const pos = text_.bidi.vis2log(vpos);
673 if (pos >= par_.size()) {
678 // Use font span to speed things up, see above
679 if (vpos < font_span.first || vpos > font_span.last) {
680 font_span = par_.fontSpan(vpos);
681 font = text_.getFont(par_, vpos);
684 const int width_pos =
685 text_.singleWidth(par_, pos, par_.getChar(pos), font);
687 if (x_ + width_pos < 0) {
693 is_struckout = isDeletedText(par_, pos);
695 if (is_struckout && !running_strikeout) {
696 running_strikeout = true;
697 last_strikeout_x = int(x_);
700 bool const highly_editable_inset = par_.isInset(pos)
701 && isHighlyEditableInset(par_.getInset(pos));
703 // If we reach the end of a struck out range, paint it.
704 // We also don't paint across things like tables
705 if (running_strikeout && (highly_editable_inset || !is_struckout)) {
706 // Calculate 1/3 height of the buffer's default font
707 FontMetrics const & fm
708 = theFontMetrics(bv_.buffer()->params().getFont());
709 int const middle = yo_ - fm.maxAscent() / 3;
710 pain_.line(last_strikeout_x, middle, int(x_), middle,
711 LColor::strikeout, Painter::line_solid, Painter::line_thin);
712 running_strikeout = false;
715 if (body_pos > 0 && pos == body_pos - 1) {
716 string lab = layout->labelsep;
717 docstring dlab(lab.begin(), lab.end());
719 = theFontMetrics(getLabelFont()).width(dlab);
721 x_ += label_hfill_ + lwidth - width_pos;
724 if (par_.isHfill(pos)) {
728 int const y1 = y0 - defaultRowHeight() / 2;
730 pain_.line(int(x_), y1, int(x_), y0, LColor::added_space);
732 if (hfillExpansion(par_, row_, pos)) {
733 int const y2 = (y0 + y1) / 2;
735 if (pos >= body_pos) {
736 pain_.line(int(x_), y2, int(x_ + hfill_), y2,
738 Painter::line_onoffdash);
741 pain_.line(int(x_), y2, int(x_ + label_hfill_), y2,
743 Painter::line_onoffdash);
746 pain_.line(int(x_), y1, int(x_), y0, LColor::added_space);
750 } else if (par_.isSeparator(pos)) {
760 // if we reach the end of a struck out range, paint it
761 if (running_strikeout) {
762 // calculate 1/3 height of the buffer's default font
763 FontMetrics const & fm
764 = theFontMetrics(bv_.buffer()->params().getFont());
765 int const middle = yo_ - fm.maxAscent() / 3;
766 pain_.line(last_strikeout_x, middle, int(x_), middle,
767 LColor::strikeout, Painter::line_solid, Painter::line_thin);
768 running_strikeout = false;
773 lyx::size_type calculateRowSignature(Row const & row, Paragraph const & par,
776 boost::crc_32_type crc;
777 for (lyx::pos_type i = row.pos(); i < row.endpos(); ++i) {
778 const unsigned char b[] = { par.getChar(i) };
779 crc.process_bytes(b, 1);
781 const unsigned char b[] = { x, y, row.width() };
782 crc.process_bytes(b, 3);
783 return crc.checksum();
787 bool CursorOnRow(PainterInfo & pi, pit_type const pit,
788 RowList::const_iterator rit, LyXText const & text)
790 // Is there a cursor on this row (or inside inset on row)
791 LCursor & cur = pi.base.bv->cursor();
792 for (lyx::size_type d = 0; d < cur.depth(); d++) {
793 CursorSlice const & sl = cur[d];
794 if (sl.text() == &text
796 && sl.pos() >= rit->pos()
797 && sl.pos() <= rit->endpos())
804 bool innerCursorOnRow(PainterInfo & pi, pit_type pit,
805 RowList::const_iterator rit, LyXText const & text)
807 // Is there a cursor inside an inset on this row, and is this inset
808 // the only "character" on this row
809 LCursor & cur = pi.base.bv->cursor();
810 if (rit->pos() + 1 != rit->endpos())
812 for (lyx::size_type d = 0; d < cur.depth(); d++) {
813 CursorSlice const & sl = cur[d];
814 if (sl.text() == &text
816 && sl.pos() == rit->pos())
817 return d < cur.depth() - 1;
824 (PainterInfo & pi, LyXText const & text, pit_type pit, int x, int y,
827 // lyxerr << " paintPar: pit: " << pit << " at y: " << y << endl;
828 static NullPainter nop;
829 static PainterInfo nullpi(pi.base.bv, nop);
830 int const ww = pi.base.bv->workHeight();
832 pi.base.bv->coordCache().parPos()[&text][pit] = Point(x, y);
834 Paragraph const & par = text.paragraphs()[pit];
835 if (par.rows().empty())
838 RowList::const_iterator const rb = par.rows().begin();
839 RowList::const_iterator const re = par.rows().end();
842 lyx::size_type rowno(0);
843 for (RowList::const_iterator rit = rb; rit != re; ++rit, ++rowno) {
845 // Allow setting of refreshInside for nested insets in
847 bool tmp = refreshInside;
849 // Row signature; has row changed since last paint?
850 lyx::size_type const row_sig = calculateRowSignature(*rit, par, x, y);
851 bool row_has_changed = par.rowSignature()[rowno] != row_sig;
853 bool cursor_on_row = CursorOnRow(pi, pit, rit, text);
854 bool in_inset_alone_on_row = innerCursorOnRow(pi, pit, rit,
857 // If this is the only object on the row, we can make it wide
858 for (pos_type i = rit->pos() ; i != rit->endpos(); ++i) {
859 InsetBase const * const in = par.getInset(i);
861 InsetText const * const t = in->asTextInset();
863 t->Wide() = in_inset_alone_on_row;
867 // If selection is on, the current row signature differs
868 // from cache, or cursor is inside an inset _on this row_,
869 // then paint the row
870 if (repaintAll || row_has_changed || cursor_on_row) {
871 // Add to row signature cache
872 par.rowSignature()[rowno] = row_sig;
874 bool const inside = (y + rit->descent() >= 0
875 && y - rit->ascent() < ww);
876 RowPainter rp(inside ? pi : nullpi, text, pit, *rit, x, y);
877 // Clear background of this row
878 // (if paragraph background was not cleared)
880 (!in_inset_alone_on_row || row_has_changed)) {
881 pi.pain.fillRectangle(x, y - rit->ascent(),
882 text.maxwidth_, rit->height(),
883 text.backgroundColor());
884 // If outer row has changed, force nested
885 // insets to repaint completely
887 refreshInside = true;
890 // Instrumentation for testing row cache (see also
892 if (text.isMainText())
893 lyxerr[Debug::PAINTING] << "#";
895 lyxerr[Debug::PAINTING] << "[" <<
896 repaintAll << row_has_changed <<
897 cursor_on_row << "]";
908 // Restore, see above
911 lyxerr[Debug::PAINTING] << "." << endl;
917 void paintText(BufferView & bv, ViewMetricsInfo const & vi,
920 LyXText & text = bv.buffer()->text();
921 bool const select = bv.cursor().selection();
923 PainterInfo pi(const_cast<BufferView *>(&bv), pain);
924 // Should the whole screen, including insets, be refreshed?
925 bool repaintAll = select || !vi.singlepar;
928 // Clear background (if not delegated to rows)
929 pain.fillRectangle(0, vi.y1, bv.workWidth(), vi.y2 - vi.y1,
930 text.backgroundColor());
933 text.drawSelection(pi, 0, 0);
938 for (pit_type pit = vi.p1; pit <= vi.p2; ++pit) {
939 refreshInside = repaintAll;
940 Paragraph const & par = text.getPar(pit);
942 paintPar(pi, text, pit, 0, yy, repaintAll);
946 // Cache one paragraph above and one below
947 // Note MV: this cannot be suppressed even for singlepar.
948 // Try viewing the User Guide Mobius figure
951 text.redoParagraph(vi.p1 - 1);
952 bv.coordCache().parPos()[&text][vi.p1 - 1] =
953 Point(0, vi.y1 - text.getPar(vi.p1 - 1).descent());
956 if (vi.p2 < lyx::pit_type(text.paragraphs().size()) - 1) {
957 text.redoParagraph(vi.p2 + 1);
958 bv.coordCache().parPos()[&text][vi.p2 + 1] =
959 Point(0, vi.y2 + text.getPar(vi.p2 + 1).ascent());
962 // and grey out above (should not happen later)
963 // lyxerr << "par ascent: " << text.getPar(vi.p1).ascent() << endl;
964 if (vi.y1 > 0 && !vi.singlepar)
965 pain.fillRectangle(0, 0, bv.workWidth(), vi.y1, LColor::bottomarea);
967 // and possibly grey out below
968 // lyxerr << "par descent: " << text.getPar(vi.p1).ascent() << endl;
969 if (vi.y2 < bv.workHeight() && !vi.singlepar)
970 pain.fillRectangle(0, vi.y2, bv.workWidth(), bv.workHeight() - vi.y2, LColor::bottomarea);
974 void paintTextInset(LyXText const & text, PainterInfo & pi, int x, int y)
976 // lyxerr << " paintTextInset: y: " << y << endl;
978 y -= text.getPar(0).ascent();
979 // This flag can not be set from within same inset:
980 bool repaintAll = refreshInside;
981 for (int pit = 0; pit < int(text.paragraphs().size()); ++pit) {
982 y += text.getPar(pit).ascent();
983 paintPar(pi, text, pit, x, y, repaintAll);
984 y += text.getPar(pit).descent();