2 * \file InsetMathSize.cpp
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 "InsetMathSize.h"
16 #include "MathParser.h"
17 #include "MathStream.h"
18 #include "output_xhtml.h"
20 #include "support/convert.h"
29 InsetMathSize::InsetMathSize(Buffer * buf, latexkeys const * l)
30 : InsetMathNest(buf, 1), key_(l), style_(Styles(convert<int>(l->extra)))
34 Inset * InsetMathSize::clone() const
36 return new InsetMathSize(*this);
40 void InsetMathSize::metrics(MetricsInfo & mi, Dimension & dim) const
42 StyleChanger dummy(mi.base, style_);
43 cell(0).metrics(mi, dim);
48 void InsetMathSize::draw(PainterInfo & pi, int x, int y) const
50 StyleChanger dummy(pi.base, style_);
51 cell(0).draw(pi, x + 1, y);
52 drawMarkers(pi, x, y);
56 void InsetMathSize::write(WriteStream & os) const
58 MathEnsurer ensurer(os);
59 os << "{\\" << key_->name << ' ' << cell(0) << '}';
63 // From the MathML documentation:
64 // MathML uses two attributes, displaystyle and scriptlevel, to control
65 // orthogonal presentation features that TeX encodes into one "style"
66 // attribute with values \displaystyle, \textstyle, \scriptstyle, and
67 // \scriptscriptstyle. The corresponding values of displaystyle and scriptlevel
68 // for those TeX styles would be "true" and "0", "false" and "0", "false" and "1",
69 // and "false" and "2", respectively.
70 void InsetMathSize::mathmlize(MathStream & ms) const
72 string const & name = to_utf8(key_->name);
73 bool dispstyle = (name == "displaystyle");
75 if (name == "scriptstyle")
77 else if (name == "scriptscriptstyle")
80 attrs << "displaystyle='" << (dispstyle ? "true" : "false")
81 << "' scriptlevel='" << scriptlevel << "'";
82 ms << MTag("mstyle", attrs.str()) << ">"
83 << cell(0) << ETag("mstyle");
87 void InsetMathSize::normalize(NormalStream & os) const
89 os << '[' << key_->name << ' ' << cell(0) << ']';
93 void InsetMathSize::infoize(odocstream & os) const
95 os << "Size: " << key_->name;