2 #include "math_sqrtinset.h"
3 #include "math_mathmlstream.h"
5 #include "frontends/Painter.h"
6 #include "textpainter.h"
9 MathSqrtInset::MathSqrtInset()
14 MathInset * MathSqrtInset::clone() const
16 return new MathSqrtInset(*this);
20 void MathSqrtInset::metrics(MetricsInfo & mi) const
23 dim_.a = cell(0).ascent() + 4;
24 dim_.d = cell(0).descent() + 2;
25 dim_.w = cell(0).width() + 12;
30 void MathSqrtInset::draw(PainterInfo & pi, int x, int y) const
32 cell(0).draw(pi, x + 10, y);
33 int const a = ascent();
34 int const d = descent();
37 xp[0] = x + width(); yp[0] = y - a + 1;
38 xp[1] = x + 8; yp[1] = y - a + 1;
39 xp[2] = x + 5; yp[2] = y + d - 1;
40 xp[3] = x; yp[3] = y + (d - a)/2;
41 pi.pain.lines(xp, yp, 4, LColor::math);
42 drawMarkers(pi, x, y);
46 void MathSqrtInset::metricsT(TextMetricsInfo const & mi) const
49 dim_.a = cell(0).ascent() + 1;
50 dim_.d = cell(0).descent();
51 dim_.w = cell(0).width() + 2;
55 void MathSqrtInset::drawT(TextPainter & pain, int x, int y) const
57 cell(0).drawT(pain, x + 2, y);
58 pain.horizontalLine(x + 2, y - cell(0).ascent(), cell(0).width(), '_');
59 pain.verticalLine (x + 1, y - cell(0).ascent() + 1, cell(0).height());
60 pain.draw(x, y + cell(0).descent(), '\\');
64 void MathSqrtInset::write(WriteStream & os) const
66 os << "\\sqrt{" << cell(0) << '}';
70 void MathSqrtInset::normalize(NormalStream & os) const
72 os << "[sqrt " << cell(0) << ']';
75 void MathSqrtInset::maple(MapleStream & os) const
77 os << "sqrt(" << cell(0) << ')';
80 void MathSqrtInset::mathematica(MathematicaStream & os) const
82 os << "Sqrt[" << cell(0) << ']';
86 void MathSqrtInset::octave(OctaveStream & os) const
88 os << "sqrt(" << cell(0) << ')';
92 void MathSqrtInset::mathmlize(MathMLStream & os) const
94 os << MTag("msqrt") << cell(0) << ETag("msqrt");