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 BufferView * bv(perv(bv_));
73 Paragraph * par(const_cast<Paragraph*>(&par_));
74 return text_.singleWidth(bv, par, pos);
78 int RowPainter::singleWidth(lyx::pos_type pos, char c) const
80 BufferView * bv(perv(bv_));
81 Paragraph * par(const_cast<Paragraph*>(&par_));
82 return text_.singleWidth(bv, par, pos, c);
86 LyXFont const RowPainter::getLabelFont() const
88 Paragraph * par(const_cast<Paragraph*>(&par_));
89 return text_.getLabelFont(bv_.buffer(), par);
93 char const RowPainter::transformChar(char c, lyx::pos_type pos) const
95 Paragraph * par(const_cast<Paragraph*>(&par_));
96 return text_.transformChar(c, par, pos);
100 int RowPainter::leftMargin() const
102 BufferView * bv(perv(bv_));
103 Row * row(const_cast<Row *>(&row_));
104 return text_.leftMargin(bv, row);
108 bool RowPainter::paintInset(pos_type const pos)
110 Inset * inset = const_cast<Inset*>(par_.getInset(pos));
114 LyXFont const & font = getFont(pos);
116 inset->update(perv(bv_), font, false);
117 inset->draw(perv(bv_), font, yo_ + row_.baseline(), x_, cleared_);
119 // return true if something changed when we drew an inset
121 return (!text_.need_break_row && !text_.isInInset()
122 && bv_.text->status() == LyXText::CHANGED_IN_DRAW);
126 void RowPainter::paintHebrewComposeChar(pos_type & vpos)
128 pos_type pos = text_.vis2log(vpos);
133 char c = par_.getChar(pos);
137 LyXFont const & font = getFont(pos);
138 int const width = font_metrics::width(c, font);
141 for (pos_type i = pos - 1; i >= 0; --i) {
143 if (!Encodings::IsComposeChar_hebrew(c)) {
144 if (IsPrintableNonspace(c)) {
148 dx = (c == 'ø' || c == 'ã')
150 : (width2 - width) / 2;
157 pain_.text(int(x_) + dx, yo_ + row_.baseline(), str, font);
161 void RowPainter::paintArabicComposeChar(pos_type & vpos)
163 pos_type pos = text_.vis2log(vpos);
167 char c = par_.getChar(pos);
168 c = transformChar(c, pos);
172 LyXFont const & font = getFont(pos);
173 int const width = font_metrics::width(c, font);
176 for (pos_type i = pos-1; i >= 0; --i) {
178 if (!Encodings::IsComposeChar_arabic(c)) {
179 if (IsPrintableNonspace(c)) {
182 dx = (width2 - width) / 2;
188 pain_.text(int(x_) + dx, yo_ + row_.baseline(), str, font);
192 void RowPainter::paintChars(pos_type & vpos, bool hebrew, bool arabic)
194 pos_type pos = text_.vis2log(vpos);
195 pos_type const last = row_.lastPrintablePos();
196 LyXFont orig_font(getFont(pos));
200 str += par_.getChar(pos);
202 unsigned char c = str[0];
203 str[0] = transformChar(c, pos);
206 bool prev_struckout(isDeletedText(par_, pos));
207 bool prev_newtext(isInsertedText(par_, pos));
211 // collect as much similar chars as we can
212 while (vpos <= last && (pos = text_.vis2log(vpos)) >= 0) {
213 char c = par_.getChar(pos);
215 if (!IsPrintableNonspace(c))
218 if (prev_struckout != isDeletedText(par_, pos))
221 if (prev_newtext != isInsertedText(par_, pos))
224 if (arabic && Encodings::IsComposeChar_arabic(c))
226 if (hebrew && Encodings::IsComposeChar_hebrew(c))
229 if (orig_font != getFont(pos))
233 c = transformChar(c, pos);
238 if (prev_struckout) {
239 orig_font.setColor(LColor::strikeout);
240 } else if (prev_newtext) {
241 orig_font.setColor(LColor::newtext);
244 // Draw text and set the new x position
245 pain_.text(int(x_), yo_ + row_.baseline(), str, orig_font);
246 x_ += font_metrics::width(str, orig_font);
250 void RowPainter::paintForeignMark(float const orig_x, LyXFont const & orig_font)
252 if (!lyxrc.mark_foreign_language)
254 if (orig_font.language() == latex_language)
256 if (orig_font.language() == bv_.buffer()->params.language)
259 int const y = yo_ + row_.baseline() + 1;
260 pain_.line(int(orig_x), y, int(x_), y, LColor::language);
264 bool RowPainter::paintFromPos(pos_type & vpos)
266 pos_type const pos = text_.vis2log(vpos);
268 LyXFont const & orig_font = getFont(pos);
270 float const orig_x = x_;
272 char const c = par_.getChar(pos);
274 if (IsInsetChar(c)) {
278 paintForeignMark(orig_x, orig_font);
282 // usual characters, no insets
284 // special case languages
285 bool const hebrew = (orig_font.language()->lang() == "hebrew");
287 orig_font.language()->lang() == "arabic" &&
288 (lyxrc.font_norm_type == LyXRC::ISO_8859_6_8 ||
289 lyxrc.font_norm_type == LyXRC::ISO_10646_1);
291 // draw as many chars as we can
292 if ((!hebrew && !arabic)
293 || (hebrew && !Encodings::IsComposeChar_hebrew(c))
294 || (arabic && !Encodings::IsComposeChar_arabic(c))) {
295 paintChars(vpos, hebrew, arabic);
297 paintHebrewComposeChar(vpos);
299 paintArabicComposeChar(vpos);
302 paintForeignMark(orig_x, orig_font);
308 bool RowPainter::paintBackground()
310 pos_type const last = row_.lastPrintablePos();
311 bool clear_area = true;
312 Inset const * inset = 0;
314 if (!bv_.screen().forceClear() && last == row_.pos()
315 && row_.pos() < par_.size()
316 && par_.isInset(row_.pos())) {
317 inset = par_.getInset(row_.pos());
318 clear_area = inset->doClearArea();
327 int const y = yo_ < 0 ? 0 : yo_;
328 int const h = yo_ < 0 ? row_.height() + yo_ : row_.height();
329 pain_.fillRectangle(x, y, width_, h, text_.backgroundColor());
336 LyXFont font(LyXFont::ALL_SANE);
339 BufferView * bv = perv(bv_);
341 int h = row_.baseline() - inset->ascent(bv, font);
343 // first clear the whole row above the inset!
345 pain_.fillRectangle(xo_, yo_, width_, h, text_.backgroundColor());
348 // clear the space below the inset!
349 h += inset->ascent(bv, font) + inset->descent(bv, font);
350 if ((row_.height() - h) > 0) {
351 pain_.fillRectangle(xo_, yo_ + h,
352 width_, row_.height() - h, text_.backgroundColor());
355 // clear the space behind the inset, if needed
356 if (!inset->display() && !inset->needFullRow()) {
357 int const xp = int(x_) + inset->width(bv, font);
358 if (width_ - xp > 0) {
359 pain_.fillRectangle(xp, yo_, width_ - xp,
360 row_.height(), text_.backgroundColor());
368 void RowPainter::paintSelection()
370 bool const is_rtl = par_.isRightToLeftPar(bv_.buffer()->params);
372 // the current selection
373 int const startx = text_.selection.start.x();
374 int const endx = text_.selection.end.x();
375 int const starty = text_.selection.start.y();
376 int const endy = text_.selection.end.y();
377 Row const * startrow = text_.selection.start.row();
378 Row const * endrow = text_.selection.end.row();
381 Row const * row = &row_;
383 if (text_.bidi_same_direction) {
387 int h = row_.height();
389 if (startrow == row && endrow == row) {
393 pain_.fillRectangle(x, y, w, h, LColor::selection);
397 pain_.fillRectangle(x, y, w, h, LColor::selection);
399 } else if (startrow == row) {
400 int const x = (is_rtl) ? xo_ : (xo_ + startx);
401 int const w = (is_rtl) ? startx : (width_ - startx);
402 pain_.fillRectangle(x, y, w, h, LColor::selection);
403 } else if (endrow == row) {
404 int const x = (is_rtl) ? (xo_ + endx) : xo_;
405 int const w = (is_rtl) ? (width_ - endx) : endx;
406 pain_.fillRectangle(x, y, w, h, LColor::selection);
407 } else if (y_ > starty && y_ < endy) {
408 pain_.fillRectangle(xo_, y, width_, h, LColor::selection);
411 } else if (startrow != row && endrow != row) {
412 if (y_ > starty && y_ < endy) {
414 int h = row_.height();
415 pain_.fillRectangle(xo_, yo_, w, h, LColor::selection);
420 if ((startrow != row && !is_rtl) || (endrow != row && is_rtl))
421 pain_.fillRectangle(xo_, yo_, int(x_), row_.height(), LColor::selection);
423 pos_type const body_pos = par_.beginningOfBody();
424 pos_type const last = row_.lastPrintablePos();
427 for (pos_type vpos = row_.pos(); vpos <= last; ++vpos) {
428 pos_type pos = text_.vis2log(vpos);
429 float const old_tmpx = tmpx;
430 if (body_pos > 0 && pos == body_pos - 1) {
431 LyXLayout_ptr const & layout = par_.layout();
432 LyXFont const lfont = getLabelFont();
434 tmpx += label_hfill_ + font_metrics::width(layout->labelsep, lfont);
436 if (par_.isLineSeparator(body_pos - 1))
437 tmpx -= singleWidth(body_pos - 1);
440 if (row_.hfillExpansion(pos)) {
441 tmpx += singleWidth(pos);
445 tmpx += label_hfill_;
448 else if (par_.isSeparator(pos)) {
449 tmpx += singleWidth(pos);
453 tmpx += singleWidth(pos);
456 if ((startrow != row || text_.selection.start.pos() <= pos) &&
457 (endrow != row || pos < text_.selection.end.pos())) {
458 // Here we do not use x_ as xo_ was added to x_.
459 pain_.fillRectangle(int(old_tmpx), yo_,
460 int(tmpx - old_tmpx + 1),
461 row_.height(), LColor::selection);
465 if ((startrow != row && is_rtl) || (endrow != row && !is_rtl)) {
466 pain_.fillRectangle(xo_ + int(tmpx),
467 yo_, int(bv_.workWidth() - tmpx),
468 row_.height(), LColor::selection);
473 void RowPainter::paintChangeBar()
475 pos_type const start = row_.pos();
476 pos_type const end = row_.lastPrintablePos();
478 if (!par_.isChanged(start, end))
481 int const height = (row_.next()
482 ? row_.height() + row_.next()->top_of_text()
485 pain_.fillRectangle(4, yo_, 5, height, LColor::changebar);
489 void RowPainter::paintAppendix()
491 // FIXME: can be just width_ ?
492 int const ww = bv_.workWidth();
494 if (par_.params().appendix()) {
495 pain_.line(1, yo_, 1, yo_ + row_.height(), LColor::appendixline);
496 pain_.line(ww - 2, yo_, ww - 2, yo_ + row_.height(), LColor::appendixline);
501 void RowPainter::paintDepthBar()
503 Paragraph::depth_type const depth = par_.getDepth();
508 Paragraph::depth_type prev_depth = 0;
510 prev_depth = row_.previous()->par()->getDepth();
511 Paragraph::depth_type next_depth = 0;
513 next_depth = row_.next()->par()->getDepth();
515 for (Paragraph::depth_type i = 1; i <= depth; ++i) {
516 int x = (PAPER_MARGIN / 5) * i + xo_;
517 // only consider the changebar space if we're drawing outer left
519 x += CHANGEBAR_MARGIN;
520 int const h = yo_ + row_.height() - 1 - (i - next_depth - 1) * 3;
522 pain_.line(x, yo_, x, h, LColor::depthbar);
524 int const w = PAPER_MARGIN / 5;
526 if (i > prev_depth) {
527 pain_.fillRectangle(x, yo_, w, 2, LColor::depthbar);
529 if (i > next_depth) {
530 pain_.fillRectangle(x, h, w, 2, LColor::depthbar);
536 int getLengthMarkerHeight(BufferView const & bv, VSpace const & vsp)
538 if (vsp.kind() == VSpace::NONE)
541 int const arrow_size = 4;
542 int const space_size = int(vsp.inPixels(bv));
546 int const min_size = max(3 * arrow_size,
547 font_metrics::maxAscent(font)
548 + font_metrics::maxDescent(font));
550 if (vsp.length().len().value() < 0.0)
553 return max(min_size, space_size);
557 int RowPainter::paintLengthMarker(string const & prefix, VSpace const & vsp, int start)
559 if (vsp.kind() == VSpace::NONE)
562 int const arrow_size = 4;
563 int const size = getLengthMarkerHeight(bv_, vsp);
564 int const end = start + size;
566 // the label to display (if any)
568 // y-values for top arrow
570 // y-values for bottom arrow
573 str = prefix + " (" + vsp.asLyXCommand() + ")";
575 if (vsp.kind() == VSpace::VFILL) {
579 // adding or removing space
580 bool const added = vsp.kind() != VSpace::LENGTH ||
581 vsp.length().len().value() > 0.0;
582 ty1 = added ? (start + arrow_size) : start;
583 ty2 = added ? start : (start + arrow_size);
584 by1 = added ? (end - arrow_size) : end;
585 by2 = added ? end : (end - arrow_size);
588 int const leftx = xo_ + leftMargin();
589 int const midx = leftx + arrow_size;
590 int const rightx = midx + arrow_size;
598 font.setColor(LColor::added_space).decSize().decSize();
599 font_metrics::rectText(str, font, w, a, d);
601 pain_.rectText(leftx + 2 * arrow_size + 5,
602 start + ((end - start) / 2) + d,
606 pain_.line(leftx, ty1, midx, ty2, LColor::added_space);
607 pain_.line(midx, ty2, rightx, ty1, LColor::added_space);
610 pain_.line(leftx, by1, midx, by2, LColor::added_space);
611 pain_.line(midx, by2, rightx, by1, LColor::added_space);
614 pain_.line(midx, ty2, midx, by2, LColor::added_space);
620 int RowPainter::paintPageBreak(string const & label, int y)
623 pb_font.setColor(LColor::pagebreak).decSize();
628 font_metrics::rectText(label, pb_font, w, a, d);
630 int const text_start = xo_ + ((width_ - w) / 2);
631 int const text_end = text_start + w;
633 pain_.rectText(text_start, y + d, label, pb_font);
635 pain_.line(xo_, y, text_start, y,
636 LColor::pagebreak, Painter::line_onoffdash);
637 pain_.line(text_end, y, xo_ + width_, y,
638 LColor::pagebreak, Painter::line_onoffdash);
640 return 3 * defaultRowHeight();
644 void RowPainter::paintFirst()
646 ParagraphParameters const & parparams = par_.params();
648 // start of appendix?
649 if (parparams.startOfAppendix()) {
650 pain_.line(1, yo_, width_ - 2, yo_, LColor::appendixline);
656 if (!row_.previous() && text_.isTopLevel())
657 y_top += PAPER_MARGIN;
659 // draw a top pagebreak
660 if (parparams.pagebreakTop()) {
661 y_top += paintPageBreak(_("Page Break (top)"),
662 yo_ + y_top + 2 * defaultRowHeight());
665 // draw the additional space if needed:
666 y_top += paintLengthMarker(_("Space above"), parparams.spaceTop(),
669 Buffer const * buffer = bv_.buffer();
671 LyXLayout_ptr const & layout = par_.layout();
673 if (buffer->params.paragraph_separation == BufferParams::PARSEP_SKIP) {
674 if (par_.previous()) {
675 if (layout->latextype == LATEX_PARAGRAPH
676 && !par_.getDepth()) {
677 y_top += buffer->params.getDefSkip().inPixels(bv_);
679 LyXLayout_ptr const & playout =
680 par_.previous()->layout();
681 if (playout->latextype == LATEX_PARAGRAPH
682 && !par_.previous()->getDepth()) {
683 // is it right to use defskip here, too? (AS)
684 y_top += buffer->params.getDefSkip().inPixels(bv_);
690 int const ww = bv_.workWidth();
693 if (parparams.lineTop()) {
694 LyXFont font(LyXFont::ALL_SANE);
695 int const asc = font_metrics::ascent('x', getFont(0));
699 int const w = (text_.isInInset() ? text_.inset_owner->width(perv(bv_), font) : ww);
700 int const xp = static_cast<int>(text_.isInInset() ? xo_ : 0);
701 pain_.line(xp, yo_ + y_top, xp + w, yo_ + y_top,
702 LColor::topline, Painter::line_solid,
703 Painter::line_thick);
708 bool const is_rtl = par_.isRightToLeftPar(bv_.buffer()->params);
710 // should we print a label?
711 if (layout->labeltype >= LABEL_STATIC
712 && (layout->labeltype != LABEL_STATIC
713 || layout->latextype != LATEX_ENVIRONMENT
714 || par_.isFirstInSequence())) {
716 LyXFont font = getLabelFont();
717 if (!par_.getLabelstring().empty()) {
719 string const str = par_.getLabelstring();
721 // this is special code for the chapter layout. This is
722 // printed in an extra row and has a pagebreak at
724 if (layout->labeltype == LABEL_COUNTER_CHAPTER) {
725 if (buffer->params.secnumdepth >= 0) {
726 float spacing_val = 1.0;
727 if (!parparams.spacing().isDefault()) {
728 spacing_val = parparams.spacing().getValue();
730 spacing_val = buffer->params.spacing.getValue();
734 int(font_metrics::maxDescent(font) * layout->spacing.getValue() * spacing_val)
735 + int(layout->parsep) * defaultRowHeight();
738 x = ww - leftMargin() -
739 font_metrics::width(str, font);
743 yo_ + row_.baseline() -
744 row_.ascent_of_text() - maxdesc,
749 x = ww - leftMargin()
750 + font_metrics::width(layout->labelsep, font);
752 x = x_ - font_metrics::width(layout->labelsep, font)
753 - font_metrics::width(str, font);
756 pain_.text(int(x), yo_ + row_.baseline(), str, font);
760 // the labels at the top of an environment.
761 // More or less for bibliography
762 } else if (par_.isFirstInSequence() &&
763 (layout->labeltype == LABEL_TOP_ENVIRONMENT ||
764 layout->labeltype == LABEL_BIBLIO ||
765 layout->labeltype == LABEL_CENTERED_TOP_ENVIRONMENT)) {
766 LyXFont font = getLabelFont();
767 if (!par_.getLabelstring().empty()) {
768 string const str = par_.getLabelstring();
769 float spacing_val = 1.0;
770 if (!parparams.spacing().isDefault()) {
771 spacing_val = parparams.spacing().getValue();
773 spacing_val = buffer->params.spacing.getValue();
777 int(font_metrics::maxDescent(font) * layout->spacing.getValue() * spacing_val
778 + (layout->labelbottomsep * defaultRowHeight()));
781 if (layout->labeltype == LABEL_CENTERED_TOP_ENVIRONMENT) {
782 x = ((is_rtl ? leftMargin() : x_)
783 + ww - text_.rightMargin(*bv_.buffer(), row_)) / 2;
784 x -= font_metrics::width(str, font) / 2;
786 x = ww - leftMargin() -
787 font_metrics::width(str, font);
789 pain_.text(int(x), yo_ + row_.baseline()
790 - row_.ascent_of_text() - maxdesc,
797 void RowPainter::paintLast()
799 ParagraphParameters const & parparams = par_.params();
800 int y_bottom = row_.height() - 1;
803 if (!row_.next() && text_.isTopLevel())
804 y_bottom -= PAPER_MARGIN;
806 int const ww = bv_.workWidth();
808 // draw a bottom pagebreak
809 if (parparams.pagebreakBottom()) {
810 y_bottom -= paintPageBreak(_("Page Break (bottom)"),
811 yo_ + y_bottom - 2 * defaultRowHeight());
814 // draw the additional space if needed:
815 int const height = getLengthMarkerHeight(bv_, parparams.spaceBottom());
816 y_bottom -= paintLengthMarker(_("Space below"), parparams.spaceBottom(),
817 yo_ + y_bottom - height);
819 // draw a bottom line
820 if (parparams.lineBottom()) {
821 LyXFont font(LyXFont::ALL_SANE);
822 int const asc = font_metrics::ascent('x',
823 getFont(max(pos_type(0), par_.size() - 1)));
827 int const w = (text_.isInInset() ? text_.inset_owner->width(perv(bv_), font) : ww);
828 int const xp = static_cast<int>(text_.isInInset() ? xo_ : 0);
829 int const y = yo_ + y_bottom;
830 pain_.line(xp, y, xp + w, y, LColor::topline, Painter::line_solid,
831 Painter::line_thick);
836 bool const is_rtl = par_.isRightToLeftPar(bv_.buffer()->params);
837 int const endlabel = par_.getEndLabel();
842 case END_LABEL_FILLED_BOX:
844 LyXFont const font = getLabelFont();
845 int const size = int(0.75 * font_metrics::maxAscent(font));
846 int const y = (yo_ + row_.baseline()) - size;
847 int x = is_rtl ? LEFT_MARGIN : ww - PAPER_MARGIN - size;
849 if (row_.fill() <= size)
850 x += (size - row_.fill() + 1) * (is_rtl ? -1 : 1);
852 if (endlabel == END_LABEL_BOX) {
853 pain_.rectangle(x, y, size, size, LColor::eolmarker);
855 pain_.fillRectangle(x, y, size, size, LColor::eolmarker);
859 case END_LABEL_STATIC:
862 LyXFont font(LyXFont::ALL_SANE);
863 font = getLabelFont();
865 LyXFont font = getLabelFont();
867 string const & str = par_.layout()->endlabelstring();
868 int const x = is_rtl ?
869 int(x_) - font_metrics::width(str, font)
870 : ww - text_.rightMargin(*bv_.buffer(), row_) - row_.fill();
871 pain_.text(x, yo_ + row_.baseline(), str, font);
874 case END_LABEL_NO_LABEL:
880 bool RowPainter::paintText()
882 pos_type const last = row_.lastPrintablePos();
883 pos_type body_pos = par_.beginningOfBody();
885 (body_pos - 1 > last ||
886 !par_.isLineSeparator(body_pos - 1))) {
890 LyXLayout_ptr const & layout = par_.layout();
892 bool running_strikeout = false;
893 bool is_struckout = false;
894 float last_strikeout_x = 0.0;
896 pos_type vpos = row_.pos();
897 while (vpos <= last) {
898 if (x_ > bv_.workWidth())
900 pos_type pos = text_.vis2log(vpos);
902 if (pos >= par_.size()) {
907 if (x_ + singleWidth(pos) < 0) {
908 x_ += singleWidth(pos);
913 is_struckout = isDeletedText(par_, pos);
915 if (is_struckout && !running_strikeout) {
916 running_strikeout = true;
917 last_strikeout_x = x_;
920 bool const highly_editable_inset = par_.isInset(pos)
921 && isHighlyEditableInset(par_.getInset(pos));
923 // if we reach the end of a struck out range, paint it
924 // we also don't paint across things like tables
925 if (running_strikeout && (highly_editable_inset || !is_struckout)) {
926 int const middle = yo_ + row_.top_of_text()
927 + ((row_.baseline() - row_.top_of_text()) / 2);
928 pain_.line(int(last_strikeout_x), middle, int(x_), middle,
929 LColor::strikeout, Painter::line_solid, Painter::line_thin);
930 running_strikeout = false;
933 if (body_pos > 0 && pos == body_pos - 1) {
934 int const lwidth = font_metrics::width(layout->labelsep,
937 x_ += label_hfill_ + lwidth
938 - singleWidth(body_pos - 1);
941 if (par_.isHfill(pos)) {
944 int const y0 = yo_ + row_.baseline();
945 int const y1 = y0 - defaultRowHeight() / 2;
947 pain_.line(int(x_), y1, int(x_), y0,
948 LColor::added_space);
950 if (row_.hfillExpansion(pos)) {
951 int const y2 = (y0 + y1) / 2;
953 if (pos >= body_pos) {
954 pain_.line(int(x_), y2,
955 int(x_ + hfill_), y2,
957 Painter::line_onoffdash);
960 pain_.line(int(x_), y2,
961 int(x_ + label_hfill_), y2,
963 Painter::line_onoffdash);
966 pain_.line(int(x_), y1,
968 LColor::added_space);
972 } else if (par_.isSeparator(pos)) {
973 x_ += singleWidth(pos);
978 if (paintFromPos(vpos))
983 // if we reach the end of a struck out range, paint it
984 if (running_strikeout) {
985 int const middle = yo_ + row_.top_of_text()
986 + ((row_.baseline() - row_.top_of_text()) / 2);
987 pain_.line(int(last_strikeout_x), middle, int(x_), middle,
988 LColor::strikeout, Painter::line_solid, Painter::line_thin);
989 running_strikeout = false;
995 bool RowPainter::paint(int y_offset, int x_offset, int y, bool cleared)
1001 width_ = text_.isInInset()
1002 ? text_.inset_owner->textWidth(perv(bv_), true) : bv_.workWidth();
1004 // FIXME: must be a cleaner way here. Aren't these calculations
1005 // belonging to row metrics ?
1006 BufferView * bv(const_cast<BufferView *>(&bv_));
1007 Row * row(const_cast<Row *>(&row_));
1008 text_.prepareToPrint(bv, row, x_, separator_, hfill_, label_hfill_);
1010 // FIXME: what is this fixing ?
1011 if (text_.isInInset() && (x_ < 0))
1015 // clear to background if necessary
1016 cleared_ = paintBackground();
1018 // paint the selection background
1019 if (text_.selection.set()) {
1023 // vertical lines for appendix
1026 // environment depth brackets
1032 if (row_.isParStart()) {
1036 if (row_.isParEnd()) {