-void RowPainter::paintBackground()
-{
- int const x = int(xo_);
- int const y = yo_ < 0 ? 0 : yo_;
- int const h = yo_ < 0 ? row_.height() + yo_ : row_.height();
- pain_.fillRectangle(x, y, width_, h, text_.backgroundColor());
-}
-
-
-void RowPainter::paintSelection()
-{
- bool const is_rtl = text_.isRTL(par_);
-
- // the current selection
- LCursor const & cur = bv_.cursor();
- int const starty = text_.cursorY(cur.selBegin());
- int const endy = text_.cursorY(cur.selEnd());
- pit_type startpit = cur.selBegin().pit();
- pit_type endpit = cur.selEnd().pit();
- RowList::iterator startrow = pars_[startpit].getRow(cur.selBegin().pos());
- RowList::iterator endrow = pars_[endpit].getRow(cur.selEnd().pos());
- int const h = row_.height();
-
- int const row_y = text_.yo_ + par_.y + row_.y_offset();
-
- bool const sel_starts_here = startpit == pit_ && startrow == rit_;
- bool const sel_ends_here = endpit == pit_ && endrow == rit_;
- bool const sel_on_one_row = sel_starts_here && sel_ends_here;
-
- if (text_.bidi.same_direction()) {
- if (sel_on_one_row) {
- int const startx = text_.cursorX(cur.selBegin());
- int const endx = text_.cursorX(cur.selEnd());
- int const x1 = is_rtl ? endx : startx;
- int const x2 = is_rtl ? startx : endx;
- pain_.fillRectangle(x1, yo_, x2 - x1, h, LColor::selection);
- } else if (sel_starts_here) {
- int const startx = text_.cursorX(cur.selBegin());
- int const x1 = is_rtl ? int(xo_) : startx;
- int const x2 = is_rtl ? startx : int(xo_) + width_;
- pain_.fillRectangle(x1, yo_, x2 - x1, h, LColor::selection);
- } else if (sel_ends_here) {
- int const endx = text_.cursorX(cur.selEnd());
- int const x1 = is_rtl ? endx : int(xo_);
- int const x2 = is_rtl ? int(xo_) + width_ : endx;
- pain_.fillRectangle(x1, yo_, x2 - x1, h, LColor::selection);
- } else if (row_y > starty && row_y < endy) {
- pain_.fillRectangle(int(xo_), yo_, width_, h, LColor::selection);
- }
- return;
- }
-
- if ((startpit != pit_ && startrow != rit_ && !is_rtl)
- || (endpit != pit_ && endrow != rit_ && is_rtl))
- pain_.fillRectangle(int(xo_), yo_,
- int(x_), h, LColor::selection);
-
- pos_type const body_pos = par_.beginOfBody();
- pos_type const end = row_.endpos();
- double tmpx = x_;
-
- for (pos_type vpos = row_.pos(); vpos < end; ++vpos) {
- pos_type pos = text_.bidi.vis2log(vpos);
- double const old_tmpx = tmpx;
- if (body_pos > 0 && pos == body_pos - 1) {
- LyXLayout_ptr const & layout = par_.layout();
- LyXFont const lfont = getLabelFont();
-
- tmpx += label_hfill_ + font_metrics::width(layout->labelsep, lfont);
-
- if (par_.isLineSeparator(body_pos - 1))
- tmpx -= singleWidth(body_pos - 1);
- }
-
- tmpx += singleWidth(pos);
-
- if (hfillExpansion(par_, row_, pos)) {
- if (pos >= body_pos)
- tmpx += hfill_;
- else
- tmpx += label_hfill_;
- } else {
- if (par_.isSeparator(pos) && pos >= body_pos)
- tmpx += separator_;
- }
-
- if (((startpit != pit_ && startrow != rit_)
- || cur.selBegin().pos() <= pos) &&
- ((endpit != pit_ && endrow != rit_)
- || pos < cur.selEnd().pos())) {
- // Here we do not use x_ as xo_ was added to x_.
- pain_.fillRectangle(int(old_tmpx), yo_,
- int(tmpx - old_tmpx + 1), h, LColor::selection);
- }
- }
-
- if ((startpit != pit_ && startrow != rit_ && is_rtl) ||
- (endpit != pit_ && endrow != rit_ && !is_rtl)) {
- pain_.fillRectangle(int(xo_ + tmpx),
- yo_, int(width_ - tmpx), h, LColor::selection);
- }
-}
-
-