-
- 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();
- RowList::iterator startrow = text_.getRow(text_.selection.start);
- RowList::iterator endrow = text_.getRow(text_.selection.end);
-
- if (text_.bidi_same_direction) {
- int x;
- int y = yo_;
- int w;
- int h = row_->height();
-
- if (startrow == row_ && endrow == row_) {
- if (startx < endx) {
- x = int(xo_) + startx;
- w = endx - startx;
- pain_.fillRectangle(x, y, w, h, LColor::selection);
- } else {
- x = int(xo_) + endx;
- w = startx - endx;
- pain_.fillRectangle(x, y, w, h, LColor::selection);
- }
- } else if (startrow == row_) {
- 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 == row_) {
- 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;
- } else if (startrow != row_ && endrow != row_) {
- if (y_ > starty && y_ < endy) {
- int w = width_;
- int h = row_->height();
- pain_.fillRectangle(int(xo_), yo_, w, h, LColor::selection);
- }
- return;
- }
-
- if ((startrow != row_ && !is_rtl) || (endrow != row_ && is_rtl))
- pain_.fillRectangle(int(xo_), yo_,
- int(x_), row_->height(), LColor::selection);
-
- pos_type const body_pos = pit_->beginningOfBody();
- pos_type const last = lastPrintablePos(text_, row_);
- double tmpx = x_;
-
- for (pos_type vpos = row_->pos(); vpos <= last; ++vpos) {
- pos_type pos = text_.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(text_, 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 != row_ || text_.selection.start.pos() <= pos) &&
- (endrow != row_ || 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),
- row_->height(), LColor::selection);
- }
- }
-
- if ((startrow != row_ && is_rtl) || (endrow != row_ && !is_rtl)) {
- pain_.fillRectangle(int(xo_ + tmpx),
- yo_, int(bv_.workWidth() - tmpx),
- row_->height(), LColor::selection);
- }