From 19198334bcbef32f915d4da4ce97ec8dc81d2d60 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andr=C3=A9=20P=C3=B6nitz?= Date: Mon, 27 Oct 2003 17:22:27 +0000 Subject: [PATCH] fix color handling git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7989 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/mathed/math_colorinset.C | 7 +++++-- src/mathed/math_colorinset.h | 4 +++- src/mathed/math_parser.C | 8 ++++++++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/mathed/math_colorinset.C b/src/mathed/math_colorinset.C index ec3edee0da..b9737c5d93 100644 --- a/src/mathed/math_colorinset.C +++ b/src/mathed/math_colorinset.C @@ -16,6 +16,7 @@ #include "math_support.h" #include "LaTeXFeatures.h" +#include "LColor.h" #include "support/std_ostream.h" @@ -63,8 +64,10 @@ void MathColorInset::draw(PainterInfo & pi, int x, int y) const x += w_ + 2; } - ColorChanger dummy1(pi.base.font, asString(cell(0))); + LColor_color origcol = pi.base.font.color(); + pi.base.font.setColor(lcolor.getFromGUIName(asString(cell(0)))); cell(1).draw(pi, x, y); + pi.base.font.setColor(origcol); } @@ -77,7 +80,7 @@ void MathColorInset::validate(LaTeXFeatures & features) const void MathColorInset::write(WriteStream & os) const { - os << "\\color" << '{' << cell(0) << '}' << '{' << cell(1) << '}'; + os << "{\\color" << '{' << cell(0) << '}' << cell(1) << '}'; } diff --git a/src/mathed/math_colorinset.h b/src/mathed/math_colorinset.h index f5ced87654..6cab921f5c 100644 --- a/src/mathed/math_colorinset.h +++ b/src/mathed/math_colorinset.h @@ -21,9 +21,11 @@ public: /// MathColorInset(); /// - virtual std::auto_ptr clone() const; + std::auto_ptr clone() const; /// void metrics(MetricsInfo & mi, Dimension & dim) const; + /// we write extra braces in any case... + bool extraBraces() const { return true; } /// void draw(PainterInfo & pi, int x, int y) const; /// we need package color diff --git a/src/mathed/math_parser.C b/src/mathed/math_parser.C index dee7aa44de..eaa3e99520 100644 --- a/src/mathed/math_parser.C +++ b/src/mathed/math_parser.C @@ -1135,6 +1135,14 @@ void Parser::parse1(MathGridInset & grid, unsigned flags, return; } + else if (t.cs() == "color") { + MathAtom at = createMathInset(t.cs()); + parse(at.nucleus()->cell(0), FLAG_ITEM, MathInset::TEXT_MODE); + parse(at.nucleus()->cell(1), flags, mode); + cell->push_back(at); + return; + } + else if (t.cs() == "substack") { cell->push_back(createMathInset(t.cs())); parse2(cell->back(), FLAG_ITEM, mode, false); -- 2.39.2