Sanitize ColorChanger

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@35331 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jean-Marc Lasgouttes 2010-09-09 13:02:20 +00:00
parent 9112064e9a
commit 6d4709d46c
5 changed files with 12 additions and 13 deletions

View File

@ -312,13 +312,13 @@ WidthChanger::~WidthChanger()
// //
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
ColorChanger::ColorChanger(FontInfo & font, docstring const & color, ColorChanger::ColorChanger(FontInfo & font, ColorCode color,
bool really_change_color) bool really_change_color)
: Changer<FontInfo, ColorCode>(font), change_(really_change_color) : Changer<FontInfo, ColorCode>(font), change_(really_change_color)
{ {
if (change_) { if (change_) {
save_ = font.color(); save_ = font.color();
font.setColor(lcolor.getFromLyXName(to_utf8(color))); font.setColor(color);
} }
} }

View File

@ -14,7 +14,7 @@
#define METRICSINFO_H #define METRICSINFO_H
#include "Changes.h" #include "Changes.h"
#include "Color.h" #include "ColorCode.h"
#include "FontInfo.h" #include "FontInfo.h"
#include "support/strfwd.h" #include "support/strfwd.h"
@ -104,7 +104,7 @@ public:
ColorCode backgroundColor(Inset const * inset, bool sel = true) const; ColorCode backgroundColor(Inset const * inset, bool sel = true) const;
/// Determines the text color based on the intended color, the /// Determines the text color based on the intended color, the
/// change tracking state and the selectio state. /// change tracking state and the selection state.
/// \param color what the color should be by default /// \param color what the color should be by default
Color textColor(Color const & color) const; Color textColor(Color const & color) const;
@ -230,7 +230,7 @@ public:
class ColorChanger : public Changer<FontInfo, ColorCode> { class ColorChanger : public Changer<FontInfo, ColorCode> {
public: public:
/// ///
ColorChanger(FontInfo & font, docstring const & color, ColorChanger(FontInfo & font, ColorCode color,
bool really_change_color = true); bool really_change_color = true);
/// ///
~ColorChanger(); ~ColorChanger();

View File

@ -329,18 +329,16 @@ docstring InsetMathHull::standardFont() const
} }
docstring InsetMathHull::standardColor() const ColorCode InsetMathHull::standardColor() const
{ {
docstring color; ColorCode color;
switch (type_) { switch (type_) {
case hullRegexp: case hullRegexp:
color = from_ascii("foreground");
break;
case hullNone: case hullNone:
color = from_ascii("foreground"); color = Color_foreground;
break; break;
default: default:
color = from_ascii("math"); color = Color_math;
} }
return color; return color;
} }

View File

@ -14,6 +14,7 @@
#include "InsetMathGrid.h" #include "InsetMathGrid.h"
#include "Color.h"
#include "DocIterator.h" #include "DocIterator.h"
#include "OutputEnums.h" #include "OutputEnums.h"
@ -207,7 +208,7 @@ private:
/// ///
docstring standardFont() const; docstring standardFont() const;
/// ///
docstring standardColor() const; ColorCode standardColor() const;
/// consistency check /// consistency check
void check() const; void check() const;
/// can this change its number of rows? /// can this change its number of rows?

View File

@ -591,7 +591,7 @@ void MathMacroTemplate::metrics(MetricsInfo & mi, Dimension & dim) const
void MathMacroTemplate::draw(PainterInfo & pi, int x, int y) const void MathMacroTemplate::draw(PainterInfo & pi, int x, int y) const
{ {
ColorChanger dummy0(pi.base.font, from_ascii("math")); ColorChanger dummy0(pi.base.font, Color_math);
FontSetChanger dummy1(pi.base, from_ascii("mathnormal")); FontSetChanger dummy1(pi.base, from_ascii("mathnormal"));
StyleChanger dummy2(pi.base, LM_ST_TEXT); StyleChanger dummy2(pi.base, LM_ST_TEXT);