5 #include "math_fracinset.h"
6 #include "mathed/support.h"
8 #include "support/LOstream.h"
11 MathFracInset::MathFracInset(bool atop)
16 MathInset * MathFracInset::clone() const
18 return new MathFracInset(*this);
22 void MathFracInset::metrics(MathMetricsInfo const & mi) const
24 MathMetricsInfo m = mi;
28 width_ = std::max(xcell(0).width(), xcell(1).width()) + 4;
29 ascent_ = xcell(0).height() + 4 + 5;
30 descent_ = xcell(1).height() + 4 - 5;
34 void MathFracInset::draw(Painter & pain, int x, int y) const
36 int m = x + width() / 2;
37 xcell(0).draw(pain, m - xcell(0).width() / 2, y - xcell(0).descent() - 3 - 5);
38 xcell(1).draw(pain, m - xcell(1).width() / 2, y + xcell(1).ascent() + 3 - 5);
40 pain.line(x + 2, y - 5, x + width() - 4, y - 5, LColor::mathline);
44 void MathFracInset::write(MathWriteInfo & os) const
47 os << '{' << cell(0) << "\\atop " << cell(1) << '}';
49 os << "\\frac{" << cell(0) << "}{" << cell(1) << '}';
53 void MathFracInset::writeNormal(std::ostream & os) const
59 cell(0).writeNormal(os);
61 cell(1).writeNormal(os);
66 void MathFracInset::maplize(MapleStream & os) const
68 os << '(' << cell(0) << '/' << cell(1) << ')';
72 void MathFracInset::mathmlize(MathMLStream & os) const
74 os << "<mfrac>" << cell(0) << cell(1) << "</mfrac>";