5 #include "math_nestinset.h"
9 MathNestInset::MathNestInset(int nargs, string const & name)
10 : MathInset(name), cells_(nargs)
14 int MathNestInset::nargs() const
20 MathXArray & MathNestInset::xcell(int i)
26 MathXArray const & MathNestInset::xcell(int i) const
32 MathArray & MathNestInset::cell(int i)
34 return cells_[i].data_;
38 MathArray const & MathNestInset::cell(int i) const
40 return cells_[i].data_;
44 void MathNestInset::substitute(MathArray & array, MathMacro const & m) const
46 MathNestInset * p = static_cast<MathNestInset *>(clone());
47 for (int i = 0; i < nargs(); ++i)
48 p->cell(i).substitute(m);
53 void MathNestInset::metrics(MathStyles st)
56 for (int i = 0; i < nargs(); ++i)
61 void MathNestInset::draw(Painter & pain, int x, int y)
65 for (int i = 0; i < nargs(); ++i)
66 xcell(i).draw(pain, x + xcell(i).xo(), y + xcell(i).yo());
70 bool MathNestInset::idxNext(int & idx, int & pos) const
72 if (idx + 1 >= nargs())
80 bool MathNestInset::idxRight(int & idx, int & pos) const
82 return idxNext(idx, pos);
86 bool MathNestInset::idxPrev(int & idx, int & pos) const
91 pos = cell(idx).size();
96 bool MathNestInset::idxLeft(int & idx, int & pos) const
98 return idxPrev(idx, pos);
102 bool MathNestInset::idxFirst(int & i, int & pos) const
112 bool MathNestInset::idxLast(int & i, int & pos) const
117 pos = cell(i).size();
122 bool MathNestInset::idxHome(int & /* idx */, int & pos) const
131 bool MathNestInset::idxEnd(int & idx, int & pos) const
133 if (pos == cell(idx).size())
136 pos = cell(idx).size();
141 void MathNestInset::dump() const
143 lyxerr << "---------------------------------------------\n";
144 write(lyxerr, false);
146 for (int i = 0; i < nargs(); ++i)
147 lyxerr << cell(i) << "\n";
148 lyxerr << "---------------------------------------------\n";
152 void MathNestInset::push_back(unsigned char ch, MathTextCodes fcode)
155 cells_.back().data_.push_back(ch, fcode);
157 lyxerr << "can't push without a cell\n";
161 void MathNestInset::push_back(MathInset * p)
164 cells_.back().data_.push_back(p);
166 lyxerr << "can't push without a cell\n";
170 void MathNestInset::validate(LaTeXFeatures & features) const
172 for (int i = 0; i < nargs(); ++i)
173 cell(i).validate(features);