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
16 #include "frontends/Painter.h"
17 #include "frontends/screen.h"
18 #include "frontends/font_metrics.h"
19 #include "support/LAssert.h"
20 #include "paragraph.h"
21 #include "support/textutils.h"
23 #include "insets/insettext.h"
24 #include "ParagraphParameters.h"
25 #include "BufferView.h"
32 #include "rowpainter.h"
39 extern int PAPER_MARGIN;
40 extern int CHANGEBAR_MARGIN;
41 extern int LEFT_MARGIN;
45 // "temporary". We'll never get to use more
46 // references until we start adding hacks like
47 // these until other places catch up.
48 BufferView * perv(BufferView const & bv)
50 return const_cast<BufferView *>(&bv);
56 RowPainter::RowPainter(BufferView const & bv, LyXText const & text, Row const & row)
57 : bv_(bv), pain_(bv_.painter()), text_(text), row_(row), par_(*row.par())
63 LyXFont const RowPainter::getFont(pos_type pos) const
65 Paragraph * perverted_par = const_cast<Paragraph *>(&par_);
66 return text_.getFont(bv_.buffer(), perverted_par, pos);
70 int RowPainter::singleWidth(lyx::pos_type pos) const
72 Paragraph * par(const_cast<Paragraph*>(&par_));
73 return text_.singleWidth(par, pos);
77 int RowPainter::singleWidth(lyx::pos_type pos, char c) const
79 Paragraph * par(const_cast<Paragraph*>(&par_));
80 return text_.singleWidth(par, pos, c);
84 LyXFont const RowPainter::getLabelFont() const
86 Paragraph * par(const_cast<Paragraph*>(&par_));
87 return text_.getLabelFont(bv_.buffer(), par);
91 char const RowPainter::transformChar(char c, lyx::pos_type pos) const
93 Paragraph * par(const_cast<Paragraph*>(&par_));
94 return text_.transformChar(c, par, pos);
98 int RowPainter::leftMargin() const
100 Row * row(const_cast<Row *>(&row_));
101 return text_.leftMargin(row);
105 bool RowPainter::paintInset(pos_type const pos)
107 Inset * inset = const_cast<Inset*>(par_.getInset(pos));
111 LyXFont const & font = getFont(pos);
113 inset->update(perv(bv_), font, false);
114 inset->draw(perv(bv_), font, yo_ + row_.baseline(), x_);
116 // return true if something changed when we drew an inset
118 return (!text_.need_break_row && !text_.isInInset()
119 && bv_.text->status() == LyXText::CHANGED_IN_DRAW);
123 void RowPainter::paintHebrewComposeChar(pos_type & vpos)
125 pos_type pos = text_.vis2log(vpos);
130 char c = par_.getChar(pos);
134 LyXFont const & font = getFont(pos);
135 int const width = font_metrics::width(c, font);
138 for (pos_type i = pos - 1; i >= 0; --i) {
140 if (!Encodings::IsComposeChar_hebrew(c)) {
141 if (IsPrintableNonspace(c)) {
145 dx = (c == 'ø' || c == 'ã')
147 : (width2 - width) / 2;
154 pain_.text(int(x_) + dx, yo_ + row_.baseline(), str, font);
158 void RowPainter::paintArabicComposeChar(pos_type & vpos)
160 pos_type pos = text_.vis2log(vpos);
164 char c = par_.getChar(pos);
165 c = transformChar(c, pos);
169 LyXFont const & font = getFont(pos);
170 int const width = font_metrics::width(c, font);
173 for (pos_type i = pos-1; i >= 0; --i) {
175 if (!Encodings::IsComposeChar_arabic(c)) {
176 if (IsPrintableNonspace(c)) {
179 dx = (width2 - width) / 2;
185 pain_.text(int(x_) + dx, yo_ + row_.baseline(), str, font);
189 void RowPainter::paintChars(pos_type & vpos, bool hebrew, bool arabic)
191 pos_type pos = text_.vis2log(vpos);
192 pos_type const last = row_.lastPrintablePos();
193 LyXFont orig_font(getFont(pos));
197 str += par_.getChar(pos);
199 unsigned char c = str[0];
200 str[0] = transformChar(c, pos);
203 bool prev_struckout(isDeletedText(par_, pos));
204 bool prev_newtext(isInsertedText(par_, pos));
208 // collect as much similar chars as we can
209 while (vpos <= last && (pos = text_.vis2log(vpos)) >= 0) {
210 char c = par_.getChar(pos);
212 if (!IsPrintableNonspace(c))
215 if (prev_struckout != isDeletedText(par_, pos))
218 if (prev_newtext != isInsertedText(par_, pos))
221 if (arabic && Encodings::IsComposeChar_arabic(c))
223 if (hebrew && Encodings::IsComposeChar_hebrew(c))
226 if (orig_font != getFont(pos))
230 c = transformChar(c, pos);
235 if (prev_struckout) {
236 orig_font.setColor(LColor::strikeout);
237 } else if (prev_newtext) {
238 orig_font.setColor(LColor::newtext);
241 // Draw text and set the new x position
242 pain_.text(int(x_), yo_ + row_.baseline(), str, orig_font);
243 x_ += font_metrics::width(str, orig_font);
247 void RowPainter::paintForeignMark(float const orig_x, LyXFont const & orig_font)
249 if (!lyxrc.mark_foreign_language)
251 if (orig_font.language() == latex_language)
253 if (orig_font.language() == bv_.buffer()->params.language)
256 int const y = yo_ + row_.baseline() + 1;
257 pain_.line(int(orig_x), y, int(x_), y, LColor::language);
261 bool RowPainter::paintFromPos(pos_type & vpos)
263 pos_type const pos = text_.vis2log(vpos);
265 LyXFont const & orig_font = getFont(pos);
267 float const orig_x = x_;
269 char const c = par_.getChar(pos);
271 if (IsInsetChar(c)) {
275 paintForeignMark(orig_x, orig_font);
279 // usual characters, no insets
281 // special case languages
282 bool const hebrew = (orig_font.language()->lang() == "hebrew");
284 orig_font.language()->lang() == "arabic" &&
285 (lyxrc.font_norm_type == LyXRC::ISO_8859_6_8 ||
286 lyxrc.font_norm_type == LyXRC::ISO_10646_1);
288 // draw as many chars as we can
289 if ((!hebrew && !arabic)
290 || (hebrew && !Encodings::IsComposeChar_hebrew(c))
291 || (arabic && !Encodings::IsComposeChar_arabic(c))) {
292 paintChars(vpos, hebrew, arabic);
294 paintHebrewComposeChar(vpos);
296 paintArabicComposeChar(vpos);
299 paintForeignMark(orig_x, orig_font);
305 void RowPainter::paintBackground()
308 int const y = yo_ < 0 ? 0 : yo_;
309 int const h = yo_ < 0 ? row_.height() + yo_ : row_.height();
310 pain_.fillRectangle(x, y, width_, h, text_.backgroundColor());
314 void RowPainter::paintSelection()
316 bool const is_rtl = par_.isRightToLeftPar(bv_.buffer()->params);
318 // the current selection
319 int const startx = text_.selection.start.x();
320 int const endx = text_.selection.end.x();
321 int const starty = text_.selection.start.y();
322 int const endy = text_.selection.end.y();
323 Row const * startrow = text_.selection.start.row();
324 Row const * endrow = text_.selection.end.row();
327 Row const * row = &row_;
329 if (text_.bidi_same_direction) {
333 int h = row_.height();
335 if (startrow == row && endrow == row) {
339 pain_.fillRectangle(x, y, w, h, LColor::selection);
343 pain_.fillRectangle(x, y, w, h, LColor::selection);
345 } else if (startrow == row) {
346 int const x = (is_rtl) ? xo_ : (xo_ + startx);
347 int const w = (is_rtl) ? startx : (width_ - startx);
348 pain_.fillRectangle(x, y, w, h, LColor::selection);
349 } else if (endrow == row) {
350 int const x = (is_rtl) ? (xo_ + endx) : xo_;
351 int const w = (is_rtl) ? (width_ - endx) : endx;
352 pain_.fillRectangle(x, y, w, h, LColor::selection);
353 } else if (y_ > starty && y_ < endy) {
354 pain_.fillRectangle(xo_, y, width_, h, LColor::selection);
357 } else if (startrow != row && endrow != row) {
358 if (y_ > starty && y_ < endy) {
360 int h = row_.height();
361 pain_.fillRectangle(xo_, yo_, w, h, LColor::selection);
366 if ((startrow != row && !is_rtl) || (endrow != row && is_rtl))
367 pain_.fillRectangle(xo_, yo_, int(x_), row_.height(), LColor::selection);
369 pos_type const body_pos = par_.beginningOfBody();
370 pos_type const last = row_.lastPrintablePos();
373 for (pos_type vpos = row_.pos(); vpos <= last; ++vpos) {
374 pos_type pos = text_.vis2log(vpos);
375 float const old_tmpx = tmpx;
376 if (body_pos > 0 && pos == body_pos - 1) {
377 LyXLayout_ptr const & layout = par_.layout();
378 LyXFont const lfont = getLabelFont();
380 tmpx += label_hfill_ + font_metrics::width(layout->labelsep, lfont);
382 if (par_.isLineSeparator(body_pos - 1))
383 tmpx -= singleWidth(body_pos - 1);
386 if (row_.hfillExpansion(pos)) {
387 tmpx += singleWidth(pos);
391 tmpx += label_hfill_;
394 else if (par_.isSeparator(pos)) {
395 tmpx += singleWidth(pos);
399 tmpx += singleWidth(pos);
402 if ((startrow != row || text_.selection.start.pos() <= pos) &&
403 (endrow != row || pos < text_.selection.end.pos())) {
404 // Here we do not use x_ as xo_ was added to x_.
405 pain_.fillRectangle(int(old_tmpx), yo_,
406 int(tmpx - old_tmpx + 1),
407 row_.height(), LColor::selection);
411 if ((startrow != row && is_rtl) || (endrow != row && !is_rtl)) {
412 pain_.fillRectangle(xo_ + int(tmpx),
413 yo_, int(bv_.workWidth() - tmpx),
414 row_.height(), LColor::selection);
419 void RowPainter::paintChangeBar()
421 pos_type const start = row_.pos();
422 pos_type const end = row_.lastPrintablePos();
424 if (!par_.isChanged(start, end))
427 int const height = (row_.next()
428 ? row_.height() + row_.next()->top_of_text()
431 pain_.fillRectangle(4, yo_, 5, height, LColor::changebar);
435 void RowPainter::paintAppendix()
437 if (!par_.params().appendix())
440 // FIXME: can be just width_ ?
441 int const ww = bv_.workWidth();
445 if (par_.params().startOfAppendix())
446 y += 2 * defaultRowHeight();
448 pain_.line(1, y, 1, yo_ + row_.height(), LColor::appendix);
449 pain_.line(ww - 2, y, ww - 2, yo_ + row_.height(), LColor::appendix);
453 void RowPainter::paintDepthBar()
455 Paragraph::depth_type const depth = par_.getDepth();
460 Paragraph::depth_type prev_depth = 0;
462 prev_depth = row_.previous()->par()->getDepth();
463 Paragraph::depth_type next_depth = 0;
465 next_depth = row_.next()->par()->getDepth();
467 for (Paragraph::depth_type i = 1; i <= depth; ++i) {
468 int x = (PAPER_MARGIN / 5) * i + xo_;
469 // only consider the changebar space if we're drawing outer left
471 x += CHANGEBAR_MARGIN;
472 int const h = yo_ + row_.height() - 1 - (i - next_depth - 1) * 3;
474 pain_.line(x, yo_, x, h, LColor::depthbar);
476 int const w = PAPER_MARGIN / 5;
478 if (i > prev_depth) {
479 pain_.fillRectangle(x, yo_, w, 2, LColor::depthbar);
481 if (i > next_depth) {
482 pain_.fillRectangle(x, h, w, 2, LColor::depthbar);
488 int getLengthMarkerHeight(BufferView const & bv, VSpace const & vsp)
490 if (vsp.kind() == VSpace::NONE)
493 int const arrow_size = 4;
494 int const space_size = int(vsp.inPixels(bv));
498 int const min_size = max(3 * arrow_size,
499 font_metrics::maxAscent(font)
500 + font_metrics::maxDescent(font));
502 if (vsp.length().len().value() < 0.0)
505 return max(min_size, space_size);
509 int RowPainter::paintLengthMarker(string const & prefix, VSpace const & vsp, int start)
511 if (vsp.kind() == VSpace::NONE)
514 int const arrow_size = 4;
515 int const size = getLengthMarkerHeight(bv_, vsp);
516 int const end = start + size;
518 // the label to display (if any)
520 // y-values for top arrow
522 // y-values for bottom arrow
525 str = prefix + " (" + vsp.asLyXCommand() + ")";
527 if (vsp.kind() == VSpace::VFILL) {
531 // adding or removing space
532 bool const added = vsp.kind() != VSpace::LENGTH ||
533 vsp.length().len().value() > 0.0;
534 ty1 = added ? (start + arrow_size) : start;
535 ty2 = added ? start : (start + arrow_size);
536 by1 = added ? (end - arrow_size) : end;
537 by2 = added ? end : (end - arrow_size);
540 int const leftx = xo_ + leftMargin();
541 int const midx = leftx + arrow_size;
542 int const rightx = midx + arrow_size;
550 font.setColor(LColor::added_space).decSize().decSize();
551 font_metrics::rectText(str, font, w, a, d);
553 pain_.rectText(leftx + 2 * arrow_size + 5,
554 start + ((end - start) / 2) + d,
558 pain_.line(leftx, ty1, midx, ty2, LColor::added_space);
559 pain_.line(midx, ty2, rightx, ty1, LColor::added_space);
562 pain_.line(leftx, by1, midx, by2, LColor::added_space);
563 pain_.line(midx, by2, rightx, by1, LColor::added_space);
566 pain_.line(midx, ty2, midx, by2, LColor::added_space);
572 int RowPainter::paintPageBreak(string const & label, int y)
575 pb_font.setColor(LColor::pagebreak).decSize();
580 font_metrics::rectText(label, pb_font, w, a, d);
582 int const text_start = xo_ + ((width_ - w) / 2);
583 int const text_end = text_start + w;
585 pain_.rectText(text_start, y + d, label, pb_font);
587 pain_.line(xo_, y, text_start, y,
588 LColor::pagebreak, Painter::line_onoffdash);
589 pain_.line(text_end, y, xo_ + width_, y,
590 LColor::pagebreak, Painter::line_onoffdash);
592 return 3 * defaultRowHeight();
596 int RowPainter::paintAppendixStart(int y)
599 pb_font.setColor(LColor::appendix).decSize();
601 string const label = _("Appendix");
605 font_metrics::rectText(label, pb_font, w, a, d);
607 int const text_start = xo_ + ((width_ - w) / 2);
608 int const text_end = text_start + w;
610 pain_.rectText(text_start, y + d, label, pb_font);
612 pain_.line(xo_ + 1, y, text_start, y, LColor::appendix);
613 pain_.line(text_end, y, xo_ + width_ - 2, y, LColor::appendix);
615 return 3 * defaultRowHeight();
619 void RowPainter::paintFirst()
621 ParagraphParameters const & parparams = par_.params();
625 // start of appendix?
626 if (parparams.startOfAppendix()) {
627 y_top += paintAppendixStart(yo_ + y_top + 2 * defaultRowHeight());
631 if (!row_.previous() && !text_.isInInset())
632 y_top += PAPER_MARGIN;
634 // draw a top pagebreak
635 if (parparams.pagebreakTop()) {
636 y_top += paintPageBreak(_("Page Break (top)"),
637 yo_ + y_top + 2 * defaultRowHeight());
640 // draw the additional space if needed:
641 y_top += paintLengthMarker(_("Space above"), parparams.spaceTop(),
644 Buffer const * buffer = bv_.buffer();
646 LyXLayout_ptr const & layout = par_.layout();
648 if (buffer->params.paragraph_separation == BufferParams::PARSEP_SKIP) {
649 if (par_.previous()) {
650 if (layout->latextype == LATEX_PARAGRAPH
651 && !par_.getDepth()) {
652 y_top += buffer->params.getDefSkip().inPixels(bv_);
654 LyXLayout_ptr const & playout =
655 par_.previous()->layout();
656 if (playout->latextype == LATEX_PARAGRAPH
657 && !par_.previous()->getDepth()) {
658 // is it right to use defskip here, too? (AS)
659 y_top += buffer->params.getDefSkip().inPixels(bv_);
665 int const ww = bv_.workWidth();
668 if (parparams.lineTop()) {
669 LyXFont font(LyXFont::ALL_SANE);
670 int const asc = font_metrics::ascent('x', getFont(0));
674 int const w = (text_.isInInset() ? text_.inset_owner->width(perv(bv_), font) : ww);
675 int const xp = static_cast<int>(text_.isInInset() ? xo_ : 0);
676 pain_.line(xp, yo_ + y_top, xp + w, yo_ + y_top,
677 LColor::topline, Painter::line_solid,
678 Painter::line_thick);
683 bool const is_rtl = par_.isRightToLeftPar(bv_.buffer()->params);
685 // should we print a label?
686 if (layout->labeltype >= LABEL_STATIC
687 && (layout->labeltype != LABEL_STATIC
688 || layout->latextype != LATEX_ENVIRONMENT
689 || par_.isFirstInSequence())) {
691 LyXFont font = getLabelFont();
692 if (!par_.getLabelstring().empty()) {
694 string const str = par_.getLabelstring();
696 // this is special code for the chapter layout. This is
697 // printed in an extra row and has a pagebreak at
699 if (layout->labeltype == LABEL_COUNTER_CHAPTER) {
700 if (buffer->params.secnumdepth >= 0) {
701 float spacing_val = 1.0;
702 if (!parparams.spacing().isDefault()) {
703 spacing_val = parparams.spacing().getValue();
705 spacing_val = buffer->params.spacing.getValue();
709 int(font_metrics::maxDescent(font) * layout->spacing.getValue() * spacing_val)
710 + int(layout->parsep) * defaultRowHeight();
713 x = ww - leftMargin() -
714 font_metrics::width(str, font);
718 yo_ + row_.baseline() -
719 row_.ascent_of_text() - maxdesc,
724 x = ww - leftMargin()
725 + font_metrics::width(layout->labelsep, font);
727 x = x_ - font_metrics::width(layout->labelsep, font)
728 - font_metrics::width(str, font);
731 pain_.text(int(x), yo_ + row_.baseline(), str, font);
735 // the labels at the top of an environment.
736 // More or less for bibliography
737 } else if (par_.isFirstInSequence() &&
738 (layout->labeltype == LABEL_TOP_ENVIRONMENT ||
739 layout->labeltype == LABEL_BIBLIO ||
740 layout->labeltype == LABEL_CENTERED_TOP_ENVIRONMENT)) {
741 LyXFont font = getLabelFont();
742 if (!par_.getLabelstring().empty()) {
743 string const str = par_.getLabelstring();
744 float spacing_val = 1.0;
745 if (!parparams.spacing().isDefault()) {
746 spacing_val = parparams.spacing().getValue();
748 spacing_val = buffer->params.spacing.getValue();
752 int(font_metrics::maxDescent(font) * layout->spacing.getValue() * spacing_val
753 + (layout->labelbottomsep * defaultRowHeight()));
756 if (layout->labeltype == LABEL_CENTERED_TOP_ENVIRONMENT) {
757 x = ((is_rtl ? leftMargin() : x_)
758 + ww - text_.rightMargin(*bv_.buffer(), row_)) / 2;
759 x -= font_metrics::width(str, font) / 2;
761 x = ww - leftMargin() -
762 font_metrics::width(str, font);
764 pain_.text(int(x), yo_ + row_.baseline()
765 - row_.ascent_of_text() - maxdesc,
772 void RowPainter::paintLast()
774 ParagraphParameters const & parparams = par_.params();
775 int y_bottom = row_.height() - 1;
778 if (!row_.next() && !text_.isInInset())
779 y_bottom -= PAPER_MARGIN;
781 int const ww = bv_.workWidth();
783 // draw a bottom pagebreak
784 if (parparams.pagebreakBottom()) {
785 y_bottom -= paintPageBreak(_("Page Break (bottom)"),
786 yo_ + y_bottom - 2 * defaultRowHeight());
789 // draw the additional space if needed:
790 int const height = getLengthMarkerHeight(bv_, parparams.spaceBottom());
791 y_bottom -= paintLengthMarker(_("Space below"), parparams.spaceBottom(),
792 yo_ + y_bottom - height);
794 // draw a bottom line
795 if (parparams.lineBottom()) {
796 LyXFont font(LyXFont::ALL_SANE);
797 int const asc = font_metrics::ascent('x',
798 getFont(max(pos_type(0), par_.size() - 1)));
802 int const w = (text_.isInInset() ? text_.inset_owner->width(perv(bv_), font) : ww);
803 int const xp = static_cast<int>(text_.isInInset() ? xo_ : 0);
804 int const y = yo_ + y_bottom;
805 pain_.line(xp, y, xp + w, y, LColor::topline, Painter::line_solid,
806 Painter::line_thick);
811 bool const is_rtl = par_.isRightToLeftPar(bv_.buffer()->params);
812 int const endlabel = par_.getEndLabel();
817 case END_LABEL_FILLED_BOX:
819 LyXFont const font = getLabelFont();
820 int const size = int(0.75 * font_metrics::maxAscent(font));
821 int const y = (yo_ + row_.baseline()) - size;
822 int x = is_rtl ? LEFT_MARGIN : ww - PAPER_MARGIN - size;
824 if (row_.fill() <= size)
825 x += (size - row_.fill() + 1) * (is_rtl ? -1 : 1);
827 if (endlabel == END_LABEL_BOX) {
828 pain_.rectangle(x, y, size, size, LColor::eolmarker);
830 pain_.fillRectangle(x, y, size, size, LColor::eolmarker);
834 case END_LABEL_STATIC:
837 LyXFont font(LyXFont::ALL_SANE);
838 font = getLabelFont();
840 LyXFont font = getLabelFont();
842 string const & str = par_.layout()->endlabelstring();
843 int const x = is_rtl ?
844 int(x_) - font_metrics::width(str, font)
845 : ww - text_.rightMargin(*bv_.buffer(), row_) - row_.fill();
846 pain_.text(x, yo_ + row_.baseline(), str, font);
849 case END_LABEL_NO_LABEL:
855 bool RowPainter::paintText()
857 pos_type const last = row_.lastPrintablePos();
858 pos_type body_pos = par_.beginningOfBody();
860 (body_pos - 1 > last ||
861 !par_.isLineSeparator(body_pos - 1))) {
865 LyXLayout_ptr const & layout = par_.layout();
867 bool running_strikeout = false;
868 bool is_struckout = false;
869 float last_strikeout_x = 0.0;
871 pos_type vpos = row_.pos();
872 while (vpos <= last) {
873 if (x_ > bv_.workWidth())
875 pos_type pos = text_.vis2log(vpos);
877 if (pos >= par_.size()) {
882 if (x_ + singleWidth(pos) < 0) {
883 x_ += singleWidth(pos);
888 is_struckout = isDeletedText(par_, pos);
890 if (is_struckout && !running_strikeout) {
891 running_strikeout = true;
892 last_strikeout_x = x_;
895 bool const highly_editable_inset = par_.isInset(pos)
896 && isHighlyEditableInset(par_.getInset(pos));
898 // if we reach the end of a struck out range, paint it
899 // we also don't paint across things like tables
900 if (running_strikeout && (highly_editable_inset || !is_struckout)) {
901 int const middle = yo_ + row_.top_of_text()
902 + ((row_.baseline() - row_.top_of_text()) / 2);
903 pain_.line(int(last_strikeout_x), middle, int(x_), middle,
904 LColor::strikeout, Painter::line_solid, Painter::line_thin);
905 running_strikeout = false;
908 if (body_pos > 0 && pos == body_pos - 1) {
909 int const lwidth = font_metrics::width(layout->labelsep,
912 x_ += label_hfill_ + lwidth
913 - singleWidth(body_pos - 1);
916 if (par_.isHfill(pos)) {
919 int const y0 = yo_ + row_.baseline();
920 int const y1 = y0 - defaultRowHeight() / 2;
922 pain_.line(int(x_), y1, int(x_), y0,
923 LColor::added_space);
925 if (row_.hfillExpansion(pos)) {
926 int const y2 = (y0 + y1) / 2;
928 if (pos >= body_pos) {
929 pain_.line(int(x_), y2,
930 int(x_ + hfill_), y2,
932 Painter::line_onoffdash);
935 pain_.line(int(x_), y2,
936 int(x_ + label_hfill_), y2,
938 Painter::line_onoffdash);
941 pain_.line(int(x_), y1,
943 LColor::added_space);
947 } else if (par_.isSeparator(pos)) {
948 x_ += singleWidth(pos);
953 if (paintFromPos(vpos))
958 // if we reach the end of a struck out range, paint it
959 if (running_strikeout) {
960 int const middle = yo_ + row_.top_of_text()
961 + ((row_.baseline() - row_.top_of_text()) / 2);
962 pain_.line(int(last_strikeout_x), middle, int(x_), middle,
963 LColor::strikeout, Painter::line_solid, Painter::line_thin);
964 running_strikeout = false;
970 bool RowPainter::paint(int y_offset, int x_offset, int y)
975 width_ = text_.isInInset()
976 ? text_.inset_owner->textWidth(perv(bv_), true) : bv_.workWidth();
978 // FIXME: must be a cleaner way here. Aren't these calculations
979 // belonging to row metrics ?
980 Row * row(const_cast<Row *>(&row_));
981 text_.prepareToPrint(row, x_, separator_, hfill_, label_hfill_);
983 // FIXME: what is this fixing ?
984 if (text_.isInInset() && (x_ < 0))
988 // If we're *not* at the top-level of rows, then the
989 // background has already been cleared.
990 if (&text_ == bv_.text)
993 // paint the selection background
994 if (text_.selection.set()) {
998 // vertical lines for appendix
1001 // environment depth brackets
1007 if (row_.isParStart()) {
1011 if (row_.isParEnd()) {