5 #include "math_fracinset.h"
6 #include "math_support.h"
7 #include "frontends/Painter.h"
8 #include "math_mathmlstream.h"
9 #include "textpainter.h"
15 MathFracInset::MathFracInset(bool atop)
20 MathInset * MathFracInset::clone() const
22 return new MathFracInset(*this);
26 MathFracInset * MathFracInset::asFracInset()
28 return atop_ ? 0 : this;
32 void MathFracInset::metrics(MathMetricsInfo & mi) const
34 MathFracChanger dummy(mi.base);
37 width_ = max(xcell(0).width(), xcell(1).width()) + 2;
38 ascent_ = xcell(0).height() + 2 + 5;
39 descent_ = xcell(1).height() + 2 - 5;
43 void MathFracInset::draw(MathPainterInfo & pi, int x, int y) const
45 int m = x + width() / 2;
46 MathFracChanger dummy(pi.base);
47 xcell(0).draw(pi, m - xcell(0).width() / 2, y - xcell(0).descent() - 2 - 5);
48 xcell(1).draw(pi, m - xcell(1).width() / 2, y + xcell(1).ascent() + 2 - 5);
50 pi.pain.line(x + 1, y - 5, x + width() - 2, y - 5, LColor::math);
54 void MathFracInset::metricsT(TextMetricsInfo const & mi) const
56 xcell(0).metricsT(mi);
57 xcell(1).metricsT(mi);
58 width_ = max(xcell(0).width(), xcell(1).width());
59 ascent_ = xcell(0).height() + 1;
60 descent_ = xcell(1).height();
64 void MathFracInset::drawT(TextPainter & pain, int x, int y) const
66 int m = x + width() / 2;
67 xcell(0).drawT(pain, m - xcell(0).width() / 2, y - xcell(0).descent() - 1);
68 xcell(1).drawT(pain, m - xcell(1).width() / 2, y + xcell(1).ascent());
70 pain.horizontalLine(x, y, width());
74 void MathFracInset::write(WriteStream & os) const
77 os << '{' << cell(0) << "\\atop " << cell(1) << '}';
79 os << "\\frac{" << cell(0) << "}{" << cell(1) << '}';
83 void MathFracInset::normalize(NormalStream & os) const
89 os << cell(0) << ' ' << cell(1) << ']';
92 void MathFracInset::maplize(MapleStream & os) const
94 os << '(' << cell(0) << ")/(" << cell(1) << ')';
97 void MathFracInset::mathematicize(MathematicaStream & os) const
99 os << '(' << cell(0) << ")/(" << cell(1) << ')';
102 void MathFracInset::octavize(OctaveStream & os) const
104 os << '(' << cell(0) << ")/(" << cell(1) << ')';
108 void MathFracInset::mathmlize(MathMLStream & os) const
110 os << MTag("mfrac") << cell(0) << cell(1) << ETag("mfrac");