]> git.lyx.org Git - lyx.git/blobdiff - src/RowPainter.cpp
Update buffer after preferences change.
[lyx.git] / src / RowPainter.cpp
index 3b4c76b6c6a0125b822ee1dd905a3ec718697a7b..efc4021c1b88f91da19f4d3241f336adc34a03ac 100644 (file)
@@ -73,11 +73,12 @@ RowPainter::RowPainter(PainterInfo & pi,
 }
 
 
-FontInfo RowPainter::labelFont() const
+FontInfo RowPainter::labelFont(bool end) const
 {
        FontInfo f = text_.labelFont(par_);
        // selected text?
-       if (row_.begin_margin_sel || pi_.selected)
+       if ((end ? row_.end_margin_sel : row_.begin_margin_sel)
+           || pi_.selected)
                f.setPaintColor(Color_selectiontext);
        return f;
 }
@@ -138,6 +139,13 @@ void RowPainter::paintInset(Row::Element const & e) const
 }
 
 
+void RowPainter::paintLanguageMarkings(Row::Element const & e) const
+{
+       paintForeignMark(e);
+       paintNoSpellingMark(e);
+}
+
+
 void RowPainter::paintForeignMark(Row::Element const & e) const
 {
        Language const * lang = e.font.language();
@@ -149,15 +157,38 @@ void RowPainter::paintForeignMark(Row::Element const & e) const
                return;
 
        int const desc = e.inset ? e.dim.descent() : 0;
-       int const y = yo_ + pi_.base.solidLineOffset()
-               + desc + pi_.base.solidLineThickness() / 2;
-       pi_.pain.line(int(x_), y, int(x_ + e.full_width()), y, Color_language,
+       int const y = yo_ + min(3 * pi_.base.solidLineOffset() / 2 + desc,
+                               row_.descent() - 1);
+       pi_.pain.line(int(x_), y, int(x_ + e.full_width() - 1), y, Color_language,
                      Painter::line_solid, pi_.base.solidLineThickness());
 }
 
 
+void RowPainter::paintNoSpellingMark(Row::Element const & e) const
+{
+       //if (!lyxrc.mark_no_spelling)
+       //      return;
+       if (e.font.language() == latex_language)
+               return;
+       if (e.font.fontInfo().nospellcheck() != FONT_ON)
+               return;
+
+       // We at the same voffset than the misspelled mark, since
+       // these two are mutually exclusive
+       int const desc = e.inset ? e.dim.descent() : 0;
+       int const y = yo_ + pi_.base.solidLineOffset() + desc
+               + pi_.base.solidLineThickness()
+               + (e.change.changed() ? pi_.base.solidLineThickness() + 1 : 0)
+               + 1;
+       pi_.pain.line(int(x_), y, int(x_ + e.full_width()), y, Color_language,
+                     Painter::line_onoffdash, pi_.base.solidLineThickness());
+}
+
+
 void RowPainter::paintMisspelledMark(Row::Element const & e) const
 {
+       if (e.font.fontInfo().nospellcheck() == FONT_ON)
+               return;
        // if changed the misspelled marker gets placed slightly lower than normal
        // to avoid drawing at the same vertical offset
        FontMetrics const & fm = theFontMetrics(e.font);
@@ -272,13 +303,7 @@ void RowPainter::paintAppendix() const
 
 void RowPainter::paintDepthBar() const
 {
-       depth_type depth = par_.getDepth();
-
-       // We also mark follow-up paragraphs in a paragraph group
-       if (par_.layout().isParagraphGroup()
-           && par_.layout().labeltype == LABEL_STATIC
-           && !text_.isFirstInSequence(row_.pit()))
-               ++depth;
+       depth_type const depth = par_.getDepth();
 
        if (depth <= 0)
                return;
@@ -289,11 +314,6 @@ void RowPainter::paintDepthBar() const
                if (row_.pos() == 0)
                        --pit2;
                prev_depth = pars_[pit2].getDepth();
-               // We also mark follow-up paragraphs in a paragraph group
-               if (pars_[pit2].layout().isParagraphGroup()
-                   && pars_[pit2].layout().labeltype == LABEL_STATIC
-                   && !text_.isFirstInSequence(pit2))
-                       ++prev_depth;
        }
 
        depth_type next_depth = 0;
@@ -302,11 +322,6 @@ void RowPainter::paintDepthBar() const
                if (row_.endpos() >= pars_[pit2].size())
                        ++pit2;
                next_depth = pars_[pit2].getDepth();
-               // We also mark follow-up paragraphs in a paragraph group
-               if (pars_[pit2].layout().isParagraphGroup()
-                   && pars_[pit2].layout().labeltype == LABEL_STATIC
-                   && !text_.isFirstInSequence(pit2))
-                       ++next_depth;
        }
 
        for (depth_type i = 1; i <= depth; ++i) {
@@ -397,7 +412,7 @@ void RowPainter::paintLabel() const
                return;
 
        Layout const & layout = par_.layout();
-       FontInfo const font = labelFont();
+       FontInfo const font = labelFont(false);
        FontMetrics const & fm = theFontMetrics(font);
        double x = x_;
 
@@ -415,7 +430,7 @@ void RowPainter::paintTopLevelLabel() const
        BufferParams const & bparams = pi_.base.bv->buffer().params();
        ParagraphParameters const & pparams = par_.params();
        Layout const & layout = par_.layout();
-       FontInfo const font = labelFont();
+       FontInfo const font = labelFont(false);
        docstring const str = par_.labelString();
        if (str.empty())
                return;
@@ -508,7 +523,9 @@ void RowPainter::paintLast() const
        switch (endlabel) {
        case END_LABEL_BOX:
        case END_LABEL_FILLED_BOX: {
-               FontInfo const font = labelFont();
+               FontInfo font = labelFont(true);
+               if (font.realColor() != Color_selectiontext)
+                       font.setPaintColor(Color_eolmarker);
                FontMetrics const & fm = theFontMetrics(font);
                int const size = int(0.75 * fm.maxAscent());
                int const y = yo_ - size;
@@ -525,14 +542,14 @@ void RowPainter::paintLast() const
                }
 
                if (endlabel == END_LABEL_BOX)
-                       pi_.pain.rectangle(x, y, size, size, Color_eolmarker);
+                       pi_.pain.rectangle(x, y, size, size, font.realColor());
                else
-                       pi_.pain.fillRectangle(x, y, size, size, Color_eolmarker);
+                       pi_.pain.fillRectangle(x, y, size, size, font.realColor());
                break;
        }
 
        case END_LABEL_STATIC: {
-               FontInfo const font = labelFont();
+               FontInfo const font = labelFont(true);
                FontMetrics const & fm = theFontMetrics(font);
                docstring const & str = par_.layout().endlabelstring();
                double const x = row_.isRTL() ? x_ - fm.width(str) : x_;
@@ -554,8 +571,9 @@ void RowPainter::paintOnlyInsets()
                Row::Element const & e = *cit;
                if (e.type == Row::INSET) {
                        paintInset(e);
-                       // The line that indicates word in a different language
-                       paintForeignMark(e);
+                       // The markings of foreign languages
+                       // and of text ignored for spellchecking
+                       paintLanguageMarkings(e);
                        // change tracking (not for insets that handle it themselves)
                        if (!e.inset->canPaintChange(*pi_.base.bv))
                                paintChange(e);
@@ -591,8 +609,9 @@ void RowPainter::paintText()
                        pi_.pain.textDecoration(e.font.fontInfo(), int(x_), yo_, int(e.full_width()));
                }
 
-               // The line that indicates word in a different language
-               paintForeignMark(e);
+               // The markings of foreign languages
+               // and of text ignored for spellchecking
+               paintLanguageMarkings(e);
 
                // change tracking (not for insets that handle it themselves)
                if (e.type != Row::INSET || ! e.inset->canPaintChange(*pi_.base.bv))