2 #include "math_fracinset.h"
3 #include "math_support.h"
4 #include "frontends/Painter.h"
5 #include "math_mathmlstream.h"
6 #include "textpainter.h"
12 MathFracInset::MathFracInset(bool atop)
17 MathInset * MathFracInset::clone() const
19 return new MathFracInset(*this);
23 MathFracInset * MathFracInset::asFracInset()
25 return atop_ ? 0 : this;
29 MathFracInset const * MathFracInset::asFracInset() const
31 return atop_ ? 0 : this;
35 void MathFracInset::metrics(MetricsInfo & mi) const
37 FracChanger dummy(mi.base);
40 dim_.w = max(cell(0).width(), cell(1).width()) + 2;
41 dim_.a = cell(0).height() + 2 + 5;
42 dim_.d = cell(1).height() + 2 - 5;
46 void MathFracInset::draw(PainterInfo & pi, int x, int y) const
48 int m = x + width() / 2;
49 FracChanger dummy(pi.base);
50 cell(0).draw(pi, m - cell(0).width() / 2, y - cell(0).descent() - 2 - 5);
51 cell(1).draw(pi, m - cell(1).width() / 2, y + cell(1).ascent() + 2 - 5);
53 pi.pain.line(x + 1, y - 5, x + width() - 2, y - 5, LColor::math);
57 void MathFracInset::metricsT(TextMetricsInfo const & mi) const
61 dim_.w = max(cell(0).width(), cell(1).width());
62 dim_.a = cell(0).height() + 1;
63 dim_.d = cell(1).height();
67 void MathFracInset::drawT(TextPainter & pain, int x, int y) const
69 int m = x + width() / 2;
70 cell(0).drawT(pain, m - cell(0).width() / 2, y - cell(0).descent() - 1);
71 cell(1).drawT(pain, m - cell(1).width() / 2, y + cell(1).ascent());
73 pain.horizontalLine(x, y, width());
77 void MathFracInset::write(WriteStream & os) const
80 os << '{' << cell(0) << "\\atop " << cell(1) << '}';
82 MathNestInset::write(os);
86 string MathFracInset::name() const
88 return atop_ ? "atop" : "frac";
92 void MathFracInset::maple(MapleStream & os) const
94 os << '(' << cell(0) << ")/(" << cell(1) << ')';
98 void MathFracInset::mathematica(MathematicaStream & os) const
100 os << '(' << cell(0) << ")/(" << cell(1) << ')';
104 void MathFracInset::octave(OctaveStream & os) const
106 os << '(' << cell(0) << ")/(" << cell(1) << ')';
110 void MathFracInset::mathmlize(MathMLStream & os) const
112 os << MTag("mfrac") << cell(0) << cell(1) << ETag("mfrac");