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"
25 #include "BufferView.h"
31 #include "rowpainter.h"
33 #include "lyxrow_funcs.h"
34 #include "metricsinfo.h"
38 using namespace lyx::support;
44 extern int PAPER_MARGIN;
45 extern int CHANGEBAR_MARGIN;
46 extern int LEFT_MARGIN;
50 // "temporary". We'll never get to use more
51 // references until we start adding hacks like
52 // these until other places catch up.
53 BufferView * perv(BufferView const & bv)
55 return const_cast<BufferView *>(&bv);
59 * A class used for painting an individual row of text.
63 /// initialise painter
64 RowPainter(BufferView const & bv, LyXText const & text,
65 ParagraphList::iterator pit,
66 RowList::iterator rit, int y_offset, int x_offset, int y);
71 // paint various parts
72 void paintBackground();
73 void paintSelection();
76 void paintChangeBar();
79 void paintForeignMark(double orig_x, LyXFont const & orig_font);
80 void paintHebrewComposeChar(lyx::pos_type & vpos);
81 void paintArabicComposeChar(lyx::pos_type & vpos);
82 void paintChars(lyx::pos_type & vpos, bool hebrew, bool arabic);
83 int paintPageBreak(string const & label, int y);
84 int paintAppendixStart(int y);
85 int paintLengthMarker(string const & prefix, VSpace const & vsp, int start);
87 void paintFromPos(lyx::pos_type & vpos);
88 void paintInset(lyx::pos_type const pos);
90 /// return left margin
91 int leftMargin() const;
93 /// return the font at the given pos
94 LyXFont const getFont(lyx::pos_type pos) const;
96 /// return the label font for this row
97 LyXFont const getLabelFont() const;
99 char const transformChar(char c, lyx::pos_type pos) const;
101 /// return pixel width for the given pos
102 int singleWidth(lyx::pos_type pos) const;
103 int singleWidth(lyx::pos_type pos, char c) const;
105 /// bufferview to paint on
106 BufferView const & bv_;
111 /// LyXText for the row
112 LyXText const & text_;
115 RowList::iterator row_;
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), row_(rit),
136 pit_(pit), xo_(x_offset), yo_(y_offset), y_(y)
141 LyXFont const RowPainter::getFont(pos_type pos) const
143 return text_.getFont(pit_, pos);
147 int RowPainter::singleWidth(lyx::pos_type pos) const
149 return text_.singleWidth(pit_, pos);
153 int RowPainter::singleWidth(lyx::pos_type pos, char c) const
155 return text_.singleWidth(pit_, pos, c);
159 LyXFont const RowPainter::getLabelFont() const
161 return text_.getLabelFont(pit_);
165 char const RowPainter::transformChar(char c, lyx::pos_type pos) const
167 return text_.transformChar(c, *pit_, pos);
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_.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)) {
212 dx = (c == 'ø' || c == 'ã')
214 : (width2 - width) / 2;
221 pain_.text(int(x_) + dx, yo_ + row_->baseline(), str, font);
225 void RowPainter::paintArabicComposeChar(pos_type & vpos)
227 pos_type pos = text_.vis2log(vpos);
231 char c = pit_->getChar(pos);
232 c = transformChar(c, pos);
236 LyXFont const & font = getFont(pos);
237 int const width = font_metrics::width(c, font);
240 for (pos_type i = pos - 1; i >= 0; --i) {
241 c = pit_->getChar(i);
242 if (!Encodings::IsComposeChar_arabic(c)) {
243 if (IsPrintableNonspace(c)) {
246 dx = (width2 - width) / 2;
252 pain_.text(int(x_) + dx, yo_ + row_->baseline(), str, font);
256 void RowPainter::paintChars(pos_type & vpos, bool hebrew, bool arabic)
258 pos_type pos = text_.vis2log(vpos);
259 pos_type const last = lastPrintablePos(*pit_, row_);
260 LyXFont orig_font = getFont(pos);
264 str += pit_->getChar(pos);
266 unsigned char c = str[0];
267 str[0] = transformChar(c, pos);
270 bool prev_struckout(isDeletedText(*pit_, pos));
271 bool prev_newtext(isInsertedText(*pit_, pos));
275 // collect as much similar chars as we can
276 while (vpos <= last && (pos = text_.vis2log(vpos)) >= 0) {
277 char c = pit_->getChar(pos);
279 if (!IsPrintableNonspace(c))
282 if (prev_struckout != isDeletedText(*pit_, pos))
285 if (prev_newtext != isInsertedText(*pit_, pos))
288 if (arabic && Encodings::IsComposeChar_arabic(c))
290 if (hebrew && Encodings::IsComposeChar_hebrew(c))
293 if (orig_font != getFont(pos))
297 c = transformChar(c, pos);
302 if (prev_struckout) {
303 orig_font.setColor(LColor::strikeout);
304 } else if (prev_newtext) {
305 orig_font.setColor(LColor::newtext);
308 // Draw text and set the new x position
309 //lyxerr << "paint row: yo_ " << yo_ << " baseline: " << row_->baseline()
311 pain_.text(int(x_), yo_ + row_->baseline(), str, orig_font);
312 x_ += font_metrics::width(str, orig_font);
316 void RowPainter::paintForeignMark(double 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 double 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()
375 int const x = int(xo_);
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_) {
402 x = int(xo_) + startx;
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 ? int(xo_) : int(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 ? int(xo_ + endx) : int(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(int(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(int(xo_), yo_, w, h, LColor::selection);
431 if ((startrow != row_ && !is_rtl) || (endrow != row_ && is_rtl))
432 pain_.fillRectangle(int(xo_), yo_,
433 int(x_), row_->height(), LColor::selection);
435 pos_type const body_pos = pit_->beginningOfBody();
436 pos_type const last = lastPrintablePos(*pit_, row_);
439 for (pos_type vpos = row_->pos(); vpos <= last; ++vpos) {
440 pos_type pos = text_.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 != 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(int(xo_ + 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(*pit_, row_);
490 if (!pit_->isChanged(start, end))
493 int const height = (row_ == text_.lastRow())
495 : 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_.firstRow()) {
528 ParagraphList::iterator pit2 = pit_;
529 if (row_ == pit2->rows.begin())
531 prev_depth = pit2->getDepth();
534 Paragraph::depth_type next_depth = 0;
535 if (row_ != text_.lastRow()) {
536 ParagraphList::iterator pit2 = pit_;
537 if (boost::next(row_) == pit2->rows.end())
539 next_depth = pit2->getDepth();
542 for (Paragraph::depth_type i = 1; i <= depth; ++i) {
543 int const w = PAPER_MARGIN / 5;
544 int x = int(w * i + xo_);
545 // only consider the changebar space if we're drawing outer left
547 x += CHANGEBAR_MARGIN;
548 int const h = yo_ + row_->height() - 1 - (i - next_depth - 1) * 3;
550 pain_.line(x, yo_, x, h, LColor::depthbar);
553 pain_.fillRectangle(x, yo_, w, 2, LColor::depthbar);
555 pain_.fillRectangle(x, h, w, 2, LColor::depthbar);
560 int RowPainter::paintLengthMarker(string const & prefix, VSpace const & vsp, int start)
562 if (vsp.kind() == VSpace::NONE)
565 int const arrow_size = 4;
566 int const size = getLengthMarkerHeight(bv_, vsp);
567 int const end = start + size;
569 // the label to display (if any)
571 // y-values for top arrow
573 // y-values for bottom arrow
576 str = prefix + " (" + vsp.asLyXCommand() + ")";
578 if (vsp.kind() == VSpace::VFILL) {
582 // adding or removing space
583 bool const added = vsp.kind() != VSpace::LENGTH ||
584 vsp.length().len().value() > 0.0;
585 ty1 = added ? (start + arrow_size) : start;
586 ty2 = added ? start : (start + arrow_size);
587 by1 = added ? (end - arrow_size) : end;
588 by2 = added ? end : (end - arrow_size);
591 int const leftx = int(xo_) + leftMargin();
592 int const midx = leftx + arrow_size;
593 int const rightx = midx + arrow_size;
601 font.setColor(LColor::added_space).decSize().decSize();
602 font_metrics::rectText(str, font, w, a, d);
604 pain_.rectText(leftx + 2 * arrow_size + 5,
605 start + ((end - start) / 2) + d,
609 pain_.line(leftx, ty1, midx, ty2, LColor::added_space);
610 pain_.line(midx, ty2, rightx, ty1, LColor::added_space);
613 pain_.line(leftx, by1, midx, by2, LColor::added_space);
614 pain_.line(midx, by2, rightx, by1, LColor::added_space);
617 pain_.line(midx, ty2, midx, by2, LColor::added_space);
623 int RowPainter::paintPageBreak(string const & label, int y)
626 pb_font.setColor(LColor::pagebreak).decSize();
631 font_metrics::rectText(label, pb_font, w, a, d);
633 int const text_start = int(xo_ + (width_ - w) / 2);
634 int const text_end = text_start + w;
636 pain_.rectText(text_start, y + d, label, pb_font);
638 pain_.line(int(xo_), y, text_start, y,
639 LColor::pagebreak, Painter::line_onoffdash);
640 pain_.line(text_end, y, int(xo_ + width_), y,
641 LColor::pagebreak, Painter::line_onoffdash);
643 return 3 * defaultRowHeight();
647 int RowPainter::paintAppendixStart(int y)
650 pb_font.setColor(LColor::appendix).decSize();
652 string const label = _("Appendix");
656 font_metrics::rectText(label, pb_font, w, a, d);
658 int const text_start = int(xo_ + (width_ - w) / 2);
659 int const text_end = text_start + w;
661 pain_.rectText(text_start, y + d, label, pb_font);
663 pain_.line(int(xo_ + 1), y, text_start, y, LColor::appendix);
664 pain_.line(text_end, y, int(xo_ + width_ - 2), y, LColor::appendix);
666 return 3 * defaultRowHeight();
670 void RowPainter::paintFirst()
672 ParagraphParameters const & parparams = pit_->params();
676 // start of appendix?
677 if (parparams.startOfAppendix())
678 y_top += paintAppendixStart(yo_ + y_top + 2 * defaultRowHeight());
681 if (row_ == text_.firstRow() && !text_.isInInset())
682 y_top += PAPER_MARGIN;
684 // draw a top pagebreak
685 if (parparams.pagebreakTop())
686 y_top += paintPageBreak(_("Page Break (top)"),
687 yo_ + y_top + 2 * defaultRowHeight());
689 // draw the additional space if needed:
690 y_top += paintLengthMarker(_("Space above"), parparams.spaceTop(),
693 Buffer const * buffer = bv_.buffer();
695 LyXLayout_ptr const & layout = pit_->layout();
697 if (buffer->params.paragraph_separation == BufferParams::PARSEP_SKIP) {
698 if (pit_ != text_.ownerParagraphs().begin()) {
699 if (layout->latextype == LATEX_PARAGRAPH
700 && !pit_->getDepth()) {
701 y_top += buffer->params.getDefSkip().inPixels(bv_);
703 LyXLayout_ptr const & playout =
704 boost::prior(pit_)->layout();
705 if (playout->latextype == LATEX_PARAGRAPH
706 && !boost::prior(pit_)->getDepth()) {
707 // is it right to use defskip here, too? (AS)
708 y_top += buffer->params.getDefSkip().inPixels(bv_);
714 int const ww = bv_.workWidth();
717 if (parparams.lineTop()) {
718 int const asc = font_metrics::ascent('x', getFont(0));
722 int const w = (text_.isInInset() ? text_.inset_owner->width() : ww);
723 int const xp = static_cast<int>(text_.isInInset() ? xo_ : 0);
724 pain_.line(xp, yo_ + y_top, xp + w, yo_ + y_top,
725 LColor::topline, Painter::line_solid,
726 Painter::line_thick);
731 bool const is_rtl = pit_->isRightToLeftPar(bv_.buffer()->params);
733 // should we print a label?
734 if (layout->labeltype >= LABEL_STATIC
735 && (layout->labeltype != LABEL_STATIC
736 || layout->latextype != LATEX_ENVIRONMENT
737 || isFirstInSequence(pit_, text_.ownerParagraphs()))) {
739 LyXFont font = getLabelFont();
740 if (!pit_->getLabelstring().empty()) {
742 string const str = pit_->getLabelstring();
744 // this is special code for the chapter layout. This is
745 // printed in an extra row and has a pagebreak at
747 if (layout->labeltype == LABEL_COUNTER_CHAPTER) {
748 if (buffer->params.secnumdepth >= 0) {
749 float spacing_val = 1.0;
750 if (!parparams.spacing().isDefault()) {
751 spacing_val = parparams.spacing().getValue();
753 spacing_val = buffer->params.spacing.getValue();
757 int(font_metrics::maxDescent(font) * layout->spacing.getValue() * spacing_val)
758 + int(layout->parsep) * defaultRowHeight();
761 x = ww - leftMargin() -
762 font_metrics::width(str, font);
766 yo_ + row_->baseline() -
767 row_->ascent_of_text() - maxdesc,
772 x = ww - leftMargin()
773 + font_metrics::width(layout->labelsep, font);
775 x = x_ - font_metrics::width(layout->labelsep, font)
776 - font_metrics::width(str, font);
779 pain_.text(int(x), yo_ + row_->baseline(), str, font);
783 // the labels at the top of an environment.
784 // More or less for bibliography
785 } else if (isFirstInSequence(pit_, text_.ownerParagraphs()) &&
786 (layout->labeltype == LABEL_TOP_ENVIRONMENT ||
787 layout->labeltype == LABEL_BIBLIO ||
788 layout->labeltype == LABEL_CENTERED_TOP_ENVIRONMENT)) {
789 LyXFont font = getLabelFont();
790 if (!pit_->getLabelstring().empty()) {
791 string const str = pit_->getLabelstring();
792 float spacing_val = 1.0;
793 if (!parparams.spacing().isDefault()) {
794 spacing_val = parparams.spacing().getValue();
796 spacing_val = buffer->params.spacing.getValue();
800 int(font_metrics::maxDescent(font) * layout->spacing.getValue() * spacing_val
801 + (layout->labelbottomsep * defaultRowHeight()));
804 if (layout->labeltype == LABEL_CENTERED_TOP_ENVIRONMENT) {
805 x = ((is_rtl ? leftMargin() : x_)
806 + ww - text_.rightMargin(pit_, *bv_.buffer(), *row_)) / 2;
807 x -= font_metrics::width(str, font) / 2;
809 x = ww - leftMargin() -
810 font_metrics::width(str, font);
813 yo_ + row_->baseline() - row_->ascent_of_text() - maxdesc,
820 void RowPainter::paintLast()
822 ParagraphParameters const & parparams = pit_->params();
823 int y_bottom = row_->height() - 1;
826 if (row_ == text_.lastRow() && !text_.isInInset())
827 y_bottom -= PAPER_MARGIN;
829 int const ww = bv_.workWidth();
831 // draw a bottom pagebreak
832 if (parparams.pagebreakBottom()) {
833 y_bottom -= paintPageBreak(_("Page Break (bottom)"),
834 yo_ + y_bottom - 2 * defaultRowHeight());
837 // draw the additional space if needed:
838 int const height = getLengthMarkerHeight(bv_, parparams.spaceBottom());
839 y_bottom -= paintLengthMarker(_("Space below"), parparams.spaceBottom(),
840 yo_ + y_bottom - height);
842 // draw a bottom line
843 if (parparams.lineBottom()) {
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 = 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);
880 case END_LABEL_STATIC:
882 LyXFont font = getLabelFont();
883 string const & str = pit_->layout()->endlabelstring();
884 double const x = is_rtl ?
885 x_ - font_metrics::width(str, font)
886 : ww - text_.rightMargin(pit_, *bv_.buffer(), *row_) - row_->fill();
887 pain_.text(int(x), yo_ + row_->baseline(), str, font);
890 case END_LABEL_NO_LABEL:
896 void RowPainter::paintText()
898 pos_type const last = lastPrintablePos(*pit_, row_);
899 pos_type body_pos = pit_->beginningOfBody();
901 (body_pos - 1 > last || !pit_->isLineSeparator(body_pos - 1))) {
905 LyXLayout_ptr const & layout = pit_->layout();
907 bool running_strikeout = false;
908 bool is_struckout = false;
909 int last_strikeout_x = 0;
911 pos_type vpos = row_->pos();
912 while (vpos <= last) {
913 if (x_ > bv_.workWidth())
915 pos_type pos = text_.vis2log(vpos);
917 if (pos >= pit_->size()) {
922 if (x_ + singleWidth(pos) < 0) {
923 x_ += singleWidth(pos);
928 is_struckout = isDeletedText(*pit_, pos);
930 if (is_struckout && !running_strikeout) {
931 running_strikeout = true;
932 last_strikeout_x = int(x_);
935 bool const highly_editable_inset = pit_->isInset(pos)
936 && isHighlyEditableInset(pit_->getInset(pos));
938 // if we reach the end of a struck out range, paint it
939 // we also don't paint across things like tables
940 if (running_strikeout && (highly_editable_inset || !is_struckout)) {
941 int const middle = yo_ + row_->top_of_text()
942 + (row_->baseline() - row_->top_of_text()) / 2;
943 pain_.line(last_strikeout_x, middle, int(x_), middle,
944 LColor::strikeout, Painter::line_solid, Painter::line_thin);
945 running_strikeout = false;
948 if (body_pos > 0 && pos == body_pos - 1) {
949 int const lwidth = font_metrics::width(layout->labelsep,
952 x_ += label_hfill_ + lwidth - singleWidth(body_pos - 1);
955 if (pit_->isHfill(pos)) {
958 int const y0 = yo_ + row_->baseline();
959 int const y1 = y0 - defaultRowHeight() / 2;
961 pain_.line(int(x_), y1, int(x_), y0, LColor::added_space);
963 if (hfillExpansion(*pit_, row_, pos)) {
964 int const y2 = (y0 + y1) / 2;
966 if (pos >= body_pos) {
967 pain_.line(int(x_), y2, int(x_ + hfill_), y2,
969 Painter::line_onoffdash);
972 pain_.line(int(x_), y2, int(x_ + label_hfill_), y2,
974 Painter::line_onoffdash);
977 pain_.line(int(x_), y1, int(x_), y0, LColor::added_space);
981 } else if (pit_->isSeparator(pos)) {
982 x_ += singleWidth(pos);
991 // if we reach the end of a struck out range, paint it
992 if (running_strikeout) {
993 int const middle = yo_ + row_->top_of_text()
994 + ((row_->baseline() - row_->top_of_text()) / 2);
995 pain_.line(last_strikeout_x, middle, int(x_), middle,
996 LColor::strikeout, Painter::line_solid, Painter::line_thin);
997 running_strikeout = false;
1002 void RowPainter::paint()
1004 width_ = text_.workWidth();
1006 // FIXME: must be a cleaner way here. Aren't these calculations
1007 // belonging to row metrics ?
1008 text_.prepareToPrint(pit_, row_, x_, separator_, hfill_, label_hfill_);
1010 // FIXME: what is this fixing ?
1011 if (text_.isInInset() && x_ < 0)
1015 // If we're *not* at the top-level of rows, then the
1016 // background has already been cleared.
1017 if (&text_ == bv_.text)
1020 // paint the selection background
1021 if (text_.selection.set())
1024 // vertical lines for appendix
1027 // environment depth brackets
1033 if (row_->isParStart())
1036 if (isParEnd(*pit_, row_))
1047 int getLengthMarkerHeight(BufferView const & bv, VSpace const & vsp)
1049 if (vsp.kind() == VSpace::NONE)
1052 int const arrow_size = 4;
1053 int const space_size = vsp.inPixels(bv);
1057 int const min_size = max(3 * arrow_size,
1058 font_metrics::maxAscent(font)
1059 + font_metrics::maxDescent(font));
1061 if (vsp.length().len().value() < 0.0)
1064 return max(min_size, space_size);
1068 int paintRows(BufferView const & bv, LyXText const & text,
1069 ParagraphList::iterator pit, RowList::iterator rit,
1070 int xo, int y, int yf, int yo)
1072 lyxerr << " paintRows: rit: " << &*rit << endl;
1073 const_cast<LyXText&>(text).updateRowPositions();
1074 int const yy = yf - y;
1075 int const y2 = bv.painter().paperHeight();
1077 ParagraphList::iterator end = text.ownerParagraphs().end();
1078 bool active = false;
1080 for ( ; pit != end; ++pit) {
1081 RowList::iterator row = pit->rows.begin();
1082 RowList::iterator rend = pit->rows.end();
1084 for ( ; row != rend; ++row) {
1088 RowPainter painter(bv, text, pit, row, y + yo, xo, y + text.top_y());
1094 //lyxerr << " paintRows: row: " << &*row << " ignored" << endl;