5 #include "math_sqrtinset.h"
6 #include "math_mathmlstream.h"
8 #include "frontends/Painter.h"
9 #include "textpainter.h"
12 MathSqrtInset::MathSqrtInset()
17 MathInset * MathSqrtInset::clone() const
19 return new MathSqrtInset(*this);
23 void MathSqrtInset::metrics(MathMetricsInfo & mi) const
26 dim_.a = cell(0).ascent() + 4;
27 dim_.d = cell(0).descent() + 2;
28 dim_.w = cell(0).width() + 12;
33 void MathSqrtInset::draw(MathPainterInfo & pi, int x, int y) const
35 cell(0).draw(pi, x + 10, y);
36 int const a = ascent();
37 int const d = descent();
40 xp[0] = x + width(); yp[0] = y - a + 1;
41 xp[1] = x + 8; yp[1] = y - a + 1;
42 xp[2] = x + 5; yp[2] = y + d - 1;
43 xp[3] = x; yp[3] = y + (d - a)/2;
44 pi.pain.lines(xp, yp, 4, LColor::math);
45 drawMarkers(pi, x, y);
49 void MathSqrtInset::metricsT(TextMetricsInfo const & mi) const
52 dim_.a = cell(0).ascent() + 1;
53 dim_.d = cell(0).descent();
54 dim_.w = cell(0).width() + 2;
58 void MathSqrtInset::drawT(TextPainter & pain, int x, int y) const
60 cell(0).drawT(pain, x + 2, y);
61 pain.horizontalLine(x + 2, y - cell(0).ascent(), cell(0).width(), '_');
62 pain.verticalLine (x + 1, y - cell(0).ascent() + 1, cell(0).height());
63 pain.draw(x, y + cell(0).descent(), '\\');
67 void MathSqrtInset::write(WriteStream & os) const
69 os << "\\sqrt{" << cell(0) << '}';
73 void MathSqrtInset::normalize(NormalStream & os) const
75 os << "[sqrt " << cell(0) << ']';
78 void MathSqrtInset::maplize(MapleStream & os) const
80 os << "sqrt(" << cell(0) << ')';
83 void MathSqrtInset::mathematicize(MathematicaStream & os) const
85 os << "Sqrt[" << cell(0) << ']';
89 void MathSqrtInset::octavize(OctaveStream & os) const
91 os << "sqrt(" << cell(0) << ')';
95 void MathSqrtInset::mathmlize(MathMLStream & os) const
97 os << MTag("msqrt") << cell(0) << ETag("msqrt");