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"
19 #include "bufferparams.h"
20 #include "BufferView.h"
27 #include "lyxrow_funcs.h"
28 #include "metricsinfo.h"
29 #include "paragraph.h"
30 #include "paragraph_funcs.h"
31 #include "ParagraphParameters.h"
34 #include "frontends/font_metrics.h"
35 #include "frontends/Painter.h"
37 #include "insets/insettext.h"
39 #include "support/textutils.h"
46 extern int PAPER_MARGIN;
47 extern int CHANGEBAR_MARGIN;
48 extern int LEFT_MARGIN;
52 // "temporary". We'll never get to use more
53 // references until we start adding hacks like
54 // these until other places catch up.
55 BufferView * perv(BufferView const & bv)
57 return const_cast<BufferView *>(&bv);
61 * A class used for painting an individual row of text.
65 /// initialise painter
66 RowPainter(BufferView const & bv, LyXText const & text,
67 ParagraphList::iterator pit,
68 RowList::iterator rit, int y_offset, int x_offset, int y);
73 // paint various parts
74 void paintBackground();
75 void paintSelection();
78 void paintChangeBar();
81 void paintForeignMark(double orig_x, LyXFont const & orig_font);
82 void paintHebrewComposeChar(lyx::pos_type & vpos);
83 void paintArabicComposeChar(lyx::pos_type & vpos);
84 void paintChars(lyx::pos_type & vpos, bool hebrew, bool arabic);
85 int paintAppendixStart(int y);
86 int paintLengthMarker(string const & prefix, VSpace const & vsp, int start);
88 void paintFromPos(lyx::pos_type & vpos);
89 void paintInset(lyx::pos_type const pos);
91 /// return left margin
92 int leftMargin() const;
94 /// return the font at the given pos
95 LyXFont const getFont(lyx::pos_type pos) const;
97 /// return the label font for this row
98 LyXFont const getLabelFont() const;
100 /// return pixel width for the given pos
101 int singleWidth(lyx::pos_type pos) const;
102 int singleWidth(lyx::pos_type pos, char c) const;
104 /// bufferview to paint on
105 BufferView const & bv_;
110 /// LyXText for the row
111 LyXText const & text_;
114 RowList::iterator const rit_;
118 mutable ParagraphList::iterator pit_;
132 RowPainter::RowPainter(BufferView const & bv, LyXText const & text,
133 ParagraphList::iterator pit, RowList::iterator rit,
134 int y_offset, int x_offset, int y)
135 : bv_(bv), pain_(bv_.painter()), text_(text), rit_(rit), row_(*rit),
136 pit_(pit), xo_(x_offset), yo_(y_offset),
138 width_(text_.workWidth()),
139 separator_(row_.fill_separator()),
140 hfill_(row_.fill_hfill()),
141 label_hfill_(row_.fill_label_hfill())
146 LyXFont const RowPainter::getFont(pos_type pos) const
148 return text_.getFont(pit_, pos);
152 int RowPainter::singleWidth(lyx::pos_type pos) const
154 return text_.singleWidth(pit_, pos);
158 int RowPainter::singleWidth(lyx::pos_type pos, char c) const
160 LyXFont const & font = text_.getFont(pit_, pos);
161 return text_.singleWidth(pit_, pos, c, font);
165 LyXFont const RowPainter::getLabelFont() const
167 return text_.getLabelFont(pit_);
171 int RowPainter::leftMargin() const
173 return text_.leftMargin(pit_, row_);
177 void RowPainter::paintInset(pos_type const pos)
179 InsetOld * inset = const_cast<InsetOld*>(pit_->getInset(pos));
183 PainterInfo pi(perv(bv_));
184 pi.base.font = getFont(pos);
185 inset->draw(pi, int(x_), yo_ + row_.baseline());
186 x_ += inset->width();
190 void RowPainter::paintHebrewComposeChar(pos_type & vpos)
192 pos_type pos = text_.bidi.vis2log(vpos);
197 char c = pit_->getChar(pos);
201 LyXFont const & font = getFont(pos);
202 int const width = font_metrics::width(c, font);
205 for (pos_type i = pos - 1; i >= 0; --i) {
206 c = pit_->getChar(i);
207 if (!Encodings::IsComposeChar_hebrew(c)) {
208 if (IsPrintableNonspace(c)) {
209 int const width2 = singleWidth(i, c);
211 dx = (c == 'ø' || c == 'ã')
213 : (width2 - width) / 2;
220 pain_.text(int(x_) + dx, yo_ + row_.baseline(), str, font);
224 void RowPainter::paintArabicComposeChar(pos_type & vpos)
226 pos_type pos = text_.bidi.vis2log(vpos);
230 char c = pit_->getChar(pos);
231 c = pit_->transformChar(c, pos);
235 LyXFont const & font = getFont(pos);
236 int const width = font_metrics::width(c, font);
239 for (pos_type i = pos - 1; i >= 0; --i) {
240 c = pit_->getChar(i);
241 if (!Encodings::IsComposeChar_arabic(c)) {
242 if (IsPrintableNonspace(c)) {
243 int const width2 = singleWidth(i, c);
244 dx = (width2 - width) / 2;
250 pain_.text(int(x_) + dx, yo_ + row_.baseline(), str, font);
254 void RowPainter::paintChars(pos_type & vpos, bool hebrew, bool arabic)
256 pos_type pos = text_.bidi.vis2log(vpos);
257 pos_type const end = row_.endpos();
258 LyXFont orig_font = getFont(pos);
262 str += pit_->getChar(pos);
264 unsigned char c = str[0];
265 str[0] = pit_->transformChar(c, pos);
268 bool prev_struckout = isDeletedText(*pit_, pos);
269 bool prev_newtext = isInsertedText(*pit_, pos);
271 // collect as much similar chars as we can
272 for (++vpos; vpos < end && (pos = text_.bidi.vis2log(vpos)) >= 0; ++vpos) {
273 char c = pit_->getChar(pos);
275 if (!IsPrintableNonspace(c))
278 if (prev_struckout != isDeletedText(*pit_, pos))
281 if (prev_newtext != isInsertedText(*pit_, pos))
284 if (arabic && Encodings::IsComposeChar_arabic(c))
287 if (hebrew && Encodings::IsComposeChar_hebrew(c))
290 if (orig_font != getFont(pos))
294 c = pit_->transformChar(c, pos);
300 orig_font.setColor(LColor::strikeout);
301 else if (prev_newtext)
302 orig_font.setColor(LColor::newtext);
304 // Draw text and set the new x position
305 //lyxerr << "paint row: yo_ " << yo_ << " baseline: " << row_.baseline()
307 pain_.text(int(x_), yo_ + row_.baseline(), str, orig_font);
308 x_ += font_metrics::width(str, orig_font);
312 void RowPainter::paintForeignMark(double orig_x, LyXFont const & orig_font)
314 if (!lyxrc.mark_foreign_language)
316 if (orig_font.language() == latex_language)
318 if (orig_font.language() == bv_.buffer()->params().language)
321 int const y = yo_ + row_.baseline() + 1;
322 pain_.line(int(orig_x), y, int(x_), y, LColor::language);
326 void RowPainter::paintFromPos(pos_type & vpos)
328 pos_type const pos = text_.bidi.vis2log(vpos);
330 LyXFont const & orig_font = getFont(pos);
332 double const orig_x = x_;
334 char const c = pit_->getChar(pos);
336 if (c == Paragraph::META_INSET) {
339 paintForeignMark(orig_x, orig_font);
343 // usual characters, no insets
345 // special case languages
346 bool const hebrew = (orig_font.language()->lang() == "hebrew");
348 orig_font.language()->lang() == "arabic" &&
349 (lyxrc.font_norm_type == LyXRC::ISO_8859_6_8 ||
350 lyxrc.font_norm_type == LyXRC::ISO_10646_1);
352 // draw as many chars as we can
353 if ((!hebrew && !arabic)
354 || (hebrew && !Encodings::IsComposeChar_hebrew(c))
355 || (arabic && !Encodings::IsComposeChar_arabic(c))) {
356 paintChars(vpos, hebrew, arabic);
358 paintHebrewComposeChar(vpos);
360 paintArabicComposeChar(vpos);
363 paintForeignMark(orig_x, orig_font);
369 void RowPainter::paintBackground()
371 int const x = int(xo_);
372 int const y = yo_ < 0 ? 0 : yo_;
373 int const h = yo_ < 0 ? row_.height() + yo_ : row_.height();
374 pain_.fillRectangle(x, y, width_, h, text_.backgroundColor());
378 void RowPainter::paintSelection()
380 bool const is_rtl = pit_->isRightToLeftPar(bv_.buffer()->params());
382 // the current selection
383 int const startx = text_.selection.start.x();
384 int const endx = text_.selection.end.x();
385 int const starty = text_.selection.start.y();
386 int const endy = text_.selection.end.y();
387 ParagraphList::iterator startpit = text_.getPar(text_.selection.start);
388 ParagraphList::iterator endpit = text_.getPar(text_.selection.end);
389 RowList::iterator startrow = startpit->getRow(text_.selection.start.pos());
390 RowList::iterator endrow = endpit->getRow(text_.selection.end.pos());
391 int const h = row_.height();
393 int const row_y = pit_->y + row_.y_offset();
395 if (text_.bidi.same_direction()) {
399 if (startrow == rit_ && endrow == rit_) {
401 x = int(xo_) + startx;
407 pain_.fillRectangle(x, y, w, h, LColor::selection);
408 } else if (startrow == rit_) {
409 int const x = is_rtl ? int(xo_) : int(xo_ + startx);
410 int const w = is_rtl ? startx : (width_ - startx);
411 pain_.fillRectangle(x, y, w, h, LColor::selection);
412 } else if (endrow == rit_) {
413 int const x = is_rtl ? int(xo_ + endx) : int(xo_);
414 int const w = is_rtl ? (width_ - endx) : endx;
415 pain_.fillRectangle(x, y, w, h, LColor::selection);
416 } else if (row_y > starty && row_y < endy) {
418 pain_.fillRectangle(int(xo_), y, width_, h, LColor::selection);
423 if (startrow != rit_ && endrow != rit_) {
424 if (y_ > starty && y_ < endy) {
426 pain_.fillRectangle(int(xo_), yo_, w, h, LColor::selection);
431 if ((startrow != rit_ && !is_rtl) || (endrow != rit_ && is_rtl))
432 pain_.fillRectangle(int(xo_), yo_,
433 int(x_), h, LColor::selection);
435 pos_type const body_pos = pit_->beginOfBody();
436 pos_type const end = row_.endpos();
439 for (pos_type vpos = row_.pos(); vpos < end; ++vpos) {
440 pos_type pos = text_.bidi.vis2log(vpos);
441 double const old_tmpx = tmpx;
442 if (body_pos > 0 && pos == body_pos - 1) {
443 LyXLayout_ptr const & layout = pit_->layout();
444 LyXFont const lfont = getLabelFont();
446 tmpx += label_hfill_ + font_metrics::width(layout->labelsep, lfont);
448 if (pit_->isLineSeparator(body_pos - 1))
449 tmpx -= singleWidth(body_pos - 1);
452 if (hfillExpansion(*pit_, row_, pos)) {
453 tmpx += singleWidth(pos);
457 tmpx += label_hfill_;
460 else if (pit_->isSeparator(pos)) {
461 tmpx += singleWidth(pos);
465 tmpx += singleWidth(pos);
468 if ((startrow != rit_ || text_.selection.start.pos() <= pos) &&
469 (endrow != rit_ || pos < text_.selection.end.pos())) {
470 // Here we do not use x_ as xo_ was added to x_.
471 pain_.fillRectangle(int(old_tmpx), yo_,
472 int(tmpx - old_tmpx + 1), h, LColor::selection);
476 if ((startrow != rit_ && is_rtl) || (endrow != rit_ && !is_rtl)) {
477 pain_.fillRectangle(int(xo_ + tmpx),
478 yo_, int(bv_.workWidth() - tmpx), h, LColor::selection);
483 void RowPainter::paintChangeBar()
485 pos_type const start = row_.pos();
486 pos_type const end = row_.endpos();
488 if (start == end || !pit_->isChanged(start, end - 1))
491 int const height = text_.isLastRow(pit_, row_)
493 : row_.height() + boost::next(rit_)->top_of_text();
495 pain_.fillRectangle(4, yo_, 5, height, LColor::changebar);
499 void RowPainter::paintAppendix()
501 if (!pit_->params().appendix())
504 // FIXME: can be just width_ ?
505 int const ww = bv_.workWidth();
509 if (pit_->params().startOfAppendix())
510 y += 2 * defaultRowHeight();
512 pain_.line(1, y, 1, yo_ + row_.height(), LColor::appendix);
513 pain_.line(ww - 2, y, ww - 2, yo_ + row_.height(), LColor::appendix);
517 void RowPainter::paintDepthBar()
519 Paragraph::depth_type const depth = pit_->getDepth();
524 Paragraph::depth_type prev_depth = 0;
525 if (!text_.isFirstRow(pit_, row_)) {
526 ParagraphList::iterator pit2 = pit_;
529 prev_depth = pit2->getDepth();
532 Paragraph::depth_type next_depth = 0;
533 if (!text_.isLastRow(pit_, row_)) {
534 ParagraphList::iterator pit2 = pit_;
535 if (row_.endpos() >= pit2->size())
537 next_depth = pit2->getDepth();
540 for (Paragraph::depth_type i = 1; i <= depth; ++i) {
541 int const w = PAPER_MARGIN / 5;
542 int x = int(w * i + xo_);
543 // only consider the changebar space if we're drawing outer left
545 x += CHANGEBAR_MARGIN;
546 int const h = yo_ + row_.height() - 1 - (i - next_depth - 1) * 3;
548 pain_.line(x, yo_, x, h, LColor::depthbar);
551 pain_.fillRectangle(x, yo_, w, 2, LColor::depthbar);
553 pain_.fillRectangle(x, h, w, 2, LColor::depthbar);
558 int RowPainter::paintLengthMarker(string const & prefix, VSpace const & vsp,
561 if (vsp.kind() == VSpace::NONE)
564 int const arrow_size = 4;
565 int const size = getLengthMarkerHeight(bv_, vsp);
566 int const end = start + size;
568 // the label to display (if any)
570 // y-values for top arrow
572 // y-values for bottom arrow
575 str = prefix + " (" + vsp.asLyXCommand() + ")";
577 if (vsp.kind() == VSpace::VFILL) {
581 // adding or removing space
582 bool const added = vsp.kind() != VSpace::LENGTH ||
583 vsp.length().len().value() > 0.0;
584 ty1 = added ? (start + arrow_size) : start;
585 ty2 = added ? start : (start + arrow_size);
586 by1 = added ? (end - arrow_size) : end;
587 by2 = added ? end : (end - arrow_size);
590 int const leftx = int(xo_) + leftMargin();
591 int const midx = leftx + arrow_size;
592 int const rightx = midx + arrow_size;
600 font.setColor(LColor::added_space);
603 font_metrics::rectText(str, font, w, a, d);
605 pain_.rectText(leftx + 2 * arrow_size + 5,
606 start + ((end - start) / 2) + d,
608 LColor::none, LColor::none);
611 pain_.line(leftx, ty1, midx, ty2, LColor::added_space);
612 pain_.line(midx, ty2, rightx, ty1, LColor::added_space);
615 pain_.line(leftx, by1, midx, by2, LColor::added_space);
616 pain_.line(midx, by2, rightx, by1, LColor::added_space);
619 pain_.line(midx, ty2, midx, by2, LColor::added_space);
625 int RowPainter::paintAppendixStart(int y)
628 pb_font.setColor(LColor::appendix);
631 string const label = _("Appendix");
635 font_metrics::rectText(label, pb_font, w, a, d);
637 int const text_start = int(xo_ + (width_ - w) / 2);
638 int const text_end = text_start + w;
640 pain_.rectText(text_start, y + d, label, pb_font, LColor::none, LColor::none);
642 pain_.line(int(xo_ + 1), y, text_start, y, LColor::appendix);
643 pain_.line(text_end, y, int(xo_ + width_ - 2), y, LColor::appendix);
645 return 3 * defaultRowHeight();
649 void RowPainter::paintFirst()
651 ParagraphParameters const & parparams = pit_->params();
655 // start of appendix?
656 if (parparams.startOfAppendix())
657 y_top += paintAppendixStart(yo_ + y_top + 2 * defaultRowHeight());
660 if (text_.isFirstRow(pit_, row_) && !text_.isInInset())
661 y_top += PAPER_MARGIN;
663 // draw the additional space if needed:
664 y_top += paintLengthMarker(_("Space above"), parparams.spaceTop(),
667 Buffer const & buffer = *bv_.buffer();
669 LyXLayout_ptr const & layout = pit_->layout();
671 if (buffer.params().paragraph_separation == BufferParams::PARSEP_SKIP) {
672 if (pit_ != text_.ownerParagraphs().begin()) {
673 if (layout->latextype == LATEX_PARAGRAPH
674 && !pit_->getDepth()) {
675 y_top += buffer.params().getDefSkip().inPixels(bv_);
677 LyXLayout_ptr const & playout =
678 boost::prior(pit_)->layout();
679 if (playout->latextype == LATEX_PARAGRAPH
680 && !boost::prior(pit_)->getDepth()) {
681 // is it right to use defskip here, too? (AS)
682 y_top += buffer.params().getDefSkip().inPixels(bv_);
688 int const ww = bv_.workWidth();
690 bool const is_rtl = pit_->isRightToLeftPar(bv_.buffer()->params());
691 bool const is_seq = isFirstInSequence(pit_, text_.ownerParagraphs());
692 //lyxerr << "paintFirst: " << pit_->id() << " is_seq: " << is_seq << std::endl;
694 // should we print a label?
695 if (layout->labeltype >= LABEL_STATIC
696 && (layout->labeltype != LABEL_STATIC
697 || layout->latextype != LATEX_ENVIRONMENT
700 LyXFont font = getLabelFont();
701 if (!pit_->getLabelstring().empty()) {
703 string const str = pit_->getLabelstring();
705 // this is special code for the chapter layout. This is
706 // printed in an extra row and has a pagebreak at
708 if (layout->counter == "chapter") {
709 if (buffer.params().secnumdepth >= 0) {
710 float spacing_val = 1.0;
711 if (!parparams.spacing().isDefault()) {
712 spacing_val = parparams.spacing().getValue();
714 spacing_val = buffer.params().spacing().getValue();
718 int(font_metrics::maxDescent(font) * layout->spacing.getValue() * spacing_val)
719 + int(layout->parsep) * defaultRowHeight();
722 x = ww - leftMargin() -
723 font_metrics::width(str, font);
727 yo_ + row_.baseline() -
728 row_.ascent_of_text() - maxdesc,
733 x = ww - leftMargin()
734 + font_metrics::width(layout->labelsep, font);
736 x = x_ - font_metrics::width(layout->labelsep, font)
737 - font_metrics::width(str, font);
740 pain_.text(int(x), yo_ + row_.baseline(), str, font);
744 // the labels at the top of an environment.
745 // More or less for bibliography
747 (layout->labeltype == LABEL_TOP_ENVIRONMENT ||
748 layout->labeltype == LABEL_BIBLIO ||
749 layout->labeltype == LABEL_CENTERED_TOP_ENVIRONMENT)) {
750 LyXFont font = getLabelFont();
751 if (!pit_->getLabelstring().empty()) {
752 string const str = pit_->getLabelstring();
753 float spacing_val = 1.0;
754 if (!parparams.spacing().isDefault()) {
755 spacing_val = parparams.spacing().getValue();
757 spacing_val = buffer.params().spacing().getValue();
761 int(font_metrics::maxDescent(font) * layout->spacing.getValue() * spacing_val
762 + (layout->labelbottomsep * defaultRowHeight()));
765 if (layout->labeltype == LABEL_CENTERED_TOP_ENVIRONMENT) {
766 x = ((is_rtl ? leftMargin() : x_)
767 + ww - text_.rightMargin(*pit_, *bv_.buffer())) / 2;
768 x -= font_metrics::width(str, font) / 2;
770 x = ww - leftMargin() -
771 font_metrics::width(str, font);
774 yo_ + row_.baseline() - row_.ascent_of_text() - maxdesc,
781 void RowPainter::paintLast()
783 ParagraphParameters const & parparams = pit_->params();
784 int y_bottom = row_.height() - 1;
787 if (text_.isLastRow(pit_, row_) && !text_.isInInset())
788 y_bottom -= PAPER_MARGIN;
790 int const ww = bv_.workWidth();
792 // draw the additional space if needed:
793 int const height = getLengthMarkerHeight(bv_, parparams.spaceBottom());
794 y_bottom -= paintLengthMarker(_("Space below"), parparams.spaceBottom(),
795 yo_ + y_bottom - height);
797 bool const is_rtl = pit_->isRightToLeftPar(bv_.buffer()->params());
798 int const endlabel = getEndLabel(pit_, text_.ownerParagraphs());
803 case END_LABEL_FILLED_BOX: {
804 LyXFont const font = getLabelFont();
805 int const size = int(0.75 * font_metrics::maxAscent(font));
806 int const y = yo_ + row_.baseline() - size;
807 int x = is_rtl ? LEFT_MARGIN : ww - PAPER_MARGIN - size;
809 if (row_.fill() <= size)
810 x += (size - row_.fill() + 1) * (is_rtl ? -1 : 1);
812 if (endlabel == END_LABEL_BOX)
813 pain_.rectangle(x, y, size, size, LColor::eolmarker);
815 pain_.fillRectangle(x, y, size, size, LColor::eolmarker);
819 case END_LABEL_STATIC: {
820 LyXFont font = getLabelFont();
821 string const & str = pit_->layout()->endlabelstring();
822 double const x = is_rtl ?
823 x_ - font_metrics::width(str, font)
824 : ww - text_.rightMargin(*pit_, *bv_.buffer()) - row_.fill();
825 pain_.text(int(x), yo_ + row_.baseline(), str, font);
829 case END_LABEL_NO_LABEL:
835 void RowPainter::paintText()
837 pos_type const end = row_.endpos();
838 pos_type body_pos = pit_->beginOfBody();
840 (body_pos > end || !pit_->isLineSeparator(body_pos - 1))) {
844 LyXLayout_ptr const & layout = pit_->layout();
846 bool running_strikeout = false;
847 bool is_struckout = false;
848 int last_strikeout_x = 0;
850 for (pos_type vpos = row_.pos(); vpos < end; ) {
851 if (x_ > bv_.workWidth())
854 pos_type pos = text_.bidi.vis2log(vpos);
856 if (pos >= pit_->size()) {
861 if (x_ + singleWidth(pos) < 0) {
862 x_ += singleWidth(pos);
867 is_struckout = isDeletedText(*pit_, pos);
869 if (is_struckout && !running_strikeout) {
870 running_strikeout = true;
871 last_strikeout_x = int(x_);
874 bool const highly_editable_inset = pit_->isInset(pos)
875 && isHighlyEditableInset(pit_->getInset(pos));
877 // if we reach the end of a struck out range, paint it
878 // we also don't paint across things like tables
879 if (running_strikeout && (highly_editable_inset || !is_struckout)) {
880 int const middle = yo_ + (row_.baseline() + row_.top_of_text()) / 2;
881 pain_.line(last_strikeout_x, middle, int(x_), middle,
882 LColor::strikeout, Painter::line_solid, Painter::line_thin);
883 running_strikeout = false;
886 if (body_pos > 0 && pos == body_pos - 1) {
887 int const lwidth = font_metrics::width(layout->labelsep,
890 x_ += label_hfill_ + lwidth - singleWidth(body_pos - 1);
893 if (pit_->isHfill(pos)) {
896 int const y0 = yo_ + row_.baseline();
897 int const y1 = y0 - defaultRowHeight() / 2;
899 pain_.line(int(x_), y1, int(x_), y0, LColor::added_space);
901 if (hfillExpansion(*pit_, row_, pos)) {
902 int const y2 = (y0 + y1) / 2;
904 if (pos >= body_pos) {
905 pain_.line(int(x_), y2, int(x_ + hfill_), y2,
907 Painter::line_onoffdash);
910 pain_.line(int(x_), y2, int(x_ + label_hfill_), y2,
912 Painter::line_onoffdash);
915 pain_.line(int(x_), y1, int(x_), y0, LColor::added_space);
919 } else if (pit_->isSeparator(pos)) {
920 x_ += singleWidth(pos);
929 // if we reach the end of a struck out range, paint it
930 if (running_strikeout) {
931 int const middle = yo_ + (row_.baseline() + row_.top_of_text()) / 2;
932 pain_.line(last_strikeout_x, middle, int(x_), middle,
933 LColor::strikeout, Painter::line_solid, Painter::line_thin);
934 running_strikeout = false;
939 void RowPainter::paint()
941 // FIXME: what is this fixing ?
942 if (text_.isInInset() && x_ < 0)
946 // background has already been cleared.
947 if (&text_ == bv_.text)
950 // paint the selection background
951 if (text_.selection.set() && &text_ == bv_.cursor().innerText())
954 // vertical lines for appendix
957 // environment depth brackets
966 if (row_.endpos() >= pit_->size())
974 int paintRows(BufferView const & bv, LyXText const & text,
975 ParagraphList::iterator pit, RowList::iterator rit,
976 int xo, int y, int yf, int yo)
978 //lyxerr << " paintRows: rit: " << &*rit << endl;
979 int const yy = yf - y;
980 int const y2 = bv.painter().paperHeight();
982 ParagraphList::iterator end = text.ownerParagraphs().end();
985 for ( ; pit != end; ++pit) {
986 RowList::iterator row = pit->rows.begin();
987 RowList::iterator rend = pit->rows.end();
989 for ( ; row != rend; ++row) {
993 RowPainter painter(bv, text, pit, row, y + yo, xo, y + bv.top_y());
997 //lyxerr << " paintRows: row: " << &*row << " ignored" << endl;
1010 int paintText(BufferView & bv)
1012 int const topy = bv.top_y();
1013 ParagraphList::iterator pit;
1014 RowList::iterator rit = bv.text->getRowNearY(topy, pit);
1015 int const y = pit->y + rit->y_offset() - topy;
1016 return paintRows(bv, *bv.text, pit, rit, 0, y, y, 0);
1020 void paintTextInset(BufferView & bv, LyXText & text, int x, int baseline)
1022 RowList::iterator rit = text.firstRow();
1023 RowList::iterator end = text.endRow();
1024 ParagraphList::iterator pit = text.ownerParagraphs().begin();
1026 int y_offset = baseline - rit->ascent_of_text();
1028 while (rit != end && y + rit->height() <= 0) {
1030 text.nextRow(pit, rit);
1033 paintRows(bv, text, pit, rit, x, 0, y, y);
1035 paintRows(bv, text, pit, rit, x, 0, y_offset, y_offset);
1039 int getLengthMarkerHeight(BufferView const & bv, VSpace const & vsp)
1041 if (vsp.kind() == VSpace::NONE)
1044 int const arrow_size = 4;
1045 int const space_size = vsp.inPixels(bv);
1049 int const min_size = max(3 * arrow_size, font_metrics::maxHeight(font));
1051 if (vsp.length().len().value() < 0.0)
1054 return max(min_size, space_size);