-
- return;
-}
-
-
-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 = pit_->isRightToLeftPar(bv_.buffer()->params());
-
- // the current selection
- int const startx = text_.selection.start.x();
- int const endx = text_.selection.end.x();
- int const starty = text_.selection.start.y();
- int const endy = text_.selection.end.y();
- ParagraphList::iterator startpit = text_.getPar(text_.selection.start);
- ParagraphList::iterator endpit = text_.getPar(text_.selection.end);
- RowList::iterator startrow = startpit->getRow(text_.selection.start.pos());
- RowList::iterator endrow = endpit->getRow(text_.selection.end.pos());
- int const h = row_.height();
-
- if (text_.bidi.same_direction()) {
- int x;
- int y = yo_;
- int w;
-
- if (startrow == rit_ && endrow == rit_) {
- if (startx < endx) {
- x = int(xo_) + startx;
- w = endx - startx;
- } else {
- x = int(xo_) + endx;
- w = startx - endx;
- }
- pain_.fillRectangle(x, y, w, h, LColor::selection);
- } else if (startrow == rit_) {
- int const x = is_rtl ? int(xo_) : int(xo_ + startx);
- int const w = is_rtl ? startx : (width_ - startx);
- pain_.fillRectangle(x, y, w, h, LColor::selection);
- } else if (endrow == rit_) {
- int const x = is_rtl ? int(xo_ + endx) : int(xo_);
- int const w = is_rtl ? (width_ - endx) : endx;
- pain_.fillRectangle(x, y, w, h, LColor::selection);
- } else if (y_ > starty && y_ < endy) {
- pain_.fillRectangle(int(xo_), y, width_, h, LColor::selection);
- }
- return;
- }
-
- if (startrow != rit_ && endrow != rit_) {
- if (y_ > starty && y_ < endy) {
- int w = width_;
- pain_.fillRectangle(int(xo_), yo_, w, h, LColor::selection);
- }
- return;
- }
-
- if ((startrow != rit_ && !is_rtl) || (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);
- }
-
- if (hfillExpansion(*pit_, row_, pos)) {
- tmpx += singleWidth(pos);
- if (pos >= body_pos)
- tmpx += hfill_;
- else
- tmpx += label_hfill_;
- }
-
- else if (pit_->isSeparator(pos)) {
- tmpx += singleWidth(pos);
- if (pos >= body_pos)
- tmpx += separator_;
- } else {
- tmpx += singleWidth(pos);
- }
-
- if ((startrow != rit_ || text_.selection.start.pos() <= pos) &&
- (endrow != rit_ || pos < text_.selection.end.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 ((startrow != rit_ && is_rtl) || (endrow != rit_ && !is_rtl)) {
- pain_.fillRectangle(int(xo_ + tmpx),
- yo_, int(bv_.workWidth() - tmpx), h, LColor::selection);
- }