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 "MathStream.h"
16 #include "TextPainter.h"
18 #include "frontends/Painter.h"
26 InsetMathSqrt::InsetMathSqrt()
31 auto_ptr<InsetBase> InsetMathSqrt::doClone() const
33 return auto_ptr<InsetBase>(new InsetMathSqrt(*this));
37 void InsetMathSqrt::metrics(MetricsInfo & mi, Dimension & dim) const
39 cell(0).metrics(mi, dim);
48 void InsetMathSqrt::draw(PainterInfo & pi, int x, int y) const
50 cell(0).draw(pi, x + 10, y);
51 int const a = dim_.ascent();
52 int const d = dim_.descent();
55 xp[0] = x + dim_.width(); yp[0] = y - a + 1;
56 xp[1] = x + 8; yp[1] = y - a + 1;
57 xp[2] = x + 5; yp[2] = y + d - 1;
58 xp[3] = x; yp[3] = y + (d - a)/2;
59 pi.pain.lines(xp, yp, 4, LColor::math);
60 drawMarkers(pi, x, y);
64 void InsetMathSqrt::metricsT(TextMetricsInfo const & mi, Dimension & dim) const
66 cell(0).metricsT(mi, dim);
72 void InsetMathSqrt::drawT(TextPainter & pain, int x, int y) const
74 cell(0).drawT(pain, x + 2, y);
75 pain.horizontalLine(x + 2, y - cell(0).ascent(), cell(0).width(), '_');
76 pain.verticalLine (x + 1, y - cell(0).ascent() + 1, cell(0).height());
77 pain.draw(x, y + cell(0).descent(), '\\');
81 void InsetMathSqrt::write(WriteStream & os) const
83 os << "\\sqrt{" << cell(0) << '}';
87 void InsetMathSqrt::normalize(NormalStream & os) const
89 os << "[sqrt " << cell(0) << ']';
92 void InsetMathSqrt::maple(MapleStream & os) const
94 os << "sqrt(" << cell(0) << ')';
97 void InsetMathSqrt::mathematica(MathematicaStream & os) const
99 os << "Sqrt[" << cell(0) << ']';
103 void InsetMathSqrt::octave(OctaveStream & os) const
105 os << "sqrt(" << cell(0) << ')';
109 void InsetMathSqrt::mathmlize(MathStream & os) const
111 os << MTag("msqrt") << cell(0) << ETag("msqrt");