-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(*pit_);
-
- // the current selection
- LCursor const & cur = bv_.cursor();
- int const startx = text_.cursorX(cur.selBegin());
- int const endx = text_.cursorX(cur.selEnd());
- int const starty = text_.cursorY(cur.selBegin());
- int const endy = text_.cursorY(cur.selEnd());
- ParagraphList::iterator startpit = text_.getPar(cur.selBegin());
- ParagraphList::iterator endpit = text_.getPar(cur.selEnd());
- RowList::iterator startrow = startpit->getRow(cur.selBegin().pos());
- RowList::iterator endrow = endpit->getRow(cur.selEnd().pos());
- int const h = row_.height();
-
- int const row_y = text_.yo_ + pit_->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()) {
- int x;
- int w;
- if (sel_on_one_row) {
- if (startx < endx) {
- x = startx;
- w = endx - startx;
- } else {
- x = endx;
- w = startx - endx;
- }
- pain_.fillRectangle(x, yo_, w, h, LColor::selection);
- } else if (sel_starts_here) {
- int const x = is_rtl ? 0 : startx;
- int const w = is_rtl ? startx : (width_ - startx);
- pain_.fillRectangle(x, yo_, w, h, LColor::selection);
- } else if (sel_ends_here) {
- int const x = is_rtl ? endx : 0;
- int const w = is_rtl ? (width_ - endx) : endx;
- pain_.fillRectangle(x, yo_, w, 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 = pit_->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 = pit_->layout();
- LyXFont const lfont = getLabelFont();
-
- tmpx += label_hfill_ + font_metrics::width(layout->labelsep, lfont);
-
- if (pit_->isLineSeparator(body_pos - 1))
- tmpx -= singleWidth(body_pos - 1);
- }
-
- tmpx += singleWidth(pos);
-
- if (hfillExpansion(*pit_, row_, pos)) {
- if (pos >= body_pos)
- tmpx += hfill_;
- else
- tmpx += label_hfill_;
- } else {
- if (pit_->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);
- }
-}
-
-