X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FRowPainter.cpp;h=a88ac2a6be39bd7a8bd2794aee1f9fdf6b2aaf6f;hb=55012674c87bae73da86b64148427b0e6e3c58f4;hp=149288b2f6c0e479824dc24b0526e981b392239c;hpb=7485225cc6f26c9e03d3674f4f361b431074fa6e;p=lyx.git diff --git a/src/RowPainter.cpp b/src/RowPainter.cpp index 149288b2f6..a88ac2a6be 100644 --- a/src/RowPainter.cpp +++ b/src/RowPainter.cpp @@ -269,6 +269,21 @@ void RowPainter::paintStringAndSel(Row::Element const & e) const } +void RowPainter::paintTextDecoration(Row::Element const & e) const +{ + // element selected? + bool const sel = (e.pos >= row_.sel_beg && e.endpos <= row_.sel_end) + || pi_.selected; + FontInfo copy = e.font.fontInfo(); + if (sel || e.change.changed()) { + Color const col = e.change.changed() ? e.change.color() + : Color_selectiontext; + copy.setPaintColor(col); + } + pi_.pain.textDecoration(copy, int(x_), yo_, int(e.full_width())); +} + + void RowPainter::paintChange(Row::Element const & e) const { e.change.paintCue(pi_, x_, yo_, x_ + e.full_width(), e.font.fontInfo()); @@ -414,14 +429,10 @@ void RowPainter::paintLabel() const Layout const & layout = par_.layout(); FontInfo const font = labelFont(false); FontMetrics const & fm = theFontMetrics(font); - double x = x_; - - if (row_.isRTL()) - x = tm_.width() - row_.right_margin + fm.width(layout.labelsep); - else - x = x_ - fm.width(layout.labelsep) - fm.width(str); + int const x = row_.isRTL() ? row_.width() + fm.width(layout.labelsep) + : row_.left_margin - fm.width(layout.labelsep) - fm.width(str); - pi_.pain.text(int(x), yo_, str, font); + pi_.pain.text(int(xo_) + x, yo_, str, font); } @@ -452,10 +463,10 @@ void RowPainter::paintTopLevelLabel() const double x = x_; if (layout.labeltype == LABEL_CENTERED) { - x = row_.left_margin + (tm_.width() - row_.left_margin - row_.right_margin) / 2; + x += (tm_.width() - row_.left_margin - row_.right_margin) / 2; x -= fm.width(str) / 2; } else if (row_.isRTL()) { - x = tm_.width() - row_.right_margin - fm.width(str); + x = xo_ + tm_.width() - row_.right_margin - fm.width(str); } pi_.pain.text(int(x), yo_ - maxdesc - labeladdon, str, font); } @@ -496,30 +507,6 @@ static int getEndLabel(pit_type p, Text const & text) void RowPainter::paintLast() const { int const endlabel = getEndLabel(row_.pit(), text_); - - // paint imaginary end-of-paragraph character - - Change const & change = par_.lookupChange(par_.size()); - if (change.changed()) { - FontMetrics const & fm = - theFontMetrics(pi_.base.bv->buffer().params().getFont()); - int const length = fm.maxAscent() / 2; - Color col = change.color(); - - pi_.pain.line(int(x_) + 1, yo_ + 2, int(x_) + 1, yo_ + 2 - length, col, - Painter::line_solid, 3); - - if (change.deleted()) { - pi_.pain.line(int(x_) + 1 - length, yo_ + 2, int(x_) + 1 + length, - yo_ + 2, col, Painter::line_solid, 3); - } else { - pi_.pain.line(int(x_) + 1 - length, yo_ + 2, int(x_) + 1, - yo_ + 2, col, Painter::line_solid, 3); - } - } - - // draw an endlabel - switch (endlabel) { case END_LABEL_BOX: case END_LABEL_FILLED_BOX: { @@ -542,9 +529,9 @@ void RowPainter::paintLast() const } if (endlabel == END_LABEL_BOX) - pi_.pain.rectangle(x, y, size, size, font.realColor()); + pi_.pain.rectangle(int(xo_) + x, y, size, size, font.realColor()); else - pi_.pain.fillRectangle(x, y, size, size, font.realColor()); + pi_.pain.fillRectangle(int(xo_) + x, y, size, size, font.realColor()); break; } @@ -565,10 +552,7 @@ void RowPainter::paintLast() const void RowPainter::paintOnlyInsets() { - Row::const_iterator cit = row_.begin(); - Row::const_iterator const & end = row_.end(); - for ( ; cit != end ; ++cit) { - Row::Element const & e = *cit; + for (Row::Element const & e : row_) { if (e.type == Row::INSET) { paintInset(e); // The markings of foreign languages @@ -586,11 +570,7 @@ void RowPainter::paintOnlyInsets() void RowPainter::paintText() { - Row::const_iterator cit = row_.begin(); - Row::const_iterator const & end = row_.end(); - for ( ; cit != end ; ++cit) { - Row::Element const & e = *cit; - + for (Row::Element const & e : row_) { switch (e.type) { case Row::STRING: case Row::VIRTUAL: @@ -603,10 +583,11 @@ void RowPainter::paintText() case Row::INSET: paintInset(e); + paintTextDecoration(e); break; case Row::SPACE: - pi_.pain.textDecoration(e.font.fontInfo(), int(x_), yo_, int(e.full_width())); + paintTextDecoration(e); } // The markings of foreign languages