9 #include "math_scriptinset.h"
13 #include "mathed/support.h"
14 #include "support/LOstream.h"
17 MathScriptInset::MathScriptInset()
18 : MathInset("script", LM_OT_SCRIPT, 2), up_(false), down_(false)
21 MathScriptInset::MathScriptInset(bool up, bool down)
22 : MathInset("script", LM_OT_SCRIPT, 2), up_(up), down_(down)
26 MathInset * MathScriptInset::clone() const
28 return new MathScriptInset(*this);
32 void MathScriptInset::Metrics(MathStyles st)
34 size_ = smallerStyleScript(st);
35 xcell(0).Metrics(size_);
36 xcell(1).Metrics(size_);
38 width_ = std::max(xcell(0).width(), xcell(1).width()) + 2;
40 ascent_ = std::max(ascent_, xcell(0).height() + 9);
42 descent_ = std::max(descent_, xcell(1).height());
46 bool MathScriptInset::up() const
51 bool MathScriptInset::down() const
56 void MathScriptInset::up(bool b)
61 void MathScriptInset::down(bool b)
67 void MathScriptInset::draw(Painter & pain, int x, int y)
72 xcell(0).draw(pain, x, y - xcell(0).descent() - 9);
74 xcell(1).draw(pain, x, y + xcell(1).ascent());
78 void MathScriptInset::Write(std::ostream & os, bool fragile) const
82 cell(0).Write(os, fragile);
87 cell(1).Write(os, fragile);
93 void MathScriptInset::WriteNormal(std::ostream & os) const
96 os << "[superscript ";
97 cell(0).WriteNormal(os);
102 cell(1).WriteNormal(os);
107 bool MathScriptInset::idxRight(int &, int &) const
112 bool MathScriptInset::idxLeft(int &, int &) const
118 bool MathScriptInset::idxUp(int & idx, int & pos) const
120 if (idx == 0 || !up())
127 bool MathScriptInset::idxDown(int & idx, int & pos) const
129 if (idx == 1 || !down())
136 bool MathScriptInset::idxFirst(int & idx, int & pos) const
143 bool MathScriptInset::idxLast(int & idx, int & pos) const
145 idx = down() ? 1 : 0;
146 pos = cell(idx).size();
151 bool MathScriptInset::idxFirstUp(int & idx, int & pos) const
160 bool MathScriptInset::idxFirstDown(int & idx, int & pos) const
169 bool MathScriptInset::idxLastUp(int & idx, int & pos) const
174 pos = cell(idx).size();
178 bool MathScriptInset::idxLastDown(int & idx, int & pos) const
183 pos = cell(idx).size();
188 bool MathScriptInset::idxDelete(int idx)