5 #include "math_fracinset.h"
6 #include "math_support.h"
8 #include "math_mathmlstream.h"
11 MathFracInset::MathFracInset(bool atop)
16 MathInset * MathFracInset::clone() const
18 return new MathFracInset(*this);
22 MathFracInset * MathFracInset::asFracInset()
24 return atop_ ? 0 : this;
28 void MathFracInset::metrics(MathMetricsInfo const & mi) const
30 MathMetricsInfo m = mi;
34 width_ = std::max(xcell(0).width(), xcell(1).width()) + 4;
35 ascent_ = xcell(0).height() + 4 + 5;
36 descent_ = xcell(1).height() + 4 - 5;
40 void MathFracInset::draw(Painter & pain, int x, int y) const
42 int m = x + width() / 2;
43 xcell(0).draw(pain, m - xcell(0).width() / 2, y - xcell(0).descent() - 3 - 5);
44 xcell(1).draw(pain, m - xcell(1).width() / 2, y + xcell(1).ascent() + 3 - 5);
46 pain.line(x + 2, y - 5, x + width() - 4, y - 5, LColor::math);
50 void MathFracInset::write(WriteStream & os) const
53 os << '{' << cell(0) << "\\atop " << cell(1) << '}';
55 os << "\\frac{" << cell(0) << "}{" << cell(1) << '}';
59 void MathFracInset::normalize(NormalStream & os) const
65 os << cell(0) << ' ' << cell(1) << ']';
69 void MathFracInset::maplize(MapleStream & os) const
71 os << '(' << cell(0) << ")/(" << cell(1) << ')';
75 void MathFracInset::mathmlize(MathMLStream & os) const
77 os << MTag("mfrac") << cell(0) << cell(1) << ETag("mfrac");