X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FMetricsInfo.cpp;h=2b954d3ed96d12926f78963c9f84cfb74587c6aa;hb=ee41b0f1930604e73f0525864cf3846e7459a449;hp=05fc0658b1cc39e5ca35f78bc3e2bd8227f7d6db;hpb=c88eaf877ec9b9f7e41658af5b4b3b55e6078cd6;p=lyx.git diff --git a/src/MetricsInfo.cpp b/src/MetricsInfo.cpp index 05fc0658b1..2b954d3ed9 100644 --- a/src/MetricsInfo.cpp +++ b/src/MetricsInfo.cpp @@ -66,7 +66,7 @@ MetricsInfo::MetricsInfo(BufferView * bv, FontInfo const & font, int textwidth, PainterInfo::PainterInfo(BufferView * bv, lyx::frontend::Painter & painter) : pain(painter), ltr_pos(false), change_(), selected(false), - full_repaint(true), background_color(Color_background) + do_spellcheck(true), full_repaint(true), background_color(Color_background) { base.bv = bv; } @@ -107,6 +107,16 @@ ColorCode PainterInfo::backgroundColor(Inset const * inset, bool sel) const } +Color PainterInfo::textColor(Color const & color) const +{ + if (change_.changed()) + return change_.color(); + if (selected) + return Color_selectiontext; + return color; +} + + ///////////////////////////////////////////////////////////////////////// // // ScriptChanger @@ -176,9 +186,8 @@ ArrayChanger::ArrayChanger(MetricsBase & mb) ///////////////////////////////////////////////////////////////////////// ShapeChanger::ShapeChanger(FontInfo & font, FontShape shape) - : Changer(font) + : Changer(font, font.shape()) { - save_ = orig_.shape(); orig_.setShape(shape); } @@ -203,7 +212,6 @@ StyleChanger::StyleChanger(MetricsBase & mb, Styles style) { 0, 0, -3, -5 }, { 3, 3, 0, -2 }, { 5, 5, 2, 0 } }; - save_ = mb; int t = diff[mb.style][style]; if (t > 0) while (t--) @@ -232,14 +240,17 @@ FontSetChanger::FontSetChanger(MetricsBase & mb, char const * name, : Changer(mb), change_(really_change_font) { if (change_) { - save_ = mb; FontSize oldsize = save_.font.size(); ColorCode oldcolor = save_.font.color(); + docstring const oldname = from_ascii(save_.fontname); mb.fontname = name; mb.font = sane_font; augmentFont(mb.font, from_ascii(name)); mb.font.setSize(oldsize); - mb.font.setColor(oldcolor); + if (string(name) != "lyxtex" + && ((isTextFont(oldname) && oldcolor != Color_foreground) + || (isMathFont(oldname) && oldcolor != Color_math))) + mb.font.setColor(oldcolor); } } @@ -249,14 +260,17 @@ FontSetChanger::FontSetChanger(MetricsBase & mb, docstring const & name, : Changer(mb), change_(really_change_font) { if (change_) { - save_ = mb; FontSize oldsize = save_.font.size(); ColorCode oldcolor = save_.font.color(); + docstring const oldname = from_ascii(save_.fontname); mb.fontname = to_utf8(name); mb.font = sane_font; augmentFont(mb.font, name); mb.font.setSize(oldsize); - mb.font.setColor(oldcolor); + if (name != "lyxtex" + && ((isTextFont(oldname) && oldcolor != Color_foreground) + || (isMathFont(oldname) && oldcolor != Color_math))) + mb.font.setColor(oldcolor); } } @@ -277,7 +291,6 @@ FontSetChanger::~FontSetChanger() WidthChanger::WidthChanger(MetricsBase & mb, int w) : Changer(mb) { - save_ = mb; mb.textwidth = w; } @@ -294,17 +307,20 @@ WidthChanger::~WidthChanger() // ///////////////////////////////////////////////////////////////////////// -ColorChanger::ColorChanger(FontInfo & font, string const & color) - : Changer(font) +ColorChanger::ColorChanger(FontInfo & font, ColorCode color, + bool really_change_color) + : Changer(font, font.color()), change_(really_change_color) { - save_ = lcolor.getFromLyXName(color); - font.setColor(lcolor.getFromLyXName(color)); + if (change_) { + font.setColor(color); + } } ColorChanger::~ColorChanger() { - orig_.setColor(lcolor.getFromLyXName(save_)); + if (change_) + orig_.setColor(save_); }