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 MathFracInset const * MathFracInset::asFracInset() const
34 return atop_ ? 0 : this;
38 void MathFracInset::metrics(MathMetricsInfo & mi) const
40 MathFracChanger dummy(mi.base);
43 dim_.w = max(cell(0).width(), cell(1).width()) + 2;
44 dim_.a = cell(0).height() + 2 + 5;
45 dim_.d = cell(1).height() + 2 - 5;
49 void MathFracInset::draw(MathPainterInfo & pi, int x, int y) const
51 int m = x + width() / 2;
52 MathFracChanger dummy(pi.base);
53 cell(0).draw(pi, m - cell(0).width() / 2, y - cell(0).descent() - 2 - 5);
54 cell(1).draw(pi, m - cell(1).width() / 2, y + cell(1).ascent() + 2 - 5);
56 pi.pain.line(x + 1, y - 5, x + width() - 2, y - 5, LColor::math);
60 void MathFracInset::metricsT(TextMetricsInfo const & mi) const
64 dim_.w = max(cell(0).width(), cell(1).width());
65 dim_.a = cell(0).height() + 1;
66 dim_.d = cell(1).height();
70 void MathFracInset::drawT(TextPainter & pain, int x, int y) const
72 int m = x + width() / 2;
73 cell(0).drawT(pain, m - cell(0).width() / 2, y - cell(0).descent() - 1);
74 cell(1).drawT(pain, m - cell(1).width() / 2, y + cell(1).ascent());
76 pain.horizontalLine(x, y, width());
80 void MathFracInset::write(WriteStream & os) const
83 os << '{' << cell(0) << "\\atop " << cell(1) << '}';
85 MathNestInset::write(os);
89 string MathFracInset::name() const
91 return atop_ ? "atop" : "frac";
95 void MathFracInset::maplize(MapleStream & os) const
97 os << '(' << cell(0) << ")/(" << cell(1) << ')';
101 void MathFracInset::mathematicize(MathematicaStream & os) const
103 os << '(' << cell(0) << ")/(" << cell(1) << ')';
107 void MathFracInset::octavize(OctaveStream & os) const
109 os << '(' << cell(0) << ")/(" << cell(1) << ')';
113 void MathFracInset::mathmlize(MathMLStream & os) const
115 os << MTag("mfrac") << cell(0) << cell(1) << ETag("mfrac");