2 * \file InsetMathSqrt.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 "InsetMathSqrt.h"
14 #include "MathArray.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 bool InsetMathSqrt::metrics(MetricsInfo & mi, Dimension & dim) const
39 cell(0).metrics(mi, dim);
51 void InsetMathSqrt::draw(PainterInfo & pi, int x, int y) const
53 cell(0).draw(pi, x + 10, y);
54 int const a = dim_.ascent();
55 int const d = dim_.descent();
58 xp[0] = x + dim_.width(); yp[0] = y - a + 1;
59 xp[1] = x + 8; yp[1] = y - a + 1;
60 xp[2] = x + 5; yp[2] = y + d - 1;
61 xp[3] = x; yp[3] = y + (d - a)/2;
62 pi.pain.lines(xp, yp, 4, LColor::math);
63 drawMarkers(pi, x, y);
67 void InsetMathSqrt::metricsT(TextMetricsInfo const & mi, Dimension & dim) const
69 cell(0).metricsT(mi, dim);
75 void InsetMathSqrt::drawT(TextPainter & pain, int x, int y) const
77 cell(0).drawT(pain, x + 2, y);
78 pain.horizontalLine(x + 2, y - cell(0).ascent(), cell(0).width(), '_');
79 pain.verticalLine (x + 1, y - cell(0).ascent() + 1, cell(0).height());
80 pain.draw(x, y + cell(0).descent(), '\\');
84 void InsetMathSqrt::write(WriteStream & os) const
86 os << "\\sqrt{" << cell(0) << '}';
90 void InsetMathSqrt::normalize(NormalStream & os) const
92 os << "[sqrt " << cell(0) << ']';
95 void InsetMathSqrt::maple(MapleStream & os) const
97 os << "sqrt(" << cell(0) << ')';
100 void InsetMathSqrt::mathematica(MathematicaStream & os) const
102 os << "Sqrt[" << cell(0) << ']';
106 void InsetMathSqrt::octave(OctaveStream & os) const
108 os << "sqrt(" << cell(0) << ')';
112 void InsetMathSqrt::mathmlize(MathStream & os) const
114 os << MTag("msqrt") << cell(0) << ETag("msqrt");