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(float const 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 #warning inset->update FIXME
182 inset->update(perv(bv_), false);
184 PainterInfo pi(perv(bv_));
185 pi.base.font = getFont(pos);
186 int const w = inset->width(perv(bv_), pi.base.font);
187 inset->draw(pi, int(x_), yo_ + row_->baseline());
192 void RowPainter::paintHebrewComposeChar(pos_type & vpos)
194 pos_type pos = text_.vis2log(vpos);
199 char c = pit_->getChar(pos);
203 LyXFont const & font = getFont(pos);
204 int const width = font_metrics::width(c, font);
207 for (pos_type i = pos - 1; i >= 0; --i) {
208 c = pit_->getChar(i);
209 if (!Encodings::IsComposeChar_hebrew(c)) {
210 if (IsPrintableNonspace(c)) {
214 dx = (c == 'ø' || c == 'ã')
216 : (width2 - width) / 2;
223 pain_.text(int(x_) + dx, yo_ + row_->baseline(), str, font);
227 void RowPainter::paintArabicComposeChar(pos_type & vpos)
229 pos_type pos = text_.vis2log(vpos);
233 char c = pit_->getChar(pos);
234 c = transformChar(c, pos);
238 LyXFont const & font = getFont(pos);
239 int const width = font_metrics::width(c, font);
242 for (pos_type i = pos - 1; i >= 0; --i) {
243 c = pit_->getChar(i);
244 if (!Encodings::IsComposeChar_arabic(c)) {
245 if (IsPrintableNonspace(c)) {
248 dx = (width2 - width) / 2;
254 pain_.text(int(x_) + dx, yo_ + row_->baseline(), str, font);
258 void RowPainter::paintChars(pos_type & vpos, bool hebrew, bool arabic)
260 pos_type pos = text_.vis2log(vpos);
261 pos_type const last = lastPrintablePos(text_, row_);
262 LyXFont orig_font = getFont(pos);
266 str += pit_->getChar(pos);
268 unsigned char c = str[0];
269 str[0] = transformChar(c, pos);
272 bool prev_struckout(isDeletedText(*pit_, pos));
273 bool prev_newtext(isInsertedText(*pit_, pos));
277 // collect as much similar chars as we can
278 while (vpos <= last && (pos = text_.vis2log(vpos)) >= 0) {
279 char c = pit_->getChar(pos);
281 if (!IsPrintableNonspace(c))
284 if (prev_struckout != isDeletedText(*pit_, pos))
287 if (prev_newtext != isInsertedText(*pit_, pos))
290 if (arabic && Encodings::IsComposeChar_arabic(c))
292 if (hebrew && Encodings::IsComposeChar_hebrew(c))
295 if (orig_font != getFont(pos))
299 c = transformChar(c, pos);
304 if (prev_struckout) {
305 orig_font.setColor(LColor::strikeout);
306 } else if (prev_newtext) {
307 orig_font.setColor(LColor::newtext);
310 // Draw text and set the new x position
311 pain_.text(int(x_), yo_ + row_->baseline(), str, orig_font);
312 x_ += font_metrics::width(str, orig_font);
316 void RowPainter::paintForeignMark(float const orig_x, LyXFont const & orig_font)
318 if (!lyxrc.mark_foreign_language)
320 if (orig_font.language() == latex_language)
322 if (orig_font.language() == bv_.buffer()->params.language)
325 int const y = yo_ + row_->baseline() + 1;
326 pain_.line(int(orig_x), y, int(x_), y, LColor::language);
330 void RowPainter::paintFromPos(pos_type & vpos)
332 pos_type const pos = text_.vis2log(vpos);
334 LyXFont const & orig_font = getFont(pos);
336 float const orig_x = x_;
338 char const c = pit_->getChar(pos);
340 if (IsInsetChar(c)) {
343 paintForeignMark(orig_x, orig_font);
347 // usual characters, no insets
349 // special case languages
350 bool const hebrew = (orig_font.language()->lang() == "hebrew");
352 orig_font.language()->lang() == "arabic" &&
353 (lyxrc.font_norm_type == LyXRC::ISO_8859_6_8 ||
354 lyxrc.font_norm_type == LyXRC::ISO_10646_1);
356 // draw as many chars as we can
357 if ((!hebrew && !arabic)
358 || (hebrew && !Encodings::IsComposeChar_hebrew(c))
359 || (arabic && !Encodings::IsComposeChar_arabic(c))) {
360 paintChars(vpos, hebrew, arabic);
362 paintHebrewComposeChar(vpos);
364 paintArabicComposeChar(vpos);
367 paintForeignMark(orig_x, orig_font);
373 void RowPainter::paintBackground()
376 int const y = yo_ < 0 ? 0 : yo_;
377 int const h = yo_ < 0 ? row_->height() + yo_ : row_->height();
378 pain_.fillRectangle(x, y, width_, h, text_.backgroundColor());
382 void RowPainter::paintSelection()
384 bool const is_rtl = pit_->isRightToLeftPar(bv_.buffer()->params);
386 // the current selection
387 int const startx = text_.selection.start.x();
388 int const endx = text_.selection.end.x();
389 int const starty = text_.selection.start.y();
390 int const endy = text_.selection.end.y();
391 RowList::iterator startrow = text_.getRow(text_.selection.start);
392 RowList::iterator endrow = text_.getRow(text_.selection.end);
394 if (text_.bidi_same_direction) {
398 int h = row_->height();
400 if (startrow == row_ && endrow == row_) {
404 pain_.fillRectangle(x, y, w, h, LColor::selection);
408 pain_.fillRectangle(x, y, w, h, LColor::selection);
410 } else if (startrow == row_) {
411 int const x = (is_rtl) ? xo_ : (xo_ + startx);
412 int const w = (is_rtl) ? startx : (width_ - startx);
413 pain_.fillRectangle(x, y, w, h, LColor::selection);
414 } else if (endrow == row_) {
415 int const x = (is_rtl) ? (xo_ + endx) : xo_;
416 int const w = (is_rtl) ? (width_ - endx) : endx;
417 pain_.fillRectangle(x, y, w, h, LColor::selection);
418 } else if (y_ > starty && y_ < endy) {
419 pain_.fillRectangle(xo_, y, width_, h, LColor::selection);
422 } else if (startrow != row_ && endrow != row_) {
423 if (y_ > starty && y_ < endy) {
425 int h = row_->height();
426 pain_.fillRectangle(xo_, yo_, w, h, LColor::selection);
431 if ((startrow != row_ && !is_rtl) || (endrow != row_ && is_rtl))
432 pain_.fillRectangle(xo_, yo_, int(x_), row_->height(), LColor::selection);
434 pos_type const body_pos = pit_->beginningOfBody();
435 pos_type const last = lastPrintablePos(text_, row_);
438 for (pos_type vpos = row_->pos(); vpos <= last; ++vpos) {
439 pos_type pos = text_.vis2log(vpos);
440 float const old_tmpx = tmpx;
441 if (body_pos > 0 && pos == body_pos - 1) {
442 LyXLayout_ptr const & layout = pit_->layout();
443 LyXFont const lfont = getLabelFont();
445 tmpx += label_hfill_ + font_metrics::width(layout->labelsep, lfont);
447 if (pit_->isLineSeparator(body_pos - 1))
448 tmpx -= singleWidth(body_pos - 1);
451 if (hfillExpansion(text_, row_, pos)) {
452 tmpx += singleWidth(pos);
456 tmpx += label_hfill_;
459 else if (pit_->isSeparator(pos)) {
460 tmpx += singleWidth(pos);
464 tmpx += singleWidth(pos);
467 if ((startrow != row_ || text_.selection.start.pos() <= pos) &&
468 (endrow != row_ || pos < text_.selection.end.pos())) {
469 // Here we do not use x_ as xo_ was added to x_.
470 pain_.fillRectangle(int(old_tmpx), yo_,
471 int(tmpx - old_tmpx + 1),
472 row_->height(), LColor::selection);
476 if ((startrow != row_ && is_rtl) || (endrow != row_ && !is_rtl)) {
477 pain_.fillRectangle(xo_ + int(tmpx),
478 yo_, int(bv_.workWidth() - tmpx),
479 row_->height(), LColor::selection);
484 void RowPainter::paintChangeBar()
486 pos_type const start = row_->pos();
487 pos_type const end = lastPrintablePos(text_, row_);
489 if (!pit_->isChanged(start, end))
492 int const height = (boost::next(row_) != text_.rows().end()
493 ? row_->height() + boost::next(row_)->top_of_text()
496 pain_.fillRectangle(4, yo_, 5, height, LColor::changebar);
500 void RowPainter::paintAppendix()
502 if (!pit_->params().appendix())
505 // FIXME: can be just width_ ?
506 int const ww = bv_.workWidth();
510 if (pit_->params().startOfAppendix())
511 y += 2 * defaultRowHeight();
513 pain_.line(1, y, 1, yo_ + row_->height(), LColor::appendix);
514 pain_.line(ww - 2, y, ww - 2, yo_ + row_->height(), LColor::appendix);
518 void RowPainter::paintDepthBar()
520 Paragraph::depth_type const depth = pit_->getDepth();
525 Paragraph::depth_type prev_depth = 0;
526 if (row_ != text_.rows().begin())
527 prev_depth = boost::prior(row_)->par()->getDepth();
528 Paragraph::depth_type next_depth = 0;
530 RowList::iterator next_row = boost::next(row_);
531 if (next_row != text_.rows().end())
532 next_depth = next_row->par()->getDepth();
534 for (Paragraph::depth_type i = 1; i <= depth; ++i) {
535 int x = (PAPER_MARGIN / 5) * i + xo_;
536 // only consider the changebar space if we're drawing outer left
538 x += CHANGEBAR_MARGIN;
539 int const h = yo_ + row_->height() - 1 - (i - next_depth - 1) * 3;
541 pain_.line(x, yo_, x, h, LColor::depthbar);
543 int const w = PAPER_MARGIN / 5;
545 if (i > prev_depth) {
546 pain_.fillRectangle(x, yo_, w, 2, LColor::depthbar);
548 if (i > next_depth) {
549 pain_.fillRectangle(x, h, w, 2, LColor::depthbar);
555 int RowPainter::paintLengthMarker(string const & prefix, VSpace const & vsp, int start)
557 if (vsp.kind() == VSpace::NONE)
560 int const arrow_size = 4;
561 int const size = getLengthMarkerHeight(bv_, vsp);
562 int const end = start + size;
564 // the label to display (if any)
566 // y-values for top arrow
568 // y-values for bottom arrow
571 str = prefix + " (" + vsp.asLyXCommand() + ")";
573 if (vsp.kind() == VSpace::VFILL) {
577 // adding or removing space
578 bool const added = vsp.kind() != VSpace::LENGTH ||
579 vsp.length().len().value() > 0.0;
580 ty1 = added ? (start + arrow_size) : start;
581 ty2 = added ? start : (start + arrow_size);
582 by1 = added ? (end - arrow_size) : end;
583 by2 = added ? end : (end - arrow_size);
586 int const leftx = xo_ + leftMargin();
587 int const midx = leftx + arrow_size;
588 int const rightx = midx + arrow_size;
596 font.setColor(LColor::added_space).decSize().decSize();
597 font_metrics::rectText(str, font, w, a, d);
599 pain_.rectText(leftx + 2 * arrow_size + 5,
600 start + ((end - start) / 2) + d,
604 pain_.line(leftx, ty1, midx, ty2, LColor::added_space);
605 pain_.line(midx, ty2, rightx, ty1, LColor::added_space);
608 pain_.line(leftx, by1, midx, by2, LColor::added_space);
609 pain_.line(midx, by2, rightx, by1, LColor::added_space);
612 pain_.line(midx, ty2, midx, by2, LColor::added_space);
618 int RowPainter::paintPageBreak(string const & label, int y)
621 pb_font.setColor(LColor::pagebreak).decSize();
626 font_metrics::rectText(label, pb_font, w, a, d);
628 int const text_start = xo_ + ((width_ - w) / 2);
629 int const text_end = text_start + w;
631 pain_.rectText(text_start, y + d, label, pb_font);
633 pain_.line(xo_, y, text_start, y,
634 LColor::pagebreak, Painter::line_onoffdash);
635 pain_.line(text_end, y, xo_ + width_, y,
636 LColor::pagebreak, Painter::line_onoffdash);
638 return 3 * defaultRowHeight();
642 int RowPainter::paintAppendixStart(int y)
645 pb_font.setColor(LColor::appendix).decSize();
647 string const label = _("Appendix");
651 font_metrics::rectText(label, pb_font, w, a, d);
653 int const text_start = xo_ + ((width_ - w) / 2);
654 int const text_end = text_start + w;
656 pain_.rectText(text_start, y + d, label, pb_font);
658 pain_.line(xo_ + 1, y, text_start, y, LColor::appendix);
659 pain_.line(text_end, y, xo_ + width_ - 2, y, LColor::appendix);
661 return 3 * defaultRowHeight();
665 void RowPainter::paintFirst()
667 ParagraphParameters const & parparams = pit_->params();
671 // start of appendix?
672 if (parparams.startOfAppendix()) {
673 y_top += paintAppendixStart(yo_ + y_top + 2 * defaultRowHeight());
677 if (row_ == text_.rows().begin() && !text_.isInInset())
678 y_top += PAPER_MARGIN;
680 // draw a top pagebreak
681 if (parparams.pagebreakTop()) {
682 y_top += paintPageBreak(_("Page Break (top)"),
683 yo_ + y_top + 2 * defaultRowHeight());
686 // draw the additional space if needed:
687 y_top += paintLengthMarker(_("Space above"), parparams.spaceTop(),
690 Buffer const * buffer = bv_.buffer();
692 LyXLayout_ptr const & layout = pit_->layout();
694 if (buffer->params.paragraph_separation == BufferParams::PARSEP_SKIP) {
695 if (pit_ != text_.ownerParagraphs().begin()) {
696 if (layout->latextype == LATEX_PARAGRAPH
697 && !pit_->getDepth()) {
698 y_top += buffer->params.getDefSkip().inPixels(bv_);
700 LyXLayout_ptr const & playout =
701 boost::prior(pit_)->layout();
702 if (playout->latextype == LATEX_PARAGRAPH
703 && !boost::prior(pit_)->getDepth()) {
704 // is it right to use defskip here, too? (AS)
705 y_top += buffer->params.getDefSkip().inPixels(bv_);
711 int const ww = bv_.workWidth();
714 if (parparams.lineTop()) {
715 LyXFont font(LyXFont::ALL_SANE);
716 int const asc = font_metrics::ascent('x', getFont(0));
720 int const w = (text_.isInInset() ? text_.inset_owner->width(perv(bv_), font) : ww);
721 int const xp = static_cast<int>(text_.isInInset() ? xo_ : 0);
722 pain_.line(xp, yo_ + y_top, xp + w, yo_ + y_top,
723 LColor::topline, Painter::line_solid,
724 Painter::line_thick);
729 bool const is_rtl = pit_->isRightToLeftPar(bv_.buffer()->params);
731 // should we print a label?
732 if (layout->labeltype >= LABEL_STATIC
733 && (layout->labeltype != LABEL_STATIC
734 || layout->latextype != LATEX_ENVIRONMENT
735 || isFirstInSequence(pit_, text_.ownerParagraphs()))) {
737 LyXFont font = getLabelFont();
738 if (!pit_->getLabelstring().empty()) {
740 string const str = pit_->getLabelstring();
742 // this is special code for the chapter layout. This is
743 // printed in an extra row and has a pagebreak at
745 if (layout->labeltype == LABEL_COUNTER_CHAPTER) {
746 if (buffer->params.secnumdepth >= 0) {
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 + int(layout->parsep) * defaultRowHeight();
759 x = ww - leftMargin() -
760 font_metrics::width(str, font);
764 yo_ + row_->baseline() -
765 row_->ascent_of_text() - maxdesc,
770 x = ww - leftMargin()
771 + font_metrics::width(layout->labelsep, font);
773 x = x_ - font_metrics::width(layout->labelsep, font)
774 - font_metrics::width(str, font);
777 pain_.text(int(x), yo_ + row_->baseline(), str, font);
781 // the labels at the top of an environment.
782 // More or less for bibliography
783 } else if (isFirstInSequence(pit_, text_.ownerParagraphs()) &&
784 (layout->labeltype == LABEL_TOP_ENVIRONMENT ||
785 layout->labeltype == LABEL_BIBLIO ||
786 layout->labeltype == LABEL_CENTERED_TOP_ENVIRONMENT)) {
787 LyXFont font = getLabelFont();
788 if (!pit_->getLabelstring().empty()) {
789 string const str = pit_->getLabelstring();
790 float spacing_val = 1.0;
791 if (!parparams.spacing().isDefault()) {
792 spacing_val = parparams.spacing().getValue();
794 spacing_val = buffer->params.spacing.getValue();
798 int(font_metrics::maxDescent(font) * layout->spacing.getValue() * spacing_val
799 + (layout->labelbottomsep * defaultRowHeight()));
802 if (layout->labeltype == LABEL_CENTERED_TOP_ENVIRONMENT) {
803 x = ((is_rtl ? leftMargin() : x_)
804 + ww - text_.rightMargin(*bv_.buffer(), *row_)) / 2;
805 x -= font_metrics::width(str, font) / 2;
807 x = ww - leftMargin() -
808 font_metrics::width(str, font);
810 pain_.text(int(x), yo_ + row_->baseline()
811 - row_->ascent_of_text() - maxdesc,
818 void RowPainter::paintLast()
820 ParagraphParameters const & parparams = pit_->params();
821 int y_bottom = row_->height() - 1;
824 if (boost::next(row_) == text_.rows().end() && !text_.isInInset())
825 y_bottom -= PAPER_MARGIN;
827 int const ww = bv_.workWidth();
829 // draw a bottom pagebreak
830 if (parparams.pagebreakBottom()) {
831 y_bottom -= paintPageBreak(_("Page Break (bottom)"),
832 yo_ + y_bottom - 2 * defaultRowHeight());
835 // draw the additional space if needed:
836 int const height = getLengthMarkerHeight(bv_, parparams.spaceBottom());
837 y_bottom -= paintLengthMarker(_("Space below"), parparams.spaceBottom(),
838 yo_ + y_bottom - height);
840 // draw a bottom line
841 if (parparams.lineBottom()) {
842 LyXFont font(LyXFont::ALL_SANE);
843 int const asc = font_metrics::ascent('x',
844 getFont(max(pos_type(0), pit_->size() - 1)));
848 int const w = (text_.isInInset() ? text_.inset_owner->width(perv(bv_), font) : ww);
849 int const xp = static_cast<int>(text_.isInInset() ? xo_ : 0);
850 int const y = yo_ + y_bottom;
851 pain_.line(xp, y, xp + w, y, LColor::topline, Painter::line_solid,
852 Painter::line_thick);
857 bool const is_rtl = pit_->isRightToLeftPar(bv_.buffer()->params);
858 int const endlabel = getEndLabel(pit_, text_.ownerParagraphs());
863 case END_LABEL_FILLED_BOX:
865 LyXFont const font = getLabelFont();
866 int const size = int(0.75 * font_metrics::maxAscent(font));
867 int const y = (yo_ + row_->baseline()) - size;
868 int x = is_rtl ? LEFT_MARGIN : ww - PAPER_MARGIN - size;
870 if (row_->fill() <= size)
871 x += (size - row_->fill() + 1) * (is_rtl ? -1 : 1);
873 if (endlabel == END_LABEL_BOX) {
874 pain_.rectangle(x, y, size, size, LColor::eolmarker);
876 pain_.fillRectangle(x, y, size, size, LColor::eolmarker);
880 case END_LABEL_STATIC:
882 LyXFont font = getLabelFont();
883 string const & str = pit_->layout()->endlabelstring();
884 int const x = is_rtl ?
885 int(x_) - font_metrics::width(str, font)
886 : ww - text_.rightMargin(*bv_.buffer(), *row_) - row_->fill();
887 pain_.text(x, yo_ + row_->baseline(), str, font);
890 case END_LABEL_NO_LABEL:
896 void RowPainter::paintText()
898 pos_type const last = lastPrintablePos(text_, row_);
899 pos_type body_pos = pit_->beginningOfBody();
901 (body_pos - 1 > last ||
902 !pit_->isLineSeparator(body_pos - 1))) {
906 LyXLayout_ptr const & layout = pit_->layout();
908 bool running_strikeout = false;
909 bool is_struckout = false;
910 float last_strikeout_x = 0.0;
912 pos_type vpos = row_->pos();
913 while (vpos <= last) {
914 if (x_ > bv_.workWidth())
916 pos_type pos = text_.vis2log(vpos);
918 if (pos >= pit_->size()) {
923 if (x_ + singleWidth(pos) < 0) {
924 x_ += singleWidth(pos);
929 is_struckout = isDeletedText(*pit_, pos);
931 if (is_struckout && !running_strikeout) {
932 running_strikeout = true;
933 last_strikeout_x = x_;
936 bool const highly_editable_inset = pit_->isInset(pos)
937 && isHighlyEditableInset(pit_->getInset(pos));
939 // if we reach the end of a struck out range, paint it
940 // we also don't paint across things like tables
941 if (running_strikeout && (highly_editable_inset || !is_struckout)) {
942 int const middle = yo_ + row_->top_of_text()
943 + ((row_->baseline() - row_->top_of_text()) / 2);
944 pain_.line(int(last_strikeout_x), middle, int(x_), middle,
945 LColor::strikeout, Painter::line_solid, Painter::line_thin);
946 running_strikeout = false;
949 if (body_pos > 0 && pos == body_pos - 1) {
950 int const lwidth = font_metrics::width(layout->labelsep,
953 x_ += label_hfill_ + lwidth
954 - singleWidth(body_pos - 1);
957 if (pit_->isHfill(pos)) {
960 int const y0 = yo_ + row_->baseline();
961 int const y1 = y0 - defaultRowHeight() / 2;
963 pain_.line(int(x_), y1, int(x_), y0,
964 LColor::added_space);
966 if (hfillExpansion(text_, row_, pos)) {
967 int const y2 = (y0 + y1) / 2;
969 if (pos >= body_pos) {
970 pain_.line(int(x_), y2,
971 int(x_ + hfill_), y2,
973 Painter::line_onoffdash);
976 pain_.line(int(x_), y2,
977 int(x_ + label_hfill_), y2,
979 Painter::line_onoffdash);
982 pain_.line(int(x_), y1,
984 LColor::added_space);
988 } else if (pit_->isSeparator(pos)) {
989 x_ += singleWidth(pos);
998 // if we reach the end of a struck out range, paint it
999 if (running_strikeout) {
1000 int const middle = yo_ + row_->top_of_text()
1001 + ((row_->baseline() - row_->top_of_text()) / 2);
1002 pain_.line(int(last_strikeout_x), middle, int(x_), middle,
1003 LColor::strikeout, Painter::line_solid, Painter::line_thin);
1004 running_strikeout = false;
1010 void RowPainter::paint()
1012 width_ = text_.isInInset()
1013 ? text_.inset_owner->textWidth(perv(bv_), true) : bv_.workWidth();
1015 // FIXME: must be a cleaner way here. Aren't these calculations
1016 // belonging to row metrics ?
1017 text_.prepareToPrint(row_, x_, separator_, hfill_, label_hfill_);
1019 // FIXME: what is this fixing ?
1020 if (text_.isInInset() && (x_ < 0))
1024 // If we're *not* at the top-level of rows, then the
1025 // background has already been cleared.
1026 if (&text_ == bv_.text)
1029 // paint the selection background
1030 if (text_.selection.set()) {
1034 // vertical lines for appendix
1037 // environment depth brackets
1043 if (row_->isParStart()) {
1047 if (isParEnd(text_, row_)) {
1059 int getLengthMarkerHeight(BufferView const & bv, VSpace const & vsp)
1061 if (vsp.kind() == VSpace::NONE)
1064 int const arrow_size = 4;
1065 int const space_size = int(vsp.inPixels(bv));
1069 int const min_size = max(3 * arrow_size,
1070 font_metrics::maxAscent(font)
1071 + font_metrics::maxDescent(font));
1073 if (vsp.length().len().value() < 0.0)
1076 return max(min_size, space_size);
1080 void paintRows(BufferView const & bv, LyXText const & text,
1081 RowList::iterator rit, int y_offset, int x_offset, int y)
1083 RowPainter painter(bv, text, rit, y_offset, x_offset, y);