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 "frontends/Painter.h"
15 #include "frontends/screen.h"
16 #include "frontends/font_metrics.h"
17 #include "support/LAssert.h"
18 #include "paragraph.h"
19 #include "paragraph_funcs.h"
20 #include "support/textutils.h"
22 #include "insets/insettext.h"
23 #include "ParagraphParameters.h"
24 #include "BufferView.h"
31 #include "rowpainter.h"
33 #include "lyxrow_funcs.h"
34 #include "metricsinfo.h"
38 using namespace lyx::support;
43 extern int PAPER_MARGIN;
44 extern int CHANGEBAR_MARGIN;
45 extern int LEFT_MARGIN;
49 // "temporary". We'll never get to use more
50 // references until we start adding hacks like
51 // these until other places catch up.
52 BufferView * perv(BufferView const & bv)
54 return const_cast<BufferView *>(&bv);
58 * A class used for painting an individual row of text.
62 /// initialise painter
63 RowPainter(BufferView const & bv, LyXText const & text,
64 RowList::iterator rit, int y_offset, int x_offset, int y);
69 // paint various parts
70 void paintBackground();
71 void paintSelection();
74 void paintChangeBar();
77 void paintForeignMark(int orig_x, LyXFont const & orig_font);
78 void paintHebrewComposeChar(lyx::pos_type & vpos);
79 void paintArabicComposeChar(lyx::pos_type & vpos);
80 void paintChars(lyx::pos_type & vpos, bool hebrew, bool arabic);
81 int paintPageBreak(string const & label, int y);
82 int paintAppendixStart(int y);
83 int paintLengthMarker(string const & prefix, VSpace const & vsp, int start);
85 void paintFromPos(lyx::pos_type & vpos);
86 void paintInset(lyx::pos_type const pos);
88 /// return left margin
89 int leftMargin() const;
91 /// return the font at the given pos
92 LyXFont const getFont(lyx::pos_type pos) const;
94 /// return the label font for this row
95 LyXFont const getLabelFont() const;
97 char const transformChar(char c, lyx::pos_type pos) const;
99 /// return pixel width for the given pos
100 int singleWidth(lyx::pos_type pos) const;
101 int singleWidth(lyx::pos_type pos, char c) const;
103 /// bufferview to paint on
104 BufferView const & bv_;
109 /// LyXText for the row
110 LyXText const & text_;
113 RowList::iterator row_;
116 mutable ParagraphList::iterator pit_;
129 RowPainter::RowPainter(BufferView const & bv, LyXText const & text,
130 RowList::iterator rit,
131 int y_offset, int x_offset, int y)
132 : bv_(bv), pain_(bv_.painter()), text_(text), row_(rit),
134 xo_(x_offset), yo_(y_offset), y_(y)
139 LyXFont const RowPainter::getFont(pos_type pos) const
141 return text_.getFont(bv_.buffer(), pit_, pos);
145 int RowPainter::singleWidth(lyx::pos_type pos) const
147 return text_.singleWidth(pit_, pos);
151 int RowPainter::singleWidth(lyx::pos_type pos, char c) const
153 return text_.singleWidth(pit_, pos, c);
157 LyXFont const RowPainter::getLabelFont() const
159 return text_.getLabelFont(bv_.buffer(), pit_);
163 char const RowPainter::transformChar(char c, lyx::pos_type pos) const
165 return text_.transformChar(c, *pit_, pos);
169 int RowPainter::leftMargin() const
171 return text_.leftMargin(*row_);
175 void RowPainter::paintInset(pos_type const pos)
177 Inset * inset = const_cast<Inset*>(pit_->getInset(pos));
181 //MetricsInfo mi(perv(bv_), getFont(pos), text_.workWidth());
183 //inset->metrics(mi, dim);
185 PainterInfo pi(perv(bv_));
186 pi.base.font = getFont(pos);
188 inset->draw(pi, int(x_), yo_ + row_->baseline());
189 x_ += inset->width();
193 void RowPainter::paintHebrewComposeChar(pos_type & vpos)
195 pos_type pos = text_.vis2log(vpos);
200 char c = pit_->getChar(pos);
204 LyXFont const & font = getFont(pos);
205 int const width = font_metrics::width(c, font);
208 for (pos_type i = pos - 1; i >= 0; --i) {
209 c = pit_->getChar(i);
210 if (!Encodings::IsComposeChar_hebrew(c)) {
211 if (IsPrintableNonspace(c)) {
215 dx = (c == 'ø' || c == 'ã')
217 : (width2 - width) / 2;
224 pain_.text(int(x_) + dx, yo_ + row_->baseline(), str, font);
228 void RowPainter::paintArabicComposeChar(pos_type & vpos)
230 pos_type pos = text_.vis2log(vpos);
234 char c = pit_->getChar(pos);
235 c = transformChar(c, pos);
239 LyXFont const & font = getFont(pos);
240 int const width = font_metrics::width(c, font);
243 for (pos_type i = pos - 1; i >= 0; --i) {
244 c = pit_->getChar(i);
245 if (!Encodings::IsComposeChar_arabic(c)) {
246 if (IsPrintableNonspace(c)) {
249 dx = (width2 - width) / 2;
255 pain_.text(int(x_) + dx, yo_ + row_->baseline(), str, font);
259 void RowPainter::paintChars(pos_type & vpos, bool hebrew, bool arabic)
261 pos_type pos = text_.vis2log(vpos);
262 pos_type const last = lastPrintablePos(text_, row_);
263 LyXFont orig_font = getFont(pos);
267 str += pit_->getChar(pos);
269 unsigned char c = str[0];
270 str[0] = transformChar(c, pos);
273 bool prev_struckout(isDeletedText(*pit_, pos));
274 bool prev_newtext(isInsertedText(*pit_, pos));
278 // collect as much similar chars as we can
279 while (vpos <= last && (pos = text_.vis2log(vpos)) >= 0) {
280 char c = pit_->getChar(pos);
282 if (!IsPrintableNonspace(c))
285 if (prev_struckout != isDeletedText(*pit_, pos))
288 if (prev_newtext != isInsertedText(*pit_, pos))
291 if (arabic && Encodings::IsComposeChar_arabic(c))
293 if (hebrew && Encodings::IsComposeChar_hebrew(c))
296 if (orig_font != getFont(pos))
300 c = transformChar(c, pos);
305 if (prev_struckout) {
306 orig_font.setColor(LColor::strikeout);
307 } else if (prev_newtext) {
308 orig_font.setColor(LColor::newtext);
311 // Draw text and set the new x position
312 pain_.text(int(x_), yo_ + row_->baseline(), str, orig_font);
313 x_ += font_metrics::width(str, orig_font);
317 void RowPainter::paintForeignMark(int orig_x, LyXFont const & orig_font)
319 if (!lyxrc.mark_foreign_language)
321 if (orig_font.language() == latex_language)
323 if (orig_font.language() == bv_.buffer()->params.language)
326 int const y = yo_ + row_->baseline() + 1;
327 pain_.line(int(orig_x), y, int(x_), y, LColor::language);
331 void RowPainter::paintFromPos(pos_type & vpos)
333 pos_type const pos = text_.vis2log(vpos);
335 LyXFont const & orig_font = getFont(pos);
337 int const orig_x = x_;
339 char const c = pit_->getChar(pos);
341 if (IsInsetChar(c)) {
344 paintForeignMark(orig_x, orig_font);
348 // usual characters, no insets
350 // special case languages
351 bool const hebrew = (orig_font.language()->lang() == "hebrew");
353 orig_font.language()->lang() == "arabic" &&
354 (lyxrc.font_norm_type == LyXRC::ISO_8859_6_8 ||
355 lyxrc.font_norm_type == LyXRC::ISO_10646_1);
357 // draw as many chars as we can
358 if ((!hebrew && !arabic)
359 || (hebrew && !Encodings::IsComposeChar_hebrew(c))
360 || (arabic && !Encodings::IsComposeChar_arabic(c))) {
361 paintChars(vpos, hebrew, arabic);
363 paintHebrewComposeChar(vpos);
365 paintArabicComposeChar(vpos);
368 paintForeignMark(orig_x, orig_font);
374 void RowPainter::paintBackground()
377 int const y = yo_ < 0 ? 0 : yo_;
378 int const h = yo_ < 0 ? row_->height() + yo_ : row_->height();
379 pain_.fillRectangle(x, y, width_, h, text_.backgroundColor());
383 void RowPainter::paintSelection()
385 bool const is_rtl = pit_->isRightToLeftPar(bv_.buffer()->params);
387 // the current selection
388 int const startx = text_.selection.start.x();
389 int const endx = text_.selection.end.x();
390 int const starty = text_.selection.start.y();
391 int const endy = text_.selection.end.y();
392 RowList::iterator startrow = text_.getRow(text_.selection.start);
393 RowList::iterator endrow = text_.getRow(text_.selection.end);
395 if (text_.bidi_same_direction) {
399 int h = row_->height();
401 if (startrow == row_ && endrow == row_) {
405 pain_.fillRectangle(x, y, w, h, LColor::selection);
409 pain_.fillRectangle(x, y, w, h, LColor::selection);
411 } else if (startrow == row_) {
412 int const x = (is_rtl) ? xo_ : (xo_ + startx);
413 int const w = (is_rtl) ? startx : (width_ - startx);
414 pain_.fillRectangle(x, y, w, h, LColor::selection);
415 } else if (endrow == row_) {
416 int const x = (is_rtl) ? (xo_ + endx) : xo_;
417 int const w = (is_rtl) ? (width_ - endx) : endx;
418 pain_.fillRectangle(x, y, w, h, LColor::selection);
419 } else if (y_ > starty && y_ < endy) {
420 pain_.fillRectangle(xo_, y, width_, h, LColor::selection);
423 } else if (startrow != row_ && endrow != row_) {
424 if (y_ > starty && y_ < endy) {
426 int h = row_->height();
427 pain_.fillRectangle(xo_, yo_, w, h, LColor::selection);
432 if ((startrow != row_ && !is_rtl) || (endrow != row_ && is_rtl))
433 pain_.fillRectangle(xo_, yo_, int(x_), row_->height(), LColor::selection);
435 pos_type const body_pos = pit_->beginningOfBody();
436 pos_type const last = lastPrintablePos(text_, row_);
439 for (pos_type vpos = row_->pos(); vpos <= last; ++vpos) {
440 pos_type pos = text_.vis2log(vpos);
441 int 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(text_, 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 != row_ || text_.selection.start.pos() <= pos) &&
469 (endrow != row_ || 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),
473 row_->height(), LColor::selection);
477 if ((startrow != row_ && is_rtl) || (endrow != row_ && !is_rtl)) {
478 pain_.fillRectangle(xo_ + int(tmpx),
479 yo_, int(bv_.workWidth() - tmpx),
480 row_->height(), LColor::selection);
485 void RowPainter::paintChangeBar()
487 pos_type const start = row_->pos();
488 pos_type const end = lastPrintablePos(text_, row_);
490 if (!pit_->isChanged(start, end))
493 int const height = (boost::next(row_) != text_.rows().end()
494 ? row_->height() + boost::next(row_)->top_of_text()
497 pain_.fillRectangle(4, yo_, 5, height, LColor::changebar);
501 void RowPainter::paintAppendix()
503 if (!pit_->params().appendix())
506 // FIXME: can be just width_ ?
507 int const ww = bv_.workWidth();
511 if (pit_->params().startOfAppendix())
512 y += 2 * defaultRowHeight();
514 pain_.line(1, y, 1, yo_ + row_->height(), LColor::appendix);
515 pain_.line(ww - 2, y, ww - 2, yo_ + row_->height(), LColor::appendix);
519 void RowPainter::paintDepthBar()
521 Paragraph::depth_type const depth = pit_->getDepth();
526 Paragraph::depth_type prev_depth = 0;
527 if (row_ != text_.rows().begin())
528 prev_depth = boost::prior(row_)->par()->getDepth();
529 Paragraph::depth_type next_depth = 0;
531 RowList::iterator next_row = boost::next(row_);
532 if (next_row != text_.rows().end())
533 next_depth = next_row->par()->getDepth();
535 for (Paragraph::depth_type i = 1; i <= depth; ++i) {
536 int x = (PAPER_MARGIN / 5) * 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);
544 int const w = PAPER_MARGIN / 5;
546 if (i > prev_depth) {
547 pain_.fillRectangle(x, yo_, w, 2, LColor::depthbar);
549 if (i > next_depth) {
550 pain_.fillRectangle(x, h, w, 2, LColor::depthbar);
556 int RowPainter::paintLengthMarker(string const & prefix, VSpace const & vsp, int start)
558 if (vsp.kind() == VSpace::NONE)
561 int const arrow_size = 4;
562 int const size = getLengthMarkerHeight(bv_, vsp);
563 int const end = start + size;
565 // the label to display (if any)
567 // y-values for top arrow
569 // y-values for bottom arrow
572 str = prefix + " (" + vsp.asLyXCommand() + ")";
574 if (vsp.kind() == VSpace::VFILL) {
578 // adding or removing space
579 bool const added = vsp.kind() != VSpace::LENGTH ||
580 vsp.length().len().value() > 0.0;
581 ty1 = added ? (start + arrow_size) : start;
582 ty2 = added ? start : (start + arrow_size);
583 by1 = added ? (end - arrow_size) : end;
584 by2 = added ? end : (end - arrow_size);
587 int const leftx = xo_ + leftMargin();
588 int const midx = leftx + arrow_size;
589 int const rightx = midx + arrow_size;
597 font.setColor(LColor::added_space).decSize().decSize();
598 font_metrics::rectText(str, font, w, a, d);
600 pain_.rectText(leftx + 2 * arrow_size + 5,
601 start + ((end - start) / 2) + d,
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::paintPageBreak(string const & label, int y)
622 pb_font.setColor(LColor::pagebreak).decSize();
627 font_metrics::rectText(label, pb_font, w, a, d);
629 int const text_start = xo_ + ((width_ - w) / 2);
630 int const text_end = text_start + w;
632 pain_.rectText(text_start, y + d, label, pb_font);
634 pain_.line(xo_, y, text_start, y,
635 LColor::pagebreak, Painter::line_onoffdash);
636 pain_.line(text_end, y, xo_ + width_, y,
637 LColor::pagebreak, Painter::line_onoffdash);
639 return 3 * defaultRowHeight();
643 int RowPainter::paintAppendixStart(int y)
646 pb_font.setColor(LColor::appendix).decSize();
648 string const label = _("Appendix");
652 font_metrics::rectText(label, pb_font, w, a, d);
654 int const text_start = xo_ + ((width_ - w) / 2);
655 int const text_end = text_start + w;
657 pain_.rectText(text_start, y + d, label, pb_font);
659 pain_.line(xo_ + 1, y, text_start, y, LColor::appendix);
660 pain_.line(text_end, y, xo_ + width_ - 2, y, LColor::appendix);
662 return 3 * defaultRowHeight();
666 void RowPainter::paintFirst()
668 ParagraphParameters const & parparams = pit_->params();
672 // start of appendix?
673 if (parparams.startOfAppendix()) {
674 y_top += paintAppendixStart(yo_ + y_top + 2 * defaultRowHeight());
678 if (row_ == text_.rows().begin() && !text_.isInInset())
679 y_top += PAPER_MARGIN;
681 // draw a top pagebreak
682 if (parparams.pagebreakTop()) {
683 y_top += paintPageBreak(_("Page Break (top)"),
684 yo_ + y_top + 2 * defaultRowHeight());
687 // draw the additional space if needed:
688 y_top += paintLengthMarker(_("Space above"), parparams.spaceTop(),
691 Buffer const * buffer = bv_.buffer();
693 LyXLayout_ptr const & layout = pit_->layout();
695 if (buffer->params.paragraph_separation == BufferParams::PARSEP_SKIP) {
696 if (pit_ != text_.ownerParagraphs().begin()) {
697 if (layout->latextype == LATEX_PARAGRAPH
698 && !pit_->getDepth()) {
699 y_top += buffer->params.getDefSkip().inPixels(bv_);
701 LyXLayout_ptr const & playout =
702 boost::prior(pit_)->layout();
703 if (playout->latextype == LATEX_PARAGRAPH
704 && !boost::prior(pit_)->getDepth()) {
705 // is it right to use defskip here, too? (AS)
706 y_top += buffer->params.getDefSkip().inPixels(bv_);
712 int const ww = bv_.workWidth();
715 if (parparams.lineTop()) {
716 LyXFont font(LyXFont::ALL_SANE);
717 int const asc = font_metrics::ascent('x', getFont(0));
721 int const w = (text_.isInInset() ? text_.inset_owner->width() : ww);
722 int const xp = static_cast<int>(text_.isInInset() ? xo_ : 0);
723 pain_.line(xp, yo_ + y_top, xp + w, yo_ + y_top,
724 LColor::topline, Painter::line_solid,
725 Painter::line_thick);
730 bool const is_rtl = pit_->isRightToLeftPar(bv_.buffer()->params);
732 // should we print a label?
733 if (layout->labeltype >= LABEL_STATIC
734 && (layout->labeltype != LABEL_STATIC
735 || layout->latextype != LATEX_ENVIRONMENT
736 || isFirstInSequence(pit_, text_.ownerParagraphs()))) {
738 LyXFont font = getLabelFont();
739 if (!pit_->getLabelstring().empty()) {
741 string const str = pit_->getLabelstring();
743 // this is special code for the chapter layout. This is
744 // printed in an extra row and has a pagebreak at
746 if (layout->labeltype == LABEL_COUNTER_CHAPTER) {
747 if (buffer->params.secnumdepth >= 0) {
748 float spacing_val = 1.0;
749 if (!parparams.spacing().isDefault()) {
750 spacing_val = parparams.spacing().getValue();
752 spacing_val = buffer->params.spacing.getValue();
756 int(font_metrics::maxDescent(font) * layout->spacing.getValue() * spacing_val)
757 + int(layout->parsep) * defaultRowHeight();
760 x = ww - leftMargin() -
761 font_metrics::width(str, font);
765 yo_ + row_->baseline() -
766 row_->ascent_of_text() - maxdesc,
771 x = ww - leftMargin()
772 + font_metrics::width(layout->labelsep, font);
774 x = x_ - font_metrics::width(layout->labelsep, font)
775 - font_metrics::width(str, font);
778 pain_.text(x, yo_ + row_->baseline(), str, font);
782 // the labels at the top of an environment.
783 // More or less for bibliography
784 } else if (isFirstInSequence(pit_, text_.ownerParagraphs()) &&
785 (layout->labeltype == LABEL_TOP_ENVIRONMENT ||
786 layout->labeltype == LABEL_BIBLIO ||
787 layout->labeltype == LABEL_CENTERED_TOP_ENVIRONMENT)) {
788 LyXFont font = getLabelFont();
789 if (!pit_->getLabelstring().empty()) {
790 string const str = pit_->getLabelstring();
791 float spacing_val = 1.0;
792 if (!parparams.spacing().isDefault()) {
793 spacing_val = parparams.spacing().getValue();
795 spacing_val = buffer->params.spacing.getValue();
799 int(font_metrics::maxDescent(font) * layout->spacing.getValue() * spacing_val
800 + (layout->labelbottomsep * defaultRowHeight()));
803 if (layout->labeltype == LABEL_CENTERED_TOP_ENVIRONMENT) {
804 x = ((is_rtl ? leftMargin() : x_)
805 + ww - text_.rightMargin(*bv_.buffer(), *row_)) / 2;
806 x -= font_metrics::width(str, font) / 2;
808 x = ww - leftMargin() -
809 font_metrics::width(str, font);
811 pain_.text(x, yo_ + row_->baseline()
812 - row_->ascent_of_text() - maxdesc,
819 void RowPainter::paintLast()
821 ParagraphParameters const & parparams = pit_->params();
822 int y_bottom = row_->height() - 1;
825 if (boost::next(row_) == text_.rows().end() && !text_.isInInset())
826 y_bottom -= PAPER_MARGIN;
828 int const ww = bv_.workWidth();
830 // draw a bottom pagebreak
831 if (parparams.pagebreakBottom()) {
832 y_bottom -= paintPageBreak(_("Page Break (bottom)"),
833 yo_ + y_bottom - 2 * defaultRowHeight());
836 // draw the additional space if needed:
837 int const height = getLengthMarkerHeight(bv_, parparams.spaceBottom());
838 y_bottom -= paintLengthMarker(_("Space below"), parparams.spaceBottom(),
839 yo_ + y_bottom - height);
841 // draw a bottom line
842 if (parparams.lineBottom()) {
843 LyXFont font(LyXFont::ALL_SANE);
844 int const asc = font_metrics::ascent('x',
845 getFont(max(pos_type(0), pit_->size() - 1)));
849 int const w = text_.isInInset() ? text_.inset_owner->width() : ww;
850 int const xp = static_cast<int>(text_.isInInset() ? xo_ : 0);
851 int const y = yo_ + y_bottom;
852 pain_.line(xp, y, xp + w, y, LColor::topline, Painter::line_solid,
853 Painter::line_thick);
858 bool const is_rtl = pit_->isRightToLeftPar(bv_.buffer()->params);
859 int const endlabel = getEndLabel(pit_, text_.ownerParagraphs());
864 case END_LABEL_FILLED_BOX:
866 LyXFont const font = getLabelFont();
867 int const size = int(0.75 * font_metrics::maxAscent(font));
868 int const y = (yo_ + row_->baseline()) - size;
869 int x = is_rtl ? LEFT_MARGIN : ww - PAPER_MARGIN - size;
871 if (row_->fill() <= size)
872 x += (size - row_->fill() + 1) * (is_rtl ? -1 : 1);
874 if (endlabel == END_LABEL_BOX) {
875 pain_.rectangle(x, y, size, size, LColor::eolmarker);
877 pain_.fillRectangle(x, y, size, size, LColor::eolmarker);
881 case END_LABEL_STATIC:
883 LyXFont font = getLabelFont();
884 string const & str = pit_->layout()->endlabelstring();
885 int const x = is_rtl ?
886 x_ - font_metrics::width(str, font)
887 : ww - text_.rightMargin(*bv_.buffer(), *row_) - row_->fill();
888 pain_.text(x, yo_ + row_->baseline(), str, font);
891 case END_LABEL_NO_LABEL:
897 void RowPainter::paintText()
899 pos_type const last = lastPrintablePos(text_, row_);
900 pos_type body_pos = pit_->beginningOfBody();
902 (body_pos - 1 > last ||
903 !pit_->isLineSeparator(body_pos - 1))) {
907 LyXLayout_ptr const & layout = pit_->layout();
909 bool running_strikeout = false;
910 bool is_struckout = false;
911 int last_strikeout_x = 0;
913 pos_type vpos = row_->pos();
914 while (vpos <= last) {
915 if (x_ > bv_.workWidth())
917 pos_type pos = text_.vis2log(vpos);
919 if (pos >= pit_->size()) {
924 if (x_ + singleWidth(pos) < 0) {
925 x_ += singleWidth(pos);
930 is_struckout = isDeletedText(*pit_, pos);
932 if (is_struckout && !running_strikeout) {
933 running_strikeout = true;
934 last_strikeout_x = x_;
937 bool const highly_editable_inset = pit_->isInset(pos)
938 && isHighlyEditableInset(pit_->getInset(pos));
940 // if we reach the end of a struck out range, paint it
941 // we also don't paint across things like tables
942 if (running_strikeout && (highly_editable_inset || !is_struckout)) {
943 int const middle = yo_ + row_->top_of_text()
944 + ((row_->baseline() - row_->top_of_text()) / 2);
945 pain_.line(last_strikeout_x, middle, x_, middle,
946 LColor::strikeout, Painter::line_solid, Painter::line_thin);
947 running_strikeout = false;
950 if (body_pos > 0 && pos == body_pos - 1) {
951 int const lwidth = font_metrics::width(layout->labelsep,
954 x_ += label_hfill_ + lwidth
955 - singleWidth(body_pos - 1);
958 if (pit_->isHfill(pos)) {
961 int const y0 = yo_ + row_->baseline();
962 int const y1 = y0 - defaultRowHeight() / 2;
964 pain_.line(x_, y1, x_, y0,
965 LColor::added_space);
967 if (hfillExpansion(text_, row_, pos)) {
968 int const y2 = (y0 + y1) / 2;
970 if (pos >= body_pos) {
971 pain_.line(x_, y2, x_ + hfill_, y2,
973 Painter::line_onoffdash);
977 x_ + label_hfill_, y2,
979 Painter::line_onoffdash);
982 pain_.line(x_, y1, x_, y0, LColor::added_space);
986 } else if (pit_->isSeparator(pos)) {
987 x_ += singleWidth(pos);
996 // if we reach the end of a struck out range, paint it
997 if (running_strikeout) {
998 int const middle = yo_ + row_->top_of_text()
999 + ((row_->baseline() - row_->top_of_text()) / 2);
1000 pain_.line(last_strikeout_x, middle, x_, middle,
1001 LColor::strikeout, Painter::line_solid, Painter::line_thin);
1002 running_strikeout = false;
1008 void RowPainter::paint()
1010 width_ = text_.workWidth();
1012 // FIXME: must be a cleaner way here. Aren't these calculations
1013 // belonging to row metrics ?
1014 text_.prepareToPrint(row_, x_, separator_, hfill_, label_hfill_);
1016 // FIXME: what is this fixing ?
1017 if (text_.isInInset() && x_ < 0)
1021 // If we're *not* at the top-level of rows, then the
1022 // background has already been cleared.
1023 if (&text_ == bv_.text)
1026 // paint the selection background
1027 if (text_.selection.set()) {
1031 // vertical lines for appendix
1034 // environment depth brackets
1040 if (row_->isParStart()) {
1044 if (isParEnd(text_, row_)) {
1056 int getLengthMarkerHeight(BufferView const & bv, VSpace const & vsp)
1058 if (vsp.kind() == VSpace::NONE)
1061 int const arrow_size = 4;
1062 int const space_size = vsp.inPixels(bv);
1066 int const min_size = max(3 * arrow_size,
1067 font_metrics::maxAscent(font)
1068 + font_metrics::maxDescent(font));
1070 if (vsp.length().len().value() < 0.0)
1073 return max(min_size, space_size);
1077 void paintRows(BufferView const & bv, LyXText const & text,
1078 RowList::iterator rit, int y_offset, int x_offset, int y)
1080 RowPainter painter(bv, text, rit, y_offset, x_offset, y);