2 * \file math_colorinset.C
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
8 * Full author contact details are available in file CREDITS.
13 #include "math_colorinset.h"
14 #include "math_data.h"
15 #include "math_mathmlstream.h"
16 #include "math_support.h"
18 #include "LaTeXFeatures.h"
21 #include "support/std_ostream.h"
26 MathColorInset::MathColorInset(bool oldstyle)
27 : MathNestInset(2), oldstyle_(oldstyle)
31 auto_ptr<InsetBase> MathColorInset::clone() const
33 return auto_ptr<InsetBase>(new MathColorInset(*this));
37 void MathColorInset::metrics(MetricsInfo & mi, Dimension & dim) const
39 cell(1).metrics(mi, dim);
41 FontSetChanger dummy(mi.base, "textnormal");
44 w_ = mathed_char_width(mi.base.font, '[');
47 dim.wid += 2 * w_ + 4;
54 void MathColorInset::draw(PainterInfo & pi, int x, int y) const
57 FontSetChanger dummy(pi.base, "textnormal");
58 drawMarkers(pi, x, y);
59 drawStrBlack(pi, x, y, "[");
61 cell(0).draw(pi, x, y);
63 drawStrBlack(pi, x, y, "]");
67 LColor_color origcol = pi.base.font.color();
68 pi.base.font.setColor(lcolor.getFromGUIName(asString(cell(0))));
69 cell(1).draw(pi, x, y);
70 pi.base.font.setColor(origcol);
74 void MathColorInset::validate(LaTeXFeatures & features) const
76 MathNestInset::validate(features);
77 features.require("color");
81 void MathColorInset::write(WriteStream & os) const
84 os << "{\\color" << '{' << cell(0) << '}' << cell(1) << '}';
86 os << "\\textcolor" << '{' << cell(0) << "}{" << cell(1) << '}';
90 void MathColorInset::normalize(NormalStream & os) const
92 os << "[color " << cell(0) << ' ' << cell(1) << ']';
96 void MathColorInset::infoize(std::ostream & os) const
98 os << "Color: " << cell(0);