- if (selection.set()) {
- int const w = (inset_owner ?
- inset_owner->width(bview, font) : ww);
- // selection code
- if (bidi_same_direction) {
- if (selection.start.row() == row_ptr &&
- selection.end.row() == row_ptr) {
- if (selection.start.x() < selection.end.x())
- pain.fillRectangle(x_offset + selection.start.x(),
- y_offset,
- selection.end.x() - selection.start.x(),
- row_ptr->height(),
- LColor::selection);
- else
- pain.fillRectangle(x_offset + selection.end.x(),
- y_offset,
- selection.start.x() - selection.end.x(),
- row_ptr->height(),
- LColor::selection);
- } else if (selection.start.row() == row_ptr) {
- if (is_rtl)
- pain.fillRectangle(x_offset, y_offset,
- selection.start.x(),
- row_ptr->height(),
- LColor::selection);
- else
- pain.fillRectangle(x_offset + selection.start.x(),
- y_offset,
- w - selection.start.x(),
- row_ptr->height(),
- LColor::selection);
- } else if (selection.end.row() == row_ptr) {
- if (is_rtl)
- pain.fillRectangle(x_offset + selection.end.x(),
- y_offset,
- w - selection.end.x(),
- row_ptr->height(),
- LColor::selection);
- else
- pain.fillRectangle(x_offset, y_offset,
- selection.end.x(),
- row_ptr->height(),
- LColor::selection);
- } else if (y > selection.start.y()
- && y < selection.end.y()) {
- pain.fillRectangle(x_offset, y_offset, w,
- row_ptr->height(),
- LColor::selection);
- }
- } else if (selection.start.row() != row_ptr &&
- selection.end.row() != row_ptr &&
- y > selection.start.y()
- && y < selection.end.y()) {
- pain.fillRectangle(x_offset, y_offset, w,
- row_ptr->height(),
- LColor::selection);
- } else if (selection.start.row() == row_ptr ||
- selection.end.row() == row_ptr) {
- float tmpx = x;
- if ((selection.start.row() != row_ptr && !is_rtl) ||
- (selection.end.row() != row_ptr && is_rtl))
- pain.fillRectangle(x_offset, y_offset,
- int(tmpx),
- row_ptr->height(),
- LColor::selection);
- Paragraph::size_type main_body =
- beginningOfMainBody(bview->buffer(),
- row_ptr->par());
-
- for (vpos = row_ptr->pos(); vpos <= last; ++vpos) {
- pos = vis2log(vpos);
- float const old_tmpx = tmpx;
- if (main_body > 0 && pos == main_body-1) {
- tmpx += fill_label_hfill +
- lyxfont::width(textclasslist.Style(bview->buffer()->params.textclass,
- row_ptr->par()->getLayout()).labelsep,
- getFont(bview->buffer(),row_ptr->par(), -2));
- if (row_ptr->par()->isLineSeparator(main_body-1))
- tmpx -= singleWidth(bview, row_ptr->par(), main_body-1);
- }
- if (hfillExpansion(bview->buffer(), row_ptr, pos)) {
- tmpx += singleWidth(bview, row_ptr->par(), pos);
- if (pos >= main_body)
- tmpx += fill_hfill;
- else
- tmpx += fill_label_hfill;
- }
- else if (row_ptr->par()->isSeparator(pos)) {
- tmpx += singleWidth(bview, row_ptr->par(), pos);
- if (pos >= main_body)
- tmpx += fill_separator;
- } else
- tmpx += singleWidth(bview, row_ptr->par(), pos);
-
- if ((selection.start.row() != row_ptr ||
- selection.start.pos() <= pos) &&
- (selection.end.row() != row_ptr ||
- pos < selection.end.pos()) )
- // Here we do not use x_offset as x_offset was
- // added to x.
- pain.fillRectangle(int(old_tmpx),
- y_offset,
- int(tmpx - old_tmpx + 1),
- row_ptr->height(),
- LColor::selection);
- }