9 #include "math_fracinset.h"
12 #include "mathed/support.h"
13 #include "support/LOstream.h"
16 MathFracInset::MathFracInset(MathInsetTypes ot)
17 : MathInset("frac", ot, 2)
19 if (objtype == LM_OT_STACKREL)
24 MathInset * MathFracInset::clone() const
26 return new MathFracInset(*this);
30 void MathFracInset::Metrics(MathStyles st)
35 width_ = std::max(xcell(0).width(), xcell(1).width()) + 4;
36 ascent_ = xcell(0).height() + 4 + 5;
37 descent_ = xcell(1).height() + 4 - 5;
41 void MathFracInset::draw(Painter & pain, int x, int y)
45 int m = x + width() / 2;
46 xcell(0).draw(pain, m - xcell(0).width() / 2, y - xcell(0).descent() - 3 - 5);
47 xcell(1).draw(pain, m - xcell(1).width() / 2, y + xcell(1).ascent() + 3 - 5);
49 if (objtype == LM_OT_FRAC)
50 pain.line(x + 2, y - 5, x + width() - 4, y - 5, LColor::mathline);
54 void MathFracInset::Write(std::ostream & os, bool fragile) const
56 os << '\\' << name() << '{';
57 cell(0).Write(os, fragile);
59 cell(1).Write(os, fragile);
64 void MathFracInset::WriteNormal(std::ostream & os) const
66 os << '[' << name() << ' ';
67 cell(0).WriteNormal(os);
69 cell(1).WriteNormal(os);
74 bool MathFracInset::idxRight(int &, int &) const
79 bool MathFracInset::idxLeft(int &, int &) const
85 bool MathFracInset::idxUp(int & idx, int &) const
93 bool MathFracInset::idxDown(int & idx, int &) const
101 bool MathFracInset::idxFirstUp(int & idx, int & pos) const
108 bool MathFracInset::idxFirstDown(int & idx, int & pos) const
115 bool MathFracInset::idxLastUp(int & idx, int & pos) const
118 pos = cell(idx).size();
122 bool MathFracInset::idxLastDown(int & idx, int & pos) const
125 pos = cell(idx).size();