7 #include "math_fracinset.h"
10 #include "mathed/support.h"
11 #include "support/LOstream.h"
14 MathFracInset::MathFracInset(MathInsetTypes ot)
15 : MathInset("frac", ot, 2)
17 if (objtype == LM_OT_STACKREL)
22 MathInset * MathFracInset::Clone() const
24 return new MathFracInset(*this);
28 void MathFracInset::Metrics(MathStyles st)
33 width_ = max(xcell(0).width(), xcell(1).width()) + 4;
34 ascent_ = xcell(0).height() + 4 + 5;
35 descent_ = xcell(1).height() + 4 - 5;
39 void MathFracInset::draw(Painter & pain, int x, int y)
43 int m = x + width() / 2;
44 xcell(0).draw(pain, m - xcell(0).width() / 2, y - xcell(0).descent() - 3 - 5);
45 xcell(1).draw(pain, m - xcell(1).width() / 2, y + xcell(1).ascent() + 3 - 5);
47 if (objtype == LM_OT_FRAC)
48 pain.line(x + 2, y - 5, x + width() - 4, y - 5, LColor::mathline);
52 void MathFracInset::Write(std::ostream & os, bool fragile) const
54 os << '\\' << name() << '{';
55 cell(0).Write(os, fragile);
57 cell(1).Write(os, fragile);
62 void MathFracInset::WriteNormal(std::ostream & os) const
64 os << '[' << name() << ' ';
65 cell(0).WriteNormal(os);
67 cell(1).WriteNormal(os);
72 bool MathFracInset::idxRight(int &, int &) const
77 bool MathFracInset::idxLeft(int &, int &) const
83 bool MathFracInset::idxUp(int & idx, int &) const
91 bool MathFracInset::idxDown(int & idx, int &) const
99 bool MathFracInset::idxFirstUp(int & idx, int & pos) const
106 bool MathFracInset::idxFirstDown(int & idx, int & pos) const
113 bool MathFracInset::idxLastUp(int & idx, int & pos) const
116 pos = cell(idx).size();
120 bool MathFracInset::idxLastDown(int & idx, int & pos) const
123 pos = cell(idx).size();