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 const & mi) const
26 ascent_ = xcell(0).ascent() + 4;
27 descent_ = xcell(0).descent() + 2;
28 width_ = xcell(0).width() + 12;
32 void MathSqrtInset::draw(Painter & pain, int x, int y) const
34 xcell(0).draw(pain, x + 10, y);
35 int const a = ascent_;
36 int const d = descent_;
39 xp[0] = x + width_; yp[0] = y - a + 1;
40 xp[1] = x + 8; yp[1] = y - a + 1;
41 xp[2] = x + 5; yp[2] = y + d - 1;
42 xp[3] = x; yp[3] = y + (d - a)/2;
43 pain.lines(xp, yp, 4, LColor::math);
47 void MathSqrtInset::metricsT(TextMetricsInfo const & mi) const
49 xcell(0).metricsT(mi);
50 ascent_ = xcell(0).ascent() + 1;
51 descent_ = xcell(0).descent();
52 width_ = xcell(0).width() + 2;
56 void MathSqrtInset::drawT(TextPainter & pain, int x, int y) const
58 xcell(0).drawT(pain, x + 2, y);
59 pain.horizontalLine(x + 2, y - xcell(0).ascent(), xcell(0).width(), '_');
60 pain.verticalLine (x + 1, y - xcell(0).ascent() + 1, xcell(0).height());
61 pain.draw(x, y + xcell(0).descent(), '\\');
65 void MathSqrtInset::write(WriteStream & os) const
67 os << "\\sqrt{" << cell(0) << '}';
71 void MathSqrtInset::normalize(NormalStream & os) const
73 os << "[sqrt " << cell(0) << ']';
77 void MathSqrtInset::maplize(MapleStream & os) const
79 os << "sqrt(" << cell(0) << ')';
83 void MathSqrtInset::octavize(OctaveStream & os) const
85 os << "sqrt(" << cell(0) << ')';
89 void MathSqrtInset::mathmlize(MathMLStream & os) const
91 os << MTag("msqrt") << cell(0) << ETag("msqrt");