5 #include "math_fracinset.h"
6 #include "mathed/support.h"
8 #include "support/LOstream.h"
11 MathFracInset::MathFracInset(string const & name)
16 MathInset * MathFracInset::clone() const
18 return new MathFracInset(*this);
22 void MathFracInset::Metrics(MathStyles st)
24 size_ = smallerStyleFrac(st);
25 xcell(0).Metrics(size_);
26 xcell(1).Metrics(size_);
27 width_ = std::max(xcell(0).width(), xcell(1).width()) + 4;
28 ascent_ = xcell(0).height() + 4 + 5;
29 descent_ = xcell(1).height() + 4 - 5;
33 void MathFracInset::draw(Painter & pain, int x, int y)
37 int m = x + width() / 2;
38 xcell(0).draw(pain, m - xcell(0).width() / 2, y - xcell(0).descent() - 3 - 5);
39 xcell(1).draw(pain, m - xcell(1).width() / 2, y + xcell(1).ascent() + 3 - 5);
42 pain.line(x + 2, y - 5, x + width() - 4, y - 5, LColor::mathline);
46 void MathFracInset::Write(std::ostream & os, bool fragile) const
48 os << '\\' << name() << '{';
49 cell(0).Write(os, fragile);
51 cell(1).Write(os, fragile);
56 void MathFracInset::WriteNormal(std::ostream & os) const
58 os << '[' << name() << ' ';
59 cell(0).WriteNormal(os);
61 cell(1).WriteNormal(os);
66 bool MathFracInset::idxRight(int &, int &) const
71 bool MathFracInset::idxLeft(int &, int &) const
77 bool MathFracInset::idxUp(int & idx, int &) const
85 bool MathFracInset::idxDown(int & idx, int &) const
93 bool MathFracInset::idxFirstUp(int & idx, int & pos) const
100 bool MathFracInset::idxFirstDown(int & idx, int & pos) const
107 bool MathFracInset::idxLastUp(int & idx, int & pos) const
110 pos = cell(idx).size();
114 bool MathFracInset::idxLastDown(int & idx, int & pos) const
117 pos = cell(idx).size();