5 #include "math_nestinset.h"
9 MathNestInset::MathNestInset(int nargs, string const & name)
10 : MathDimInset(), cells_(nargs)
16 int MathNestInset::nargs() const
22 MathXArray & MathNestInset::xcell(int i)
28 MathXArray const & MathNestInset::xcell(int i) const
34 MathArray & MathNestInset::cell(int i)
36 return cells_[i].data_;
40 MathArray const & MathNestInset::cell(int i) const
42 return cells_[i].data_;
46 void MathNestInset::substitute(MathArray & array, MathMacro const & m) const
48 array.push_back(clone());
49 for (int i = 0; i < nargs(); ++i)
50 array.back()->cell(i).substitute(m);
54 void MathNestInset::metrics(MathStyles st) const
57 for (int i = 0; i < nargs(); ++i)
62 void MathNestInset::draw(Painter & pain, int x, int y) const
66 for (int i = 0; i < nargs(); ++i)
67 xcell(i).draw(pain, x + xcell(i).xo(), y + xcell(i).yo());
71 bool MathNestInset::idxNext(int & idx, int & pos) const
73 if (idx + 1 >= nargs())
81 bool MathNestInset::idxRight(int & idx, int & pos) const
83 return idxNext(idx, pos);
87 bool MathNestInset::idxPrev(int & idx, int & pos) const
92 pos = cell(idx).size();
97 bool MathNestInset::idxLeft(int & idx, int & pos) const
99 return idxPrev(idx, pos);
103 bool MathNestInset::idxFirst(int & i, int & pos) const
113 bool MathNestInset::idxLast(int & i, int & pos) const
118 pos = cell(i).size();
123 bool MathNestInset::idxHome(int & /* idx */, int & pos) const
132 bool MathNestInset::idxEnd(int & idx, int & pos) const
134 if (pos == cell(idx).size())
137 pos = cell(idx).size();
142 void MathNestInset::dump() const
144 lyxerr << "---------------------------------------------\n";
145 write(lyxerr, false);
147 for (int i = 0; i < nargs(); ++i)
148 lyxerr << cell(i) << "\n";
149 lyxerr << "---------------------------------------------\n";
153 void MathNestInset::push_back(unsigned char ch, MathTextCodes fcode)
156 cells_.back().data_.push_back(ch, fcode);
158 lyxerr << "can't push without a cell\n";
162 void MathNestInset::push_back(MathInset * p)
165 cells_.back().data_.push_back(p);
167 lyxerr << "can't push without a cell\n";
171 void MathNestInset::validate(LaTeXFeatures & features) const
173 for (int i = 0; i < nargs(); ++i)
174 cell(i).validate(features);