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 dim_.w = max(xcell(0).width(), xcell(1).width()) + 2;
38 dim_.a = xcell(0).height() + 2 + 5;
39 dim_.d = 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 dim_.w = max(xcell(0).width(), xcell(1).width());
59 dim_.a = xcell(0).height() + 1;
60 dim_.d = 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 MathNestInset::write(os);
83 string MathFracInset::name() const
85 return atop_ ? "atop" : "frac";
89 void MathFracInset::maplize(MapleStream & os) const
91 os << '(' << cell(0) << ")/(" << cell(1) << ')';
95 void MathFracInset::mathematicize(MathematicaStream & os) const
97 os << '(' << cell(0) << ")/(" << cell(1) << ')';
101 void MathFracInset::octavize(OctaveStream & os) const
103 os << '(' << cell(0) << ")/(" << cell(1) << ')';
107 void MathFracInset::mathmlize(MathMLStream & os) const
109 os << MTag("mfrac") << cell(0) << cell(1) << ETag("mfrac");