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 MathInset::Metrics(st);
36 width_ = std::max(xcell(0).width(), xcell(1).width()) + 2;
38 ascent_ = std::max(ascent_, xcell(0).height() + 9);
40 descent_ = std::max(descent_, xcell(1).height());
44 bool MathScriptInset::up() const
49 bool MathScriptInset::down() const
54 void MathScriptInset::up(bool b)
59 void MathScriptInset::down(bool b)
65 void MathScriptInset::draw(Painter & pain, int x, int y)
70 xcell(0).draw(pain, x, y - xcell(0).descent() - 9);
72 xcell(1).draw(pain, x, y + xcell(1).ascent());
76 void MathScriptInset::Write(std::ostream & os, bool fragile) const
80 cell(0).Write(os, fragile);
85 cell(1).Write(os, fragile);
91 void MathScriptInset::WriteNormal(std::ostream & os) const
94 os << "[superscript ";
95 cell(0).WriteNormal(os);
100 cell(1).WriteNormal(os);
105 bool MathScriptInset::idxRight(int &, int &) const
110 bool MathScriptInset::idxLeft(int &, int &) const
116 bool MathScriptInset::idxUp(int & idx, int & pos) const
118 if (idx == 0 || !up())
125 bool MathScriptInset::idxDown(int & idx, int & pos) const
127 if (idx == 1 || !down())
134 bool MathScriptInset::idxFirst(int & idx, int & pos) const
141 bool MathScriptInset::idxLast(int & idx, int & pos) const
143 idx = down() ? 1 : 0;
144 pos = cell(idx).size();
149 bool MathScriptInset::idxFirstUp(int & idx, int & pos) const
158 bool MathScriptInset::idxFirstDown(int & idx, int & pos) const
167 bool MathScriptInset::idxLastUp(int & idx, int & pos) const
172 pos = cell(idx).size();
176 bool MathScriptInset::idxLastDown(int & idx, int & pos) const
181 pos = cell(idx).size();
186 bool MathScriptInset::idxDelete(int idx)