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 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 theApp->fontLoader().metrics(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 =
522 theApp->fontLoader().metrics(font);
524 string const str = par_.getLabelstring();
527 docstring dstr(str.begin(), str.end());
529 // this is special code for the chapter layout. This is
530 // printed in an extra row and has a pagebreak at
532 if (layout->counter == "chapter") {
533 double spacing_val = 1.0;
534 if (!parparams.spacing().isDefault()) {
535 spacing_val = parparams.spacing().getValue();
537 spacing_val = buffer.params().spacing().getValue();
540 int const labeladdon = int(fm.maxHeight() * layout->spacing.getValue() * spacing_val);
542 int const maxdesc = int(fm.maxDescent() * layout->spacing.getValue() * spacing_val)
543 + int(layout->parsep) * defaultRowHeight();
546 x = width_ - leftMargin() -
550 pain_.text(int(x), yo_ - maxdesc - labeladdon, dstr, font);
552 string lab = layout->labelsep;
553 docstring dlab(lab.begin(), lab.end());
555 x = width_ - leftMargin()
558 x = x_ - fm.width(dlab)
562 pain_.text(int(x), yo_, dstr, font);
566 // the labels at the top of an environment.
567 // More or less for bibliography
569 (layout->labeltype == LABEL_TOP_ENVIRONMENT ||
570 layout->labeltype == LABEL_BIBLIO ||
571 layout->labeltype == LABEL_CENTERED_TOP_ENVIRONMENT)) {
572 LyXFont font = getLabelFont();
573 if (!par_.getLabelstring().empty()) {
574 string const str = par_.getLabelstring();
575 docstring dstr(str.begin(), str.end());
576 double spacing_val = 1.0;
577 if (!parparams.spacing().isDefault())
578 spacing_val = parparams.spacing().getValue();
580 spacing_val = buffer.params().spacing().getValue();
582 FontMetrics const & fm =
583 theApp->fontLoader().metrics(font);
585 int const labeladdon = int(fm.maxHeight()
586 * layout->spacing.getValue() * spacing_val);
589 int(fm.maxDescent() * layout->spacing.getValue() * spacing_val
590 + (layout->labelbottomsep * defaultRowHeight()));
593 if (layout->labeltype == LABEL_CENTERED_TOP_ENVIRONMENT) {
596 x += (width_ - text_.rightMargin(par_) - leftMargin()) / 2;
597 x -= fm.width(dstr) / 2;
599 x = width_ - leftMargin() - fm.width(dstr);
601 pain_.text(int(x), yo_ - maxdesc - labeladdon, dstr, font);
607 void RowPainter::paintLast()
609 bool const is_rtl = text_.isRTL(par_);
610 int const endlabel = getEndLabel(pit_, text_.paragraphs());
615 case END_LABEL_FILLED_BOX: {
616 LyXFont const font = getLabelFont();
617 FontMetrics const & fm = theApp->fontLoader().metrics(font);
618 int const size = int(0.75 * fm.maxAscent());
619 int const y = yo_ - size;
620 int x = is_rtl ? nestMargin() + changebarMargin() : width_ - size;
622 if (width_ - int(row_.width()) <= size)
623 x += (size - width_ + row_.width() + 1) * (is_rtl ? -1 : 1);
625 if (endlabel == END_LABEL_BOX)
626 pain_.rectangle(x, y, size, size, LColor::eolmarker);
628 pain_.fillRectangle(x, y, size, size, LColor::eolmarker);
632 case END_LABEL_STATIC: {
633 LyXFont font = getLabelFont();
634 FontMetrics const & fm = theApp->fontLoader().metrics(font);
635 string const & str = par_.layout()->endlabelstring();
636 docstring dstr(str.begin(), str.end());
637 double const x = is_rtl ?
639 : - text_.rightMargin(par_) - row_.width();
640 pain_.text(int(x), yo_, dstr, font);
644 case END_LABEL_NO_LABEL:
650 void RowPainter::paintText()
652 pos_type const end = row_.endpos();
653 pos_type body_pos = par_.beginOfBody();
655 (body_pos > end || !par_.isLineSeparator(body_pos - 1))) {
659 LyXLayout_ptr const & layout = par_.layout();
661 bool running_strikeout = false;
662 bool is_struckout = false;
663 int last_strikeout_x = 0;
665 // Use font span to speed things up, see below
669 for (pos_type vpos = row_.pos(); vpos < end; ) {
670 if (x_ > bv_.workWidth())
673 pos_type const pos = text_.bidi.vis2log(vpos);
675 if (pos >= par_.size()) {
680 // Use font span to speed things up, see above
681 if (vpos < font_span.first || vpos > font_span.last) {
682 font_span = par_.fontSpan(vpos);
683 font = text_.getFont(par_, vpos);
686 const int width_pos =
687 text_.singleWidth(par_, pos, par_.getChar(pos), font);
689 if (x_ + width_pos < 0) {
695 is_struckout = isDeletedText(par_, pos);
697 if (is_struckout && !running_strikeout) {
698 running_strikeout = true;
699 last_strikeout_x = int(x_);
702 bool const highly_editable_inset = par_.isInset(pos)
703 && isHighlyEditableInset(par_.getInset(pos));
705 // If we reach the end of a struck out range, paint it.
706 // We also don't paint across things like tables
707 if (running_strikeout && (highly_editable_inset || !is_struckout)) {
708 // Calculate 1/3 height of the buffer's default font
709 FontMetrics const & fm = theApp->fontLoader().metrics(
710 bv_.buffer()->params().getFont());
711 int const middle = yo_ - fm.maxAscent() / 3;
712 pain_.line(last_strikeout_x, middle, int(x_), middle,
713 LColor::strikeout, Painter::line_solid, Painter::line_thin);
714 running_strikeout = false;
717 if (body_pos > 0 && pos == body_pos - 1) {
718 string lab = layout->labelsep;
719 docstring dlab(lab.begin(), lab.end());
721 theApp->fontLoader().metrics(getLabelFont()).width(dlab);
723 x_ += label_hfill_ + lwidth - width_pos;
726 if (par_.isHfill(pos)) {
730 int const y1 = y0 - defaultRowHeight() / 2;
732 pain_.line(int(x_), y1, int(x_), y0, LColor::added_space);
734 if (hfillExpansion(par_, row_, pos)) {
735 int const y2 = (y0 + y1) / 2;
737 if (pos >= body_pos) {
738 pain_.line(int(x_), y2, int(x_ + hfill_), y2,
740 Painter::line_onoffdash);
743 pain_.line(int(x_), y2, int(x_ + label_hfill_), y2,
745 Painter::line_onoffdash);
748 pain_.line(int(x_), y1, int(x_), y0, LColor::added_space);
752 } else if (par_.isSeparator(pos)) {
762 // if we reach the end of a struck out range, paint it
763 if (running_strikeout) {
764 // calculate 1/3 height of the buffer's default font
765 FontMetrics const & fm = theApp->fontLoader().metrics(
766 bv_.buffer()->params().getFont());
767 int const middle = yo_ - fm.maxAscent() / 3;
768 pain_.line(last_strikeout_x, middle, int(x_), middle,
769 LColor::strikeout, Painter::line_solid, Painter::line_thin);
770 running_strikeout = false;
775 lyx::size_type calculateRowSignature(Row const & row, Paragraph const & par,
778 boost::crc_32_type crc;
779 for (lyx::pos_type i = row.pos(); i < row.endpos(); ++i) {
780 const unsigned char b[] = { par.getChar(i) };
781 crc.process_bytes(b, 1);
783 const unsigned char b[] = { x, y, row.width() };
784 crc.process_bytes(b, 3);
785 return crc.checksum();
789 bool CursorOnRow(PainterInfo & pi, pit_type const pit,
790 RowList::const_iterator rit, LyXText const & text)
792 // Is there a cursor on this row (or inside inset on row)
793 LCursor & cur = pi.base.bv->cursor();
794 for (lyx::size_type d = 0; d < cur.depth(); d++) {
795 CursorSlice const & sl = cur[d];
796 if (sl.text() == &text
798 && sl.pos() >= rit->pos()
799 && sl.pos() <= rit->endpos())
806 bool innerCursorOnRow(PainterInfo & pi, pit_type pit,
807 RowList::const_iterator rit, LyXText const & text)
809 // Is there a cursor inside an inset on this row, and is this inset
810 // the only "character" on this row
811 LCursor & cur = pi.base.bv->cursor();
812 if (rit->pos() + 1 != rit->endpos())
814 for (lyx::size_type d = 0; d < cur.depth(); d++) {
815 CursorSlice const & sl = cur[d];
816 if (sl.text() == &text
818 && sl.pos() == rit->pos())
819 return d < cur.depth() - 1;
826 (PainterInfo & pi, LyXText const & text, pit_type pit, int x, int y,
829 // lyxerr << " paintPar: pit: " << pit << " at y: " << y << endl;
830 static NullPainter nop;
831 static PainterInfo nullpi(pi.base.bv, nop);
832 int const ww = pi.base.bv->workHeight();
834 theCoords.parPos()[&text][pit] = Point(x, y);
836 Paragraph const & par = text.paragraphs()[pit];
837 if (par.rows().empty())
840 RowList::const_iterator const rb = par.rows().begin();
841 RowList::const_iterator const re = par.rows().end();
844 lyx::size_type rowno(0);
845 for (RowList::const_iterator rit = rb; rit != re; ++rit, ++rowno) {
847 // Allow setting of refreshInside for nested insets in
849 bool tmp = refreshInside;
851 // Row signature; has row changed since last paint?
852 lyx::size_type const row_sig = calculateRowSignature(*rit, par, x, y);
853 bool row_has_changed = par.rowSignature()[rowno] != row_sig;
855 bool cursor_on_row = CursorOnRow(pi, pit, rit, text);
856 bool in_inset_alone_on_row = innerCursorOnRow(pi, pit, rit,
859 // If this is the only object on the row, we can make it wide
860 for (pos_type i = rit->pos() ; i != rit->endpos(); ++i) {
861 InsetBase const * const in = par.getInset(i);
863 InsetText const * const t = in->asTextInset();
865 t->Wide() = in_inset_alone_on_row;
869 // If selection is on, the current row signature differs
870 // from cache, or cursor is inside an inset _on this row_,
871 // then paint the row
872 if (repaintAll || row_has_changed || cursor_on_row) {
873 // Add to row signature cache
874 par.rowSignature()[rowno] = row_sig;
876 bool const inside = (y + rit->descent() >= 0
877 && y - rit->ascent() < ww);
878 RowPainter rp(inside ? pi : nullpi, text, pit, *rit, x, y);
879 // Clear background of this row
880 // (if paragraph background was not cleared)
882 (!in_inset_alone_on_row || row_has_changed)) {
883 pi.pain.fillRectangle(x, y - rit->ascent(),
884 text.maxwidth_, rit->height(),
885 text.backgroundColor());
886 // If outer row has changed, force nested
887 // insets to repaint completely
889 refreshInside = true;
892 // Instrumentation for testing row cache (see also
894 if (text.isMainText())
895 lyxerr[Debug::PAINTING] << "#";
897 lyxerr[Debug::PAINTING] << "[" <<
898 repaintAll << row_has_changed <<
899 cursor_on_row << "]";
910 // Restore, see above
913 lyxerr[Debug::PAINTING] << "." << endl;
919 void paintText(BufferView const & bv, ViewMetricsInfo const & vi,
922 LyXText & text = bv.buffer()->text();
923 bool const select = bv.cursor().selection();
925 PainterInfo pi(const_cast<BufferView *>(&bv), pain);
926 // Should the whole screen, including insets, be refreshed?
927 bool repaintAll = select || !vi.singlepar;
930 // Clear background (if not delegated to rows)
931 pain.fillRectangle(0, vi.y1, bv.workWidth(), vi.y2 - vi.y1,
932 text.backgroundColor());
935 text.drawSelection(pi, 0, 0);
940 for (pit_type pit = vi.p1; pit <= vi.p2; ++pit) {
941 refreshInside = repaintAll;
942 Paragraph const & par = text.getPar(pit);
944 paintPar(pi, text, pit, 0, yy, repaintAll);
948 // Cache one paragraph above and one below
949 // Note MV: this cannot be suppressed even for singlepar.
950 // Try viewing the User Guide Mobius figure
953 text.redoParagraph(vi.p1 - 1);
954 theCoords.parPos()[&text][vi.p1 - 1] =
955 Point(0, vi.y1 - text.getPar(vi.p1 - 1).descent());
958 if (vi.p2 < lyx::pit_type(text.paragraphs().size()) - 1) {
959 text.redoParagraph(vi.p2 + 1);
960 theCoords.parPos()[&text][vi.p2 + 1] =
961 Point(0, vi.y2 + text.getPar(vi.p2 + 1).ascent());
964 // and grey out above (should not happen later)
965 // lyxerr << "par ascent: " << text.getPar(vi.p1).ascent() << endl;
966 if (vi.y1 > 0 && !vi.singlepar)
967 pain.fillRectangle(0, 0, bv.workWidth(), vi.y1, LColor::bottomarea);
969 // and possibly grey out below
970 // lyxerr << "par descent: " << text.getPar(vi.p1).ascent() << endl;
971 if (vi.y2 < bv.workHeight() && !vi.singlepar)
972 pain.fillRectangle(0, vi.y2, bv.workWidth(), bv.workHeight() - vi.y2, LColor::bottomarea);
976 void paintTextInset(LyXText const & text, PainterInfo & pi, int x, int y)
978 // lyxerr << " paintTextInset: y: " << y << endl;
980 y -= text.getPar(0).ascent();
981 // This flag can not be set from within same inset:
982 bool repaintAll = refreshInside;
983 for (int pit = 0; pit < int(text.paragraphs().size()); ++pit) {
984 y += text.getPar(pit).ascent();
985 paintPar(pi, text, pit, x, y, repaintAll);
986 y += text.getPar(pit).descent();