5 #include "math_fracinset.h"
6 #include "math_support.h"
8 #include "math_mathmlstream.h"
14 MathFracInset::MathFracInset(bool atop)
19 MathInset * MathFracInset::clone() const
21 return new MathFracInset(*this);
25 MathFracInset * MathFracInset::asFracInset()
27 return atop_ ? 0 : this;
31 void MathFracInset::metrics(MathMetricsInfo const & mi) const
33 MathMetricsInfo m = mi;
37 width_ = max(xcell(0).width(), xcell(1).width()) + 4;
38 ascent_ = xcell(0).height() + 2 + 5;
39 descent_ = xcell(1).height() + 2 - 5;
43 void MathFracInset::draw(Painter & pain, int x, int y) const
45 int m = x + width() / 2;
46 xcell(0).draw(pain, m - xcell(0).width() / 2, y - xcell(0).descent() - 2 - 5);
47 xcell(1).draw(pain, m - xcell(1).width() / 2, y + xcell(1).ascent() + 2 - 5);
49 pain.line(x + 2, y - 5, x + width() - 4, y - 5, LColor::math);
53 void MathFracInset::write(WriteStream & os) const
56 os << '{' << cell(0) << "\\atop " << cell(1) << '}';
58 os << "\\frac{" << cell(0) << "}{" << cell(1) << '}';
62 void MathFracInset::normalize(NormalStream & os) const
68 os << cell(0) << ' ' << cell(1) << ']';
72 void MathFracInset::maplize(MapleStream & os) const
74 os << '(' << cell(0) << ")/(" << cell(1) << ')';
78 void MathFracInset::mathmlize(MathMLStream & os) const
80 os << MTag("mfrac") << cell(0) << cell(1) << ETag("mfrac");