2 * \file InsetMathSqrt.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 "InsetMathSqrt.h"
15 #include "MathMLStream.h"
16 #include "TextPainter.h"
18 #include "frontends/Painter.h"
23 InsetMathSqrt::InsetMathSqrt()
28 auto_ptr<InsetBase> InsetMathSqrt::doClone() const
30 return auto_ptr<InsetBase>(new InsetMathSqrt(*this));
34 void InsetMathSqrt::metrics(MetricsInfo & mi, Dimension & dim) const
36 cell(0).metrics(mi, dim);
45 void InsetMathSqrt::draw(PainterInfo & pi, int x, int y) const
47 cell(0).draw(pi, x + 10, y);
48 int const a = dim_.ascent();
49 int const d = dim_.descent();
52 xp[0] = x + dim_.width(); yp[0] = y - a + 1;
53 xp[1] = x + 8; yp[1] = y - a + 1;
54 xp[2] = x + 5; yp[2] = y + d - 1;
55 xp[3] = x; yp[3] = y + (d - a)/2;
56 pi.pain.lines(xp, yp, 4, LColor::math);
57 drawMarkers(pi, x, y);
61 void InsetMathSqrt::metricsT(TextMetricsInfo const & mi, Dimension & dim) const
63 cell(0).metricsT(mi, dim);
69 void InsetMathSqrt::drawT(TextPainter & pain, int x, int y) const
71 cell(0).drawT(pain, x + 2, y);
72 pain.horizontalLine(x + 2, y - cell(0).ascent(), cell(0).width(), '_');
73 pain.verticalLine (x + 1, y - cell(0).ascent() + 1, cell(0).height());
74 pain.draw(x, y + cell(0).descent(), '\\');
78 void InsetMathSqrt::write(WriteStream & os) const
80 os << "\\sqrt{" << cell(0) << '}';
84 void InsetMathSqrt::normalize(NormalStream & os) const
86 os << "[sqrt " << cell(0) << ']';
89 void InsetMathSqrt::maple(MapleStream & os) const
91 os << "sqrt(" << cell(0) << ')';
94 void InsetMathSqrt::mathematica(MathematicaStream & os) const
96 os << "Sqrt[" << cell(0) << ']';
100 void InsetMathSqrt::octave(OctaveStream & os) const
102 os << "sqrt(" << cell(0) << ')';
106 void InsetMathSqrt::mathmlize(MathMLStream & os) const
108 os << MTag("msqrt") << cell(0) << ETag("msqrt");