5 #include "math_updowninset.h"
6 #include "support/LOstream.h"
9 MathUpDownInset::MathUpDownInset()
10 : MathInset(2), up_(false), down_(false)
13 MathUpDownInset::MathUpDownInset(bool up, bool down)
14 : MathInset(2), up_(up), down_(down)
18 MathInset * MathUpDownInset::clone() const
20 return new MathUpDownInset(*this);
24 bool MathUpDownInset::up() const
29 bool MathUpDownInset::down() const
34 void MathUpDownInset::up(bool b)
39 void MathUpDownInset::down(bool b)
45 bool MathUpDownInset::idxRight(int &, int &) const
50 bool MathUpDownInset::idxLeft(int &, int &) const
56 bool MathUpDownInset::idxUp(int & idx, int & pos) const
58 if (idx == 0 || !up())
65 bool MathUpDownInset::idxDown(int & idx, int & pos) const
67 if (idx == 1 || !down())
74 bool MathUpDownInset::idxFirst(int & idx, int & pos) const
81 bool MathUpDownInset::idxLast(int & idx, int & pos) const
84 pos = cell(idx).size();
89 bool MathUpDownInset::idxFirstUp(int & idx, int & pos) const
98 bool MathUpDownInset::idxFirstDown(int & idx, int & pos) const
107 bool MathUpDownInset::idxLastUp(int & idx, int & pos) const
112 pos = cell(idx).size();
116 bool MathUpDownInset::idxLastDown(int & idx, int & pos) const
121 pos = cell(idx).size();
126 void MathUpDownInset::idxDelete(int & idx, bool & popit, bool & deleteit)
133 deleteit = !(up() || down());
136 void MathUpDownInset::Write(std::ostream & os, bool fragile) const
140 cell(0).Write(os, fragile);
145 cell(1).Write(os, fragile);
150 void MathUpDownInset::Metrics(MathStyles st, int asc, int des)
153 MathStyles tt = smallerStyleScript(st);
156 xcell(0).Metrics(tt);
158 xcell(1).Metrics(tt);
160 // we assume that asc, des, wid are the metrics of the item in front
161 // of this MathScriptInset
162 width_ = std::max(xcell(0).width(), xcell(1).width());
163 ascent_ = up() ? xcell(0).height() + asc : 0;
164 descent_ = down() ? xcell(1).height() : 0;
165 dy0_ = - asc - xcell(0).descent();
166 dy1_ = des + xcell(1).ascent();
170 void MathUpDownInset::draw(Painter & pain, int x, int y)
175 xcell(0).draw(pain, x, y + dy0_);
177 xcell(1).draw(pain, x, y + dy1_);