7 #include "math_updowninset.h"
8 #include "support/LOstream.h"
11 MathUpDownInset::MathUpDownInset()
12 : MathInset(2), up_(false), down_(false)
15 MathUpDownInset::MathUpDownInset(bool up, bool down)
16 : MathInset(2), up_(up), down_(down)
20 MathInset * MathUpDownInset::clone() const
22 return new MathUpDownInset(*this);
26 bool MathUpDownInset::up() const
31 bool MathUpDownInset::down() const
36 void MathUpDownInset::up(bool b)
41 void MathUpDownInset::down(bool b)
47 bool MathUpDownInset::idxRight(int &, int &) const
52 bool MathUpDownInset::idxLeft(int &, int &) const
58 bool MathUpDownInset::idxUp(int & idx, int & pos) const
60 if (idx == 0 || !up())
67 bool MathUpDownInset::idxDown(int & idx, int & pos) const
69 if (idx == 1 || !down())
76 bool MathUpDownInset::idxFirst(int & idx, int & pos) const
83 bool MathUpDownInset::idxLast(int & idx, int & pos) const
86 pos = cell(idx).size();
91 bool MathUpDownInset::idxFirstUp(int & idx, int & pos) const
100 bool MathUpDownInset::idxFirstDown(int & idx, int & pos) const
109 bool MathUpDownInset::idxLastUp(int & idx, int & pos) const
114 pos = cell(idx).size();
118 bool MathUpDownInset::idxLastDown(int & idx, int & pos) const
123 pos = cell(idx).size();
128 void MathUpDownInset::idxDelete(int & idx, bool & popit, bool & deleteit)
135 deleteit = !(up() || down());
138 void MathUpDownInset::Write(std::ostream & os, bool fragile) const
142 cell(0).Write(os, fragile);
147 cell(1).Write(os, fragile);
152 void MathUpDownInset::Metrics(MathStyles st, int asc, int des)
155 xcell(0).Metrics(st);
157 xcell(1).Metrics(st);
159 // we assume that asc, des, wid are the metrics of the item in front
160 // of this MathScriptInset
161 width_ = std::max(xcell(0).width(), xcell(1).width());
162 ascent_ = up() ? xcell(0).height() + asc : 0;
163 descent_ = down() ? xcell(1).height() : 0;
164 dy0_ = - asc - xcell(0).descent();
165 dy1_ = des + xcell(1).ascent();
169 void MathUpDownInset::draw(Painter & pain, int x, int y)
174 xcell(0).draw(pain, x, y + dy0_);
176 xcell(1).draw(pain, x, y + dy1_);