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 MathNestInset * p = static_cast<MathNestInset *>(clone());
49 for (int i = 0; i < nargs(); ++i)
50 p->cell(i).substitute(m);
55 void MathNestInset::metrics(MathStyles st)
58 for (int i = 0; i < nargs(); ++i)
63 void MathNestInset::draw(Painter & pain, int x, int y)
67 for (int i = 0; i < nargs(); ++i)
68 xcell(i).draw(pain, x + xcell(i).xo(), y + xcell(i).yo());
72 bool MathNestInset::idxNext(int & idx, int & pos) const
74 if (idx + 1 >= nargs())
82 bool MathNestInset::idxRight(int & idx, int & pos) const
84 return idxNext(idx, pos);
88 bool MathNestInset::idxPrev(int & idx, int & pos) const
93 pos = cell(idx).size();
98 bool MathNestInset::idxLeft(int & idx, int & pos) const
100 return idxPrev(idx, pos);
104 bool MathNestInset::idxFirst(int & i, int & pos) const
114 bool MathNestInset::idxLast(int & i, int & pos) const
119 pos = cell(i).size();
124 bool MathNestInset::idxHome(int & /* idx */, int & pos) const
133 bool MathNestInset::idxEnd(int & idx, int & pos) const
135 if (pos == cell(idx).size())
138 pos = cell(idx).size();
143 void MathNestInset::dump() const
145 lyxerr << "---------------------------------------------\n";
146 write(lyxerr, false);
148 for (int i = 0; i < nargs(); ++i)
149 lyxerr << cell(i) << "\n";
150 lyxerr << "---------------------------------------------\n";
154 void MathNestInset::push_back(unsigned char ch, MathTextCodes fcode)
157 cells_.back().data_.push_back(ch, fcode);
159 lyxerr << "can't push without a cell\n";
163 void MathNestInset::push_back(MathInset * p)
166 cells_.back().data_.push_back(p);
168 lyxerr << "can't push without a cell\n";
172 void MathNestInset::validate(LaTeXFeatures & features) const
174 for (int i = 0; i < nargs(); ++i)
175 cell(i).validate(features);