5 #include "math_nestinset.h"
9 MathNestInset::MathNestInset(int nargs)
10 : MathDimInset(), 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
48 MathNestInset * p = clone();
49 array.push_back(clone());
50 for (int i = 0; i < nargs(); ++i)
51 array.back().cellsubstitute(m);
56 void MathNestInset::metrics(MathStyles st) const
59 for (int i = 0; i < nargs(); ++i)
64 void MathNestInset::draw(Painter & pain, int x, int y) const
68 for (int i = 0; i < nargs(); ++i)
69 xcell(i).draw(pain, x + xcell(i).xo(), y + xcell(i).yo());
73 bool MathNestInset::idxNext(int & idx, int & pos) const
75 if (idx + 1 >= nargs())
83 bool MathNestInset::idxRight(int & idx, int & pos) const
85 return idxNext(idx, pos);
89 bool MathNestInset::idxPrev(int & idx, int & pos) const
94 pos = cell(idx).size();
99 bool MathNestInset::idxLeft(int & idx, int & pos) const
101 return idxPrev(idx, pos);
105 bool MathNestInset::idxFirst(int & i, int & pos) const
115 bool MathNestInset::idxLast(int & i, int & pos) const
120 pos = cell(i).size();
125 bool MathNestInset::idxHome(int & /* idx */, int & pos) const
134 bool MathNestInset::idxEnd(int & idx, int & pos) const
136 if (pos == cell(idx).size())
139 pos = cell(idx).size();
144 void MathNestInset::dump() const
146 lyxerr << "---------------------------------------------\n";
147 write(lyxerr, false);
149 for (int i = 0; i < nargs(); ++i)
150 lyxerr << cell(i) << "\n";
151 lyxerr << "---------------------------------------------\n";
155 void MathNestInset::push_back(MathInset * p)
158 cells_.back().data_.push_back(p);
160 lyxerr << "can't push without a cell\n";
164 void MathNestInset::validate(LaTeXFeatures & features) const
166 for (int i = 0; i < nargs(); ++i)
167 cell(i).validate(features);