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 "rowpainter.h"
19 #include "bufferparams.h"
20 #include "BufferView.h"
27 #include "lyxrow_funcs.h"
28 #include "metricsinfo.h"
29 #include "paragraph.h"
30 #include "paragraph_funcs.h"
31 #include "ParagraphParameters.h"
34 #include "frontends/font_metrics.h"
35 #include "frontends/Painter.h"
37 #include "insets/insettext.h"
39 #include "support/textutils.h"
47 extern int PAPER_MARGIN;
48 extern int CHANGEBAR_MARGIN;
49 extern int LEFT_MARGIN;
54 * A class used for painting an individual row of text.
58 /// initialise and run painter
59 RowPainter(BufferView const & bv, LyXText const & text,
60 ParagraphList::iterator pit, RowList::iterator rit, int xo, int yo);
62 // paint various parts
63 void paintBackground();
64 void paintSelection();
67 void paintChangeBar();
70 void paintForeignMark(double orig_x, LyXFont const & orig_font);
71 void paintHebrewComposeChar(lyx::pos_type & vpos);
72 void paintArabicComposeChar(lyx::pos_type & vpos);
73 void paintChars(lyx::pos_type & vpos, bool hebrew, bool arabic);
74 int paintAppendixStart(int y);
75 int paintLengthMarker(string const & prefix, VSpace const & vsp, int start);
77 void paintFromPos(lyx::pos_type & vpos);
78 void paintInset(lyx::pos_type const pos);
80 /// return left margin
81 int leftMargin() const;
83 /// return the font at the given pos
84 LyXFont const getFont(lyx::pos_type pos) const;
86 /// return the label font for this row
87 LyXFont const getLabelFont() const;
89 /// return pixel width for the given pos
90 int singleWidth(lyx::pos_type pos) const;
91 int singleWidth(lyx::pos_type pos, char c) const;
93 /// bufferview to paint on
94 BufferView const & bv_;
99 /// LyXText for the row
100 LyXText const & text_;
103 RowList::iterator const rit_;
107 mutable ParagraphList::iterator pit_;
120 RowPainter::RowPainter(BufferView const & bv, LyXText const & text,
121 ParagraphList::iterator pit, RowList::iterator rit,
123 : bv_(bv), pain_(bv_.painter()), text_(text), rit_(rit), row_(*rit),
124 pit_(pit), xo_(xo), yo_(yo), x_(row_.x()),
125 width_(text_.workWidth()),
126 separator_(row_.fill_separator()),
127 hfill_(row_.fill_hfill()),
128 label_hfill_(row_.fill_label_hfill())
132 // background has already been cleared.
133 if (&text_ == bv_.text)
136 // paint the selection background
137 if (text_.selection.set() && &text_ == bv_.cursor().innerText())
140 // vertical lines for appendix
143 // environment depth brackets
152 if (row_.endpos() >= pit_->size())
161 LyXFont const RowPainter::getFont(pos_type pos) const
163 return text_.getFont(pit_, pos);
167 int RowPainter::singleWidth(lyx::pos_type pos) const
169 return text_.singleWidth(pit_, pos);
173 int RowPainter::singleWidth(lyx::pos_type pos, char c) const
175 LyXFont const & font = text_.getFont(pit_, pos);
176 return text_.singleWidth(pit_, pos, c, font);
180 LyXFont const RowPainter::getLabelFont() const
182 return text_.getLabelFont(pit_);
186 int RowPainter::leftMargin() const
188 return text_.leftMargin(pit_, row_);
192 void RowPainter::paintInset(pos_type const pos)
194 InsetOld * inset = const_cast<InsetOld*>(pit_->getInset(pos));
198 PainterInfo pi(const_cast<BufferView *>(&bv_));
199 pi.base.font = getFont(pos);
200 inset->draw(pi, int(x_), yo_ + row_.baseline());
201 x_ += inset->width();
205 void RowPainter::paintHebrewComposeChar(pos_type & vpos)
207 pos_type pos = text_.bidi.vis2log(vpos);
212 char c = pit_->getChar(pos);
216 LyXFont const & font = getFont(pos);
217 int const width = font_metrics::width(c, font);
220 for (pos_type i = pos - 1; i >= 0; --i) {
221 c = pit_->getChar(i);
222 if (!Encodings::IsComposeChar_hebrew(c)) {
223 if (IsPrintableNonspace(c)) {
224 int const width2 = singleWidth(i, c);
226 dx = (c == 'ø' || c == 'ã')
228 : (width2 - width) / 2;
235 pain_.text(int(x_) + dx, yo_ + row_.baseline(), str, font);
239 void RowPainter::paintArabicComposeChar(pos_type & vpos)
241 pos_type pos = text_.bidi.vis2log(vpos);
245 char c = pit_->getChar(pos);
246 c = pit_->transformChar(c, pos);
250 LyXFont const & font = getFont(pos);
251 int const width = font_metrics::width(c, font);
254 for (pos_type i = pos - 1; i >= 0; --i) {
255 c = pit_->getChar(i);
256 if (!Encodings::IsComposeChar_arabic(c)) {
257 if (IsPrintableNonspace(c)) {
258 int const width2 = singleWidth(i, c);
259 dx = (width2 - width) / 2;
265 pain_.text(int(x_) + dx, yo_ + row_.baseline(), str, font);
269 void RowPainter::paintChars(pos_type & vpos, bool hebrew, bool arabic)
271 pos_type pos = text_.bidi.vis2log(vpos);
272 pos_type const end = row_.endpos();
273 LyXFont orig_font = getFont(pos);
277 str += pit_->getChar(pos);
279 unsigned char c = str[0];
280 str[0] = pit_->transformChar(c, pos);
283 bool prev_struckout = isDeletedText(*pit_, pos);
284 bool prev_newtext = isInsertedText(*pit_, pos);
286 // collect as much similar chars as we can
287 for (++vpos; vpos < end && (pos = text_.bidi.vis2log(vpos)) >= 0; ++vpos) {
288 char c = pit_->getChar(pos);
290 if (!IsPrintableNonspace(c))
293 if (prev_struckout != isDeletedText(*pit_, pos))
296 if (prev_newtext != isInsertedText(*pit_, pos))
299 if (arabic && Encodings::IsComposeChar_arabic(c))
302 if (hebrew && Encodings::IsComposeChar_hebrew(c))
305 if (orig_font != getFont(pos))
309 c = pit_->transformChar(c, pos);
315 orig_font.setColor(LColor::strikeout);
316 else if (prev_newtext)
317 orig_font.setColor(LColor::newtext);
319 // Draw text and set the new x position
320 //lyxerr << "paint row: yo_ " << yo_ << " baseline: " << row_.baseline()
322 pain_.text(int(x_), yo_ + row_.baseline(), str, orig_font);
323 x_ += font_metrics::width(str, orig_font);
327 void RowPainter::paintForeignMark(double orig_x, LyXFont const & orig_font)
329 if (!lyxrc.mark_foreign_language)
331 if (orig_font.language() == latex_language)
333 if (orig_font.language() == bv_.buffer()->params().language)
336 int const y = yo_ + row_.baseline() + 1;
337 pain_.line(int(orig_x), y, int(x_), y, LColor::language);
341 void RowPainter::paintFromPos(pos_type & vpos)
343 pos_type const pos = text_.bidi.vis2log(vpos);
345 LyXFont const & orig_font = getFont(pos);
347 double const orig_x = x_;
349 char const c = pit_->getChar(pos);
351 if (c == Paragraph::META_INSET) {
354 paintForeignMark(orig_x, orig_font);
358 // usual characters, no insets
360 // special case languages
361 bool const hebrew = (orig_font.language()->lang() == "hebrew");
363 orig_font.language()->lang() == "arabic" &&
364 (lyxrc.font_norm_type == LyXRC::ISO_8859_6_8 ||
365 lyxrc.font_norm_type == LyXRC::ISO_10646_1);
367 // draw as many chars as we can
368 if ((!hebrew && !arabic)
369 || (hebrew && !Encodings::IsComposeChar_hebrew(c))
370 || (arabic && !Encodings::IsComposeChar_arabic(c))) {
371 paintChars(vpos, hebrew, arabic);
373 paintHebrewComposeChar(vpos);
375 paintArabicComposeChar(vpos);
378 paintForeignMark(orig_x, orig_font);
382 void RowPainter::paintBackground()
384 int const x = int(xo_);
385 int const y = yo_ < 0 ? 0 : yo_;
386 int const h = yo_ < 0 ? row_.height() + yo_ : row_.height();
387 pain_.fillRectangle(x, y, width_, h, text_.backgroundColor());
391 void RowPainter::paintSelection()
393 bool const is_rtl = pit_->isRightToLeftPar(bv_.buffer()->params());
395 // the current selection
396 int const startx = text_.selection.start.x();
397 int const endx = text_.selection.end.x();
398 int const starty = text_.selection.start.y();
399 int const endy = text_.selection.end.y();
400 ParagraphList::iterator startpit = text_.getPar(text_.selection.start);
401 ParagraphList::iterator endpit = text_.getPar(text_.selection.end);
402 RowList::iterator startrow = startpit->getRow(text_.selection.start.pos());
403 RowList::iterator endrow = endpit->getRow(text_.selection.end.pos());
404 int const h = row_.height();
406 int const row_y = pit_->y + row_.y_offset();
408 bool const sel_starts_here = startpit == pit_ && startrow == rit_;
409 bool const sel_ends_here = endpit == pit_ && endrow == rit_;
410 bool const sel_on_one_row = sel_starts_here && sel_ends_here;
412 if (text_.bidi.same_direction()) {
415 if (sel_on_one_row) {
417 x = int(xo_) + startx;
423 pain_.fillRectangle(x, yo_, w, h, LColor::selection);
424 } else if (sel_starts_here) {
425 int const x = is_rtl ? int(xo_) : int(xo_ + startx);
426 int const w = is_rtl ? startx : (width_ - startx);
427 pain_.fillRectangle(x, yo_, w, h, LColor::selection);
428 } else if (sel_ends_here) {
429 int const x = is_rtl ? int(xo_ + endx) : int(xo_);
430 int const w = is_rtl ? (width_ - endx) : endx;
431 pain_.fillRectangle(x, yo_, w, h, LColor::selection);
432 } else if (row_y > starty && row_y < endy) {
433 pain_.fillRectangle(int(xo_), yo_, width_, h, LColor::selection);
438 if ((startpit != pit_ && startrow != rit_ && !is_rtl)
439 || (endpit != pit_ && endrow != rit_ && is_rtl))
440 pain_.fillRectangle(int(xo_), yo_,
441 int(x_), h, LColor::selection);
443 pos_type const body_pos = pit_->beginOfBody();
444 pos_type const end = row_.endpos();
447 for (pos_type vpos = row_.pos(); vpos < end; ++vpos) {
448 pos_type pos = text_.bidi.vis2log(vpos);
449 double const old_tmpx = tmpx;
450 if (body_pos > 0 && pos == body_pos - 1) {
451 LyXLayout_ptr const & layout = pit_->layout();
452 LyXFont const lfont = getLabelFont();
454 tmpx += label_hfill_ + font_metrics::width(layout->labelsep, lfont);
456 if (pit_->isLineSeparator(body_pos - 1))
457 tmpx -= singleWidth(body_pos - 1);
460 tmpx += singleWidth(pos);
462 if (hfillExpansion(*pit_, row_, pos)) {
466 tmpx += label_hfill_;
468 if (pit_->isSeparator(pos) && pos >= body_pos)
472 if (((startpit != pit_ && startrow != rit_)
473 || text_.selection.start.pos() <= pos) &&
474 ((endpit != pit_ && endrow != rit_)
475 || pos < text_.selection.end.pos())) {
476 // Here we do not use x_ as xo_ was added to x_.
477 pain_.fillRectangle(int(old_tmpx), yo_,
478 int(tmpx - old_tmpx + 1), h, LColor::selection);
482 if ((startpit != pit_ && startrow != rit_ && is_rtl) ||
483 (endpit != pit_ && endrow != rit_ && !is_rtl)) {
484 pain_.fillRectangle(int(xo_ + tmpx),
485 yo_, int(bv_.workWidth() - tmpx), h, LColor::selection);
490 void RowPainter::paintChangeBar()
492 pos_type const start = row_.pos();
493 pos_type const end = row_.endpos();
495 if (start == end || !pit_->isChanged(start, end - 1))
498 int const height = text_.isLastRow(pit_, row_)
500 : row_.height() + boost::next(rit_)->top_of_text();
502 pain_.fillRectangle(4, yo_, 5, height, LColor::changebar);
506 void RowPainter::paintAppendix()
508 if (!pit_->params().appendix())
511 // FIXME: can be just width_ ?
512 int const ww = bv_.workWidth();
516 if (pit_->params().startOfAppendix())
517 y += 2 * defaultRowHeight();
519 pain_.line(1, y, 1, yo_ + row_.height(), LColor::appendix);
520 pain_.line(ww - 2, y, ww - 2, yo_ + row_.height(), LColor::appendix);
524 void RowPainter::paintDepthBar()
526 Paragraph::depth_type const depth = pit_->getDepth();
531 Paragraph::depth_type prev_depth = 0;
532 if (!text_.isFirstRow(pit_, row_)) {
533 ParagraphList::iterator pit2 = pit_;
536 prev_depth = pit2->getDepth();
539 Paragraph::depth_type next_depth = 0;
540 if (!text_.isLastRow(pit_, row_)) {
541 ParagraphList::iterator pit2 = pit_;
542 if (row_.endpos() >= pit2->size())
544 next_depth = pit2->getDepth();
547 for (Paragraph::depth_type i = 1; i <= depth; ++i) {
548 int const w = PAPER_MARGIN / 5;
549 int x = int(w * i + xo_);
550 // only consider the changebar space if we're drawing outer left
552 x += CHANGEBAR_MARGIN;
553 int const h = yo_ + row_.height() - 1 - (i - next_depth - 1) * 3;
555 pain_.line(x, yo_, x, h, LColor::depthbar);
558 pain_.fillRectangle(x, yo_, w, 2, LColor::depthbar);
560 pain_.fillRectangle(x, h, w, 2, LColor::depthbar);
565 int RowPainter::paintLengthMarker(string const & prefix, VSpace const & vsp,
568 if (vsp.kind() == VSpace::NONE)
571 int const arrow_size = 4;
572 int const size = getLengthMarkerHeight(bv_, vsp);
573 int const end = start + size;
575 // the label to display (if any)
577 // y-values for top arrow
579 // y-values for bottom arrow
582 str = prefix + " (" + vsp.asLyXCommand() + ")";
584 if (vsp.kind() == VSpace::VFILL) {
588 // adding or removing space
589 bool const added = vsp.kind() != VSpace::LENGTH ||
590 vsp.length().len().value() > 0.0;
591 ty1 = added ? (start + arrow_size) : start;
592 ty2 = added ? start : (start + arrow_size);
593 by1 = added ? (end - arrow_size) : end;
594 by2 = added ? end : (end - arrow_size);
597 int const leftx = int(xo_) + leftMargin();
598 int const midx = leftx + arrow_size;
599 int const rightx = midx + arrow_size;
607 font.setColor(LColor::added_space);
610 font_metrics::rectText(str, font, w, a, d);
612 pain_.rectText(leftx + 2 * arrow_size + 5,
613 start + (end - start) / 2 + d,
615 LColor::none, LColor::none);
618 pain_.line(leftx, ty1, midx, ty2, LColor::added_space);
619 pain_.line(midx, ty2, rightx, ty1, LColor::added_space);
622 pain_.line(leftx, by1, midx, by2, LColor::added_space);
623 pain_.line(midx, by2, rightx, by1, LColor::added_space);
626 pain_.line(midx, ty2, midx, by2, LColor::added_space);
632 int RowPainter::paintAppendixStart(int y)
635 pb_font.setColor(LColor::appendix);
638 string const label = _("Appendix");
642 font_metrics::rectText(label, pb_font, w, a, d);
644 int const text_start = int(xo_ + (width_ - w) / 2);
645 int const text_end = text_start + w;
647 pain_.rectText(text_start, y + d, label, pb_font, LColor::none, LColor::none);
649 pain_.line(int(xo_ + 1), y, text_start, y, LColor::appendix);
650 pain_.line(text_end, y, int(xo_ + width_ - 2), y, LColor::appendix);
652 return 3 * defaultRowHeight();
656 void RowPainter::paintFirst()
658 ParagraphParameters const & parparams = pit_->params();
662 // start of appendix?
663 if (parparams.startOfAppendix())
664 y_top += paintAppendixStart(yo_ + y_top + 2 * defaultRowHeight());
667 if (text_.isFirstRow(pit_, row_) && !text_.isInInset())
668 y_top += PAPER_MARGIN;
670 // draw the additional space if needed:
671 y_top += paintLengthMarker(_("Space above"), parparams.spaceTop(),
674 Buffer const & buffer = *bv_.buffer();
676 LyXLayout_ptr const & layout = pit_->layout();
678 if (buffer.params().paragraph_separation == BufferParams::PARSEP_SKIP) {
679 if (pit_ != text_.ownerParagraphs().begin()) {
680 if (layout->latextype == LATEX_PARAGRAPH
681 && !pit_->getDepth()) {
682 y_top += buffer.params().getDefSkip().inPixels(bv_);
684 LyXLayout_ptr const & playout =
685 boost::prior(pit_)->layout();
686 if (playout->latextype == LATEX_PARAGRAPH
687 && !boost::prior(pit_)->getDepth()) {
688 // is it right to use defskip here, too? (AS)
689 y_top += buffer.params().getDefSkip().inPixels(bv_);
695 int const ww = bv_.workWidth();
697 bool const is_rtl = pit_->isRightToLeftPar(bv_.buffer()->params());
698 bool const is_seq = isFirstInSequence(pit_, text_.ownerParagraphs());
699 //lyxerr << "paintFirst: " << pit_->id() << " is_seq: " << is_seq << std::endl;
701 // should we print a label?
702 if (layout->labeltype >= LABEL_STATIC
703 && (layout->labeltype != LABEL_STATIC
704 || layout->latextype != LATEX_ENVIRONMENT
707 LyXFont font = getLabelFont();
708 if (!pit_->getLabelstring().empty()) {
710 string const str = pit_->getLabelstring();
712 // this is special code for the chapter layout. This is
713 // printed in an extra row and has a pagebreak at
715 if (layout->counter == "chapter") {
716 if (buffer.params().secnumdepth >= 0) {
717 float spacing_val = 1.0;
718 if (!parparams.spacing().isDefault()) {
719 spacing_val = parparams.spacing().getValue();
721 spacing_val = buffer.params().spacing().getValue();
725 int(font_metrics::maxDescent(font) * layout->spacing.getValue() * spacing_val)
726 + int(layout->parsep) * defaultRowHeight();
729 x = ww - leftMargin() -
730 font_metrics::width(str, font);
734 yo_ + row_.baseline() -
735 row_.ascent_of_text() - maxdesc,
740 x = ww - leftMargin()
741 + font_metrics::width(layout->labelsep, font);
743 x = x_ - font_metrics::width(layout->labelsep, font)
744 - font_metrics::width(str, font);
747 pain_.text(int(x), yo_ + row_.baseline(), str, font);
751 // the labels at the top of an environment.
752 // More or less for bibliography
754 (layout->labeltype == LABEL_TOP_ENVIRONMENT ||
755 layout->labeltype == LABEL_BIBLIO ||
756 layout->labeltype == LABEL_CENTERED_TOP_ENVIRONMENT)) {
757 LyXFont font = getLabelFont();
758 if (!pit_->getLabelstring().empty()) {
759 string const str = pit_->getLabelstring();
760 float spacing_val = 1.0;
761 if (!parparams.spacing().isDefault()) {
762 spacing_val = parparams.spacing().getValue();
764 spacing_val = buffer.params().spacing().getValue();
768 int(font_metrics::maxDescent(font) * layout->spacing.getValue() * spacing_val
769 + (layout->labelbottomsep * defaultRowHeight()));
772 if (layout->labeltype == LABEL_CENTERED_TOP_ENVIRONMENT) {
773 x = ((is_rtl ? leftMargin() : x_)
774 + ww - text_.rightMargin(*pit_, *bv_.buffer())) / 2;
775 x -= font_metrics::width(str, font) / 2;
777 x = ww - leftMargin() -
778 font_metrics::width(str, font);
781 yo_ + row_.baseline() - row_.ascent_of_text() - maxdesc,
788 void RowPainter::paintLast()
790 ParagraphParameters const & parparams = pit_->params();
791 int y_bottom = row_.height() - 1;
794 if (text_.isLastRow(pit_, row_) && !text_.isInInset())
795 y_bottom -= PAPER_MARGIN;
797 int const ww = bv_.workWidth();
799 // draw the additional space if needed:
800 int const height = getLengthMarkerHeight(bv_, parparams.spaceBottom());
801 y_bottom -= paintLengthMarker(_("Space below"), parparams.spaceBottom(),
802 yo_ + y_bottom - height);
804 bool const is_rtl = pit_->isRightToLeftPar(bv_.buffer()->params());
805 int const endlabel = getEndLabel(pit_, text_.ownerParagraphs());
810 case END_LABEL_FILLED_BOX: {
811 LyXFont const font = getLabelFont();
812 int const size = int(0.75 * font_metrics::maxAscent(font));
813 int const y = yo_ + row_.baseline() - size;
814 int x = is_rtl ? LEFT_MARGIN : ww - PAPER_MARGIN - size;
816 if (row_.fill() <= size)
817 x += (size - row_.fill() + 1) * (is_rtl ? -1 : 1);
819 if (endlabel == END_LABEL_BOX)
820 pain_.rectangle(x, y, size, size, LColor::eolmarker);
822 pain_.fillRectangle(x, y, size, size, LColor::eolmarker);
826 case END_LABEL_STATIC: {
827 LyXFont font = getLabelFont();
828 string const & str = pit_->layout()->endlabelstring();
829 double const x = is_rtl ?
830 x_ - font_metrics::width(str, font)
831 : ww - text_.rightMargin(*pit_, *bv_.buffer()) - row_.fill();
832 pain_.text(int(x), yo_ + row_.baseline(), str, font);
836 case END_LABEL_NO_LABEL:
842 void RowPainter::paintText()
844 pos_type const end = row_.endpos();
845 pos_type body_pos = pit_->beginOfBody();
847 (body_pos > end || !pit_->isLineSeparator(body_pos - 1))) {
851 LyXLayout_ptr const & layout = pit_->layout();
853 bool running_strikeout = false;
854 bool is_struckout = false;
855 int last_strikeout_x = 0;
857 for (pos_type vpos = row_.pos(); vpos < end; ) {
858 if (x_ > bv_.workWidth())
861 pos_type pos = text_.bidi.vis2log(vpos);
863 if (pos >= pit_->size()) {
868 if (x_ + singleWidth(pos) < 0) {
869 x_ += singleWidth(pos);
874 is_struckout = isDeletedText(*pit_, pos);
876 if (is_struckout && !running_strikeout) {
877 running_strikeout = true;
878 last_strikeout_x = int(x_);
881 bool const highly_editable_inset = pit_->isInset(pos)
882 && isHighlyEditableInset(pit_->getInset(pos));
884 // if we reach the end of a struck out range, paint it
885 // we also don't paint across things like tables
886 if (running_strikeout && (highly_editable_inset || !is_struckout)) {
887 int const middle = yo_ + (row_.baseline() + row_.top_of_text()) / 2;
888 pain_.line(last_strikeout_x, middle, int(x_), middle,
889 LColor::strikeout, Painter::line_solid, Painter::line_thin);
890 running_strikeout = false;
893 if (body_pos > 0 && pos == body_pos - 1) {
894 int const lwidth = font_metrics::width(layout->labelsep,
897 x_ += label_hfill_ + lwidth - singleWidth(body_pos - 1);
900 if (pit_->isHfill(pos)) {
903 int const y0 = yo_ + row_.baseline();
904 int const y1 = y0 - defaultRowHeight() / 2;
906 pain_.line(int(x_), y1, int(x_), y0, LColor::added_space);
908 if (hfillExpansion(*pit_, row_, pos)) {
909 int const y2 = (y0 + y1) / 2;
911 if (pos >= body_pos) {
912 pain_.line(int(x_), y2, int(x_ + hfill_), y2,
914 Painter::line_onoffdash);
917 pain_.line(int(x_), y2, int(x_ + label_hfill_), y2,
919 Painter::line_onoffdash);
922 pain_.line(int(x_), y1, int(x_), y0, LColor::added_space);
926 } else if (pit_->isSeparator(pos)) {
927 x_ += singleWidth(pos);
936 // if we reach the end of a struck out range, paint it
937 if (running_strikeout) {
938 int const middle = yo_ + (row_.baseline() + row_.top_of_text()) / 2;
939 pain_.line(last_strikeout_x, middle, int(x_), middle,
940 LColor::strikeout, Painter::line_solid, Painter::line_thin);
941 running_strikeout = false;
946 int paintPars(BufferView const & bv, LyXText const & text,
947 ParagraphList::iterator pit, int xo, int yo, int y)
949 //lyxerr << " paintRows: pit: " << &*pit << endl;
950 int const y2 = bv.painter().paperHeight();
953 ParagraphList::iterator end = text.ownerParagraphs().end();
955 for ( ; pit != end; ++pit) {
956 RowList::iterator row = pit->rows.begin();
957 RowList::iterator rend = pit->rows.end();
959 for ( ; row != rend; ++row) {
960 RowPainter(bv, text, pit, row, xo, y + yo);
973 int paintText(BufferView & bv)
975 ParagraphList::iterator pit;
976 bv.text->getRowNearY(bv.top_y(), pit);
977 return paintPars(bv, *bv.text, pit, 0, 0, pit->y);
981 void paintTextInset(BufferView & bv, LyXText & text, int xo, int yo)
983 paintPars(bv, text, text.ownerParagraphs().begin(), xo, yo, 0);
987 int getLengthMarkerHeight(BufferView const & bv, VSpace const & vsp)
989 if (vsp.kind() == VSpace::NONE)
992 int const arrow_size = 4;
993 int const space_size = vsp.inPixels(bv);
997 int const min_size = max(3 * arrow_size, font_metrics::maxHeight(font));
999 if (vsp.length().len().value() < 0.0)
1002 return max(min_size, space_size);