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"
20 #include "support/std_ostream.h"
25 MathColorInset::MathColorInset()
30 auto_ptr<InsetBase> MathColorInset::clone() const
32 return auto_ptr<InsetBase>(new MathColorInset(*this));
36 void MathColorInset::metrics(MetricsInfo & mi, Dimension & dim) const
38 FontSetChanger dummy(mi.base, "textnormal");
39 w_ = mathed_char_width(mi.base.font, '[');
40 MathNestInset::metrics(mi);
42 dim_ += cell(1).dim();
43 dim_.wid += 2 * w_ + 4;
49 void MathColorInset::draw(PainterInfo & pi, int x, int y) const
51 FontSetChanger dummy(pi.base, "textnormal");
52 drawMarkers(pi, x, y);
54 drawStrBlack(pi, x, y, "[");
56 cell(0).draw(pi, x, y);
58 drawStrBlack(pi, x, y, "]");
61 ColorChanger dummy1(pi.base.font, asString(cell(0)));
62 cell(1).draw(pi, x, y);
66 void MathColorInset::validate(LaTeXFeatures & features) const
68 MathNestInset::validate(features);
69 features.require("color");
73 void MathColorInset::write(WriteStream & os) const
75 os << "\\color" << '{' << cell(0) << '}' << '{' << cell(1) << '}';
79 void MathColorInset::normalize(NormalStream & os) const
81 os << "[color " << cell(0) << ' ' << cell(1) << ']';
85 void MathColorInset::infoize(std::ostream & os) const
87 os << "Color: " << cell(0);