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);
367 void RowPainter::paintBackground()
369 int const x = int(xo_);
370 int const y = yo_ < 0 ? 0 : yo_;
371 int const h = yo_ < 0 ? row_.height() + yo_ : row_.height();
372 pain_.fillRectangle(x, y, width_, h, text_.backgroundColor());
376 void RowPainter::paintSelection()
378 bool const is_rtl = pit_->isRightToLeftPar(bv_.buffer()->params());
380 // the current selection
381 int const startx = text_.selection.start.x();
382 int const endx = text_.selection.end.x();
383 int const starty = text_.selection.start.y();
384 int const endy = text_.selection.end.y();
385 ParagraphList::iterator startpit = text_.getPar(text_.selection.start);
386 ParagraphList::iterator endpit = text_.getPar(text_.selection.end);
387 RowList::iterator startrow = startpit->getRow(text_.selection.start.pos());
388 RowList::iterator endrow = endpit->getRow(text_.selection.end.pos());
389 int const h = row_.height();
391 int const row_y = pit_->y + row_.y_offset();
393 if (text_.bidi.same_direction()) {
397 if (startrow == rit_ && endrow == rit_) {
399 x = int(xo_) + startx;
405 pain_.fillRectangle(x, y, w, h, LColor::selection);
406 } else if (startrow == rit_) {
407 int const x = is_rtl ? int(xo_) : int(xo_ + startx);
408 int const w = is_rtl ? startx : (width_ - startx);
409 pain_.fillRectangle(x, y, w, h, LColor::selection);
410 } else if (endrow == rit_) {
411 int const x = is_rtl ? int(xo_ + endx) : int(xo_);
412 int const w = is_rtl ? (width_ - endx) : endx;
413 pain_.fillRectangle(x, y, w, h, LColor::selection);
414 } else if (row_y > starty && row_y < endy) {
416 pain_.fillRectangle(int(xo_), y, width_, h, LColor::selection);
421 if (startrow != rit_ && endrow != rit_) {
422 if (y_ > starty && y_ < endy) {
424 pain_.fillRectangle(int(xo_), yo_, w, h, LColor::selection);
429 if ((startrow != rit_ && !is_rtl) || (endrow != rit_ && is_rtl))
430 pain_.fillRectangle(int(xo_), yo_,
431 int(x_), h, LColor::selection);
433 pos_type const body_pos = pit_->beginOfBody();
434 pos_type const end = row_.endpos();
437 for (pos_type vpos = row_.pos(); vpos < end; ++vpos) {
438 pos_type pos = text_.bidi.vis2log(vpos);
439 double const old_tmpx = tmpx;
440 if (body_pos > 0 && pos == body_pos - 1) {
441 LyXLayout_ptr const & layout = pit_->layout();
442 LyXFont const lfont = getLabelFont();
444 tmpx += label_hfill_ + font_metrics::width(layout->labelsep, lfont);
446 if (pit_->isLineSeparator(body_pos - 1))
447 tmpx -= singleWidth(body_pos - 1);
450 tmpx += singleWidth(pos);
452 if (hfillExpansion(*pit_, row_, pos)) {
456 tmpx += label_hfill_;
458 if (pit_->isSeparator(pos) && pos >= body_pos)
462 if ((startrow != rit_ || text_.selection.start.pos() <= pos) &&
463 (endrow != rit_ || pos < text_.selection.end.pos())) {
464 // Here we do not use x_ as xo_ was added to x_.
465 pain_.fillRectangle(int(old_tmpx), yo_,
466 int(tmpx - old_tmpx + 1), h, LColor::selection);
470 if ((startrow != rit_ && is_rtl) || (endrow != rit_ && !is_rtl)) {
471 pain_.fillRectangle(int(xo_ + tmpx),
472 yo_, int(bv_.workWidth() - tmpx), h, LColor::selection);
477 void RowPainter::paintChangeBar()
479 pos_type const start = row_.pos();
480 pos_type const end = row_.endpos();
482 if (start == end || !pit_->isChanged(start, end - 1))
485 int const height = text_.isLastRow(pit_, row_)
487 : row_.height() + boost::next(rit_)->top_of_text();
489 pain_.fillRectangle(4, yo_, 5, height, LColor::changebar);
493 void RowPainter::paintAppendix()
495 if (!pit_->params().appendix())
498 // FIXME: can be just width_ ?
499 int const ww = bv_.workWidth();
503 if (pit_->params().startOfAppendix())
504 y += 2 * defaultRowHeight();
506 pain_.line(1, y, 1, yo_ + row_.height(), LColor::appendix);
507 pain_.line(ww - 2, y, ww - 2, yo_ + row_.height(), LColor::appendix);
511 void RowPainter::paintDepthBar()
513 Paragraph::depth_type const depth = pit_->getDepth();
518 Paragraph::depth_type prev_depth = 0;
519 if (!text_.isFirstRow(pit_, row_)) {
520 ParagraphList::iterator pit2 = pit_;
523 prev_depth = pit2->getDepth();
526 Paragraph::depth_type next_depth = 0;
527 if (!text_.isLastRow(pit_, row_)) {
528 ParagraphList::iterator pit2 = pit_;
529 if (row_.endpos() >= pit2->size())
531 next_depth = pit2->getDepth();
534 for (Paragraph::depth_type i = 1; i <= depth; ++i) {
535 int const w = PAPER_MARGIN / 5;
536 int x = int(w * i + xo_);
537 // only consider the changebar space if we're drawing outer left
539 x += CHANGEBAR_MARGIN;
540 int const h = yo_ + row_.height() - 1 - (i - next_depth - 1) * 3;
542 pain_.line(x, yo_, x, h, LColor::depthbar);
545 pain_.fillRectangle(x, yo_, w, 2, LColor::depthbar);
547 pain_.fillRectangle(x, h, w, 2, LColor::depthbar);
552 int RowPainter::paintLengthMarker(string const & prefix, VSpace const & vsp,
555 if (vsp.kind() == VSpace::NONE)
558 int const arrow_size = 4;
559 int const size = getLengthMarkerHeight(bv_, vsp);
560 int const end = start + size;
562 // the label to display (if any)
564 // y-values for top arrow
566 // y-values for bottom arrow
569 str = prefix + " (" + vsp.asLyXCommand() + ")";
571 if (vsp.kind() == VSpace::VFILL) {
575 // adding or removing space
576 bool const added = vsp.kind() != VSpace::LENGTH ||
577 vsp.length().len().value() > 0.0;
578 ty1 = added ? (start + arrow_size) : start;
579 ty2 = added ? start : (start + arrow_size);
580 by1 = added ? (end - arrow_size) : end;
581 by2 = added ? end : (end - arrow_size);
584 int const leftx = int(xo_) + leftMargin();
585 int const midx = leftx + arrow_size;
586 int const rightx = midx + arrow_size;
594 font.setColor(LColor::added_space);
597 font_metrics::rectText(str, font, w, a, d);
599 pain_.rectText(leftx + 2 * arrow_size + 5,
600 start + ((end - start) / 2) + d,
602 LColor::none, LColor::none);
605 pain_.line(leftx, ty1, midx, ty2, LColor::added_space);
606 pain_.line(midx, ty2, rightx, ty1, LColor::added_space);
609 pain_.line(leftx, by1, midx, by2, LColor::added_space);
610 pain_.line(midx, by2, rightx, by1, LColor::added_space);
613 pain_.line(midx, ty2, midx, by2, LColor::added_space);
619 int RowPainter::paintAppendixStart(int y)
622 pb_font.setColor(LColor::appendix);
625 string const label = _("Appendix");
629 font_metrics::rectText(label, pb_font, w, a, d);
631 int const text_start = int(xo_ + (width_ - w) / 2);
632 int const text_end = text_start + w;
634 pain_.rectText(text_start, y + d, label, pb_font, LColor::none, LColor::none);
636 pain_.line(int(xo_ + 1), y, text_start, y, LColor::appendix);
637 pain_.line(text_end, y, int(xo_ + width_ - 2), y, LColor::appendix);
639 return 3 * defaultRowHeight();
643 void RowPainter::paintFirst()
645 ParagraphParameters const & parparams = pit_->params();
649 // start of appendix?
650 if (parparams.startOfAppendix())
651 y_top += paintAppendixStart(yo_ + y_top + 2 * defaultRowHeight());
654 if (text_.isFirstRow(pit_, row_) && !text_.isInInset())
655 y_top += PAPER_MARGIN;
657 // draw the additional space if needed:
658 y_top += paintLengthMarker(_("Space above"), parparams.spaceTop(),
661 Buffer const & buffer = *bv_.buffer();
663 LyXLayout_ptr const & layout = pit_->layout();
665 if (buffer.params().paragraph_separation == BufferParams::PARSEP_SKIP) {
666 if (pit_ != text_.ownerParagraphs().begin()) {
667 if (layout->latextype == LATEX_PARAGRAPH
668 && !pit_->getDepth()) {
669 y_top += buffer.params().getDefSkip().inPixels(bv_);
671 LyXLayout_ptr const & playout =
672 boost::prior(pit_)->layout();
673 if (playout->latextype == LATEX_PARAGRAPH
674 && !boost::prior(pit_)->getDepth()) {
675 // is it right to use defskip here, too? (AS)
676 y_top += buffer.params().getDefSkip().inPixels(bv_);
682 int const ww = bv_.workWidth();
684 bool const is_rtl = pit_->isRightToLeftPar(bv_.buffer()->params());
685 bool const is_seq = isFirstInSequence(pit_, text_.ownerParagraphs());
686 //lyxerr << "paintFirst: " << pit_->id() << " is_seq: " << is_seq << std::endl;
688 // should we print a label?
689 if (layout->labeltype >= LABEL_STATIC
690 && (layout->labeltype != LABEL_STATIC
691 || layout->latextype != LATEX_ENVIRONMENT
694 LyXFont font = getLabelFont();
695 if (!pit_->getLabelstring().empty()) {
697 string const str = pit_->getLabelstring();
699 // this is special code for the chapter layout. This is
700 // printed in an extra row and has a pagebreak at
702 if (layout->counter == "chapter") {
703 if (buffer.params().secnumdepth >= 0) {
704 float spacing_val = 1.0;
705 if (!parparams.spacing().isDefault()) {
706 spacing_val = parparams.spacing().getValue();
708 spacing_val = buffer.params().spacing().getValue();
712 int(font_metrics::maxDescent(font) * layout->spacing.getValue() * spacing_val)
713 + int(layout->parsep) * defaultRowHeight();
716 x = ww - leftMargin() -
717 font_metrics::width(str, font);
721 yo_ + row_.baseline() -
722 row_.ascent_of_text() - maxdesc,
727 x = ww - leftMargin()
728 + font_metrics::width(layout->labelsep, font);
730 x = x_ - font_metrics::width(layout->labelsep, font)
731 - font_metrics::width(str, font);
734 pain_.text(int(x), yo_ + row_.baseline(), str, font);
738 // the labels at the top of an environment.
739 // More or less for bibliography
741 (layout->labeltype == LABEL_TOP_ENVIRONMENT ||
742 layout->labeltype == LABEL_BIBLIO ||
743 layout->labeltype == LABEL_CENTERED_TOP_ENVIRONMENT)) {
744 LyXFont font = getLabelFont();
745 if (!pit_->getLabelstring().empty()) {
746 string const str = pit_->getLabelstring();
747 float spacing_val = 1.0;
748 if (!parparams.spacing().isDefault()) {
749 spacing_val = parparams.spacing().getValue();
751 spacing_val = buffer.params().spacing().getValue();
755 int(font_metrics::maxDescent(font) * layout->spacing.getValue() * spacing_val
756 + (layout->labelbottomsep * defaultRowHeight()));
759 if (layout->labeltype == LABEL_CENTERED_TOP_ENVIRONMENT) {
760 x = ((is_rtl ? leftMargin() : x_)
761 + ww - text_.rightMargin(*pit_, *bv_.buffer())) / 2;
762 x -= font_metrics::width(str, font) / 2;
764 x = ww - leftMargin() -
765 font_metrics::width(str, font);
768 yo_ + row_.baseline() - row_.ascent_of_text() - maxdesc,
775 void RowPainter::paintLast()
777 ParagraphParameters const & parparams = pit_->params();
778 int y_bottom = row_.height() - 1;
781 if (text_.isLastRow(pit_, row_) && !text_.isInInset())
782 y_bottom -= PAPER_MARGIN;
784 int const ww = bv_.workWidth();
786 // draw the additional space if needed:
787 int const height = getLengthMarkerHeight(bv_, parparams.spaceBottom());
788 y_bottom -= paintLengthMarker(_("Space below"), parparams.spaceBottom(),
789 yo_ + y_bottom - height);
791 bool const is_rtl = pit_->isRightToLeftPar(bv_.buffer()->params());
792 int const endlabel = getEndLabel(pit_, text_.ownerParagraphs());
797 case END_LABEL_FILLED_BOX: {
798 LyXFont const font = getLabelFont();
799 int const size = int(0.75 * font_metrics::maxAscent(font));
800 int const y = yo_ + row_.baseline() - size;
801 int x = is_rtl ? LEFT_MARGIN : ww - PAPER_MARGIN - size;
803 if (row_.fill() <= size)
804 x += (size - row_.fill() + 1) * (is_rtl ? -1 : 1);
806 if (endlabel == END_LABEL_BOX)
807 pain_.rectangle(x, y, size, size, LColor::eolmarker);
809 pain_.fillRectangle(x, y, size, size, LColor::eolmarker);
813 case END_LABEL_STATIC: {
814 LyXFont font = getLabelFont();
815 string const & str = pit_->layout()->endlabelstring();
816 double const x = is_rtl ?
817 x_ - font_metrics::width(str, font)
818 : ww - text_.rightMargin(*pit_, *bv_.buffer()) - row_.fill();
819 pain_.text(int(x), yo_ + row_.baseline(), str, font);
823 case END_LABEL_NO_LABEL:
829 void RowPainter::paintText()
831 pos_type const end = row_.endpos();
832 pos_type body_pos = pit_->beginOfBody();
834 (body_pos > end || !pit_->isLineSeparator(body_pos - 1))) {
838 LyXLayout_ptr const & layout = pit_->layout();
840 bool running_strikeout = false;
841 bool is_struckout = false;
842 int last_strikeout_x = 0;
844 for (pos_type vpos = row_.pos(); vpos < end; ) {
845 if (x_ > bv_.workWidth())
848 pos_type pos = text_.bidi.vis2log(vpos);
850 if (pos >= pit_->size()) {
855 if (x_ + singleWidth(pos) < 0) {
856 x_ += singleWidth(pos);
861 is_struckout = isDeletedText(*pit_, pos);
863 if (is_struckout && !running_strikeout) {
864 running_strikeout = true;
865 last_strikeout_x = int(x_);
868 bool const highly_editable_inset = pit_->isInset(pos)
869 && isHighlyEditableInset(pit_->getInset(pos));
871 // if we reach the end of a struck out range, paint it
872 // we also don't paint across things like tables
873 if (running_strikeout && (highly_editable_inset || !is_struckout)) {
874 int const middle = yo_ + (row_.baseline() + row_.top_of_text()) / 2;
875 pain_.line(last_strikeout_x, middle, int(x_), middle,
876 LColor::strikeout, Painter::line_solid, Painter::line_thin);
877 running_strikeout = false;
880 if (body_pos > 0 && pos == body_pos - 1) {
881 int const lwidth = font_metrics::width(layout->labelsep,
884 x_ += label_hfill_ + lwidth - singleWidth(body_pos - 1);
887 if (pit_->isHfill(pos)) {
890 int const y0 = yo_ + row_.baseline();
891 int const y1 = y0 - defaultRowHeight() / 2;
893 pain_.line(int(x_), y1, int(x_), y0, LColor::added_space);
895 if (hfillExpansion(*pit_, row_, pos)) {
896 int const y2 = (y0 + y1) / 2;
898 if (pos >= body_pos) {
899 pain_.line(int(x_), y2, int(x_ + hfill_), y2,
901 Painter::line_onoffdash);
904 pain_.line(int(x_), y2, int(x_ + label_hfill_), y2,
906 Painter::line_onoffdash);
909 pain_.line(int(x_), y1, int(x_), y0, LColor::added_space);
913 } else if (pit_->isSeparator(pos)) {
914 x_ += singleWidth(pos);
923 // if we reach the end of a struck out range, paint it
924 if (running_strikeout) {
925 int const middle = yo_ + (row_.baseline() + row_.top_of_text()) / 2;
926 pain_.line(last_strikeout_x, middle, int(x_), middle,
927 LColor::strikeout, Painter::line_solid, Painter::line_thin);
928 running_strikeout = false;
933 void RowPainter::paint()
935 // FIXME: what is this fixing ?
936 if (text_.isInInset() && x_ < 0)
940 // background has already been cleared.
941 if (&text_ == bv_.text)
944 // paint the selection background
945 if (text_.selection.set() && &text_ == bv_.cursor().innerText())
948 // vertical lines for appendix
951 // environment depth brackets
960 if (row_.endpos() >= pit_->size())
968 int paintPars(BufferView const & bv, LyXText const & text,
969 ParagraphList::iterator pit, int xo, int yo, int y)
971 //lyxerr << " paintRows: pit: " << &*pit << endl;
972 int const y2 = bv.painter().paperHeight();
974 ParagraphList::iterator end = text.ownerParagraphs().end();
976 for ( ; pit != end; ++pit) {
977 RowList::iterator row = pit->rows.begin();
978 RowList::iterator rend = pit->rows.end();
980 for ( ; row != rend; ++row) {
981 RowPainter painter(bv, text, pit, row, y + yo, xo, y + bv.top_y());
995 int paintText(BufferView & bv)
997 int const topy = bv.top_y();
998 ParagraphList::iterator pit;
999 bv.text->getRowNearY(topy, pit);
1000 return paintPars(bv, *bv.text, pit, 0, 0, pit->y - topy);
1004 void paintTextInset(BufferView & bv, LyXText & text, int xo, int yo)
1006 paintPars(bv, text, text.ownerParagraphs().begin(), xo, yo, 0);
1010 int getLengthMarkerHeight(BufferView const & bv, VSpace const & vsp)
1012 if (vsp.kind() == VSpace::NONE)
1015 int const arrow_size = 4;
1016 int const space_size = vsp.inPixels(bv);
1020 int const min_size = max(3 * arrow_size, font_metrics::maxHeight(font));
1022 if (vsp.length().len().value() < 0.0)
1025 return max(min_size, space_size);