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
46 array.push_back(clone());
47 for (int i = 0; i < nargs(); ++i)
48 array.back()->cell(i).substitute(m);
52 void MathNestInset::metrics(MathStyles st) const
55 for (int i = 0; i < nargs(); ++i)
60 void MathNestInset::draw(Painter & pain, int x, int y) const
64 for (int i = 0; i < nargs(); ++i)
65 xcell(i).draw(pain, x + xcell(i).xo(), y + xcell(i).yo());
69 bool MathNestInset::idxNext(int & idx, int & pos) const
71 if (idx + 1 >= nargs())
79 bool MathNestInset::idxRight(int & idx, int & pos) const
81 return idxNext(idx, pos);
85 bool MathNestInset::idxPrev(int & idx, int & pos) const
90 pos = cell(idx).size();
95 bool MathNestInset::idxLeft(int & idx, int & pos) const
97 return idxPrev(idx, pos);
101 bool MathNestInset::idxFirst(int & i, int & pos) const
111 bool MathNestInset::idxLast(int & i, int & pos) const
116 pos = cell(i).size();
121 bool MathNestInset::idxHome(int & /* idx */, int & pos) const
130 bool MathNestInset::idxEnd(int & idx, int & pos) const
132 if (pos == cell(idx).size())
135 pos = cell(idx).size();
140 void MathNestInset::dump() const
142 lyxerr << "---------------------------------------------\n";
143 write(lyxerr, false);
145 for (int i = 0; i < nargs(); ++i)
146 lyxerr << cell(i) << "\n";
147 lyxerr << "---------------------------------------------\n";
151 void MathNestInset::push_back(unsigned char ch, MathTextCodes fcode)
154 cells_.back().data_.push_back(ch, fcode);
156 lyxerr << "can't push without a cell\n";
160 void MathNestInset::push_back(MathInset * p)
163 cells_.back().data_.push_back(p);
165 lyxerr << "can't push without a cell\n";
169 void MathNestInset::validate(LaTeXFeatures & features) const
171 for (int i = 0; i < nargs(); ++i)
172 cell(i).validate(features);