9 #include "math_fracinset.h"
12 #include "mathed/support.h"
13 #include "support/LOstream.h"
16 MathFracInset::MathFracInset(string const & name)
21 MathInset * MathFracInset::clone() const
23 return new MathFracInset(*this);
27 void MathFracInset::Metrics(MathStyles st)
29 size_ = smallerStyleFrac(st);
30 xcell(0).Metrics(size_);
31 xcell(1).Metrics(size_);
32 width_ = std::max(xcell(0).width(), xcell(1).width()) + 4;
33 ascent_ = xcell(0).height() + 4 + 5;
34 descent_ = xcell(1).height() + 4 - 5;
38 void MathFracInset::draw(Painter & pain, int x, int y)
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);
47 pain.line(x + 2, y - 5, x + width() - 4, y - 5, LColor::mathline);
51 void MathFracInset::Write(std::ostream & os, bool fragile) const
53 os << '\\' << name() << '{';
54 cell(0).Write(os, fragile);
56 cell(1).Write(os, fragile);
61 void MathFracInset::WriteNormal(std::ostream & os) const
63 os << '[' << name() << ' ';
64 cell(0).WriteNormal(os);
66 cell(1).WriteNormal(os);
71 bool MathFracInset::idxRight(int &, int &) const
76 bool MathFracInset::idxLeft(int &, int &) const
82 bool MathFracInset::idxUp(int & idx, int &) const
90 bool MathFracInset::idxDown(int & idx, int &) const
98 bool MathFracInset::idxFirstUp(int & idx, int & pos) const
105 bool MathFracInset::idxFirstDown(int & idx, int & pos) const
112 bool MathFracInset::idxLastUp(int & idx, int & pos) const
115 pos = cell(idx).size();
119 bool MathFracInset::idxLastDown(int & idx, int & pos) const
122 pos = cell(idx).size();