5 #include "math_nestinset.h"
6 #include "math_cursor.h"
7 #include "math_mathmlstream.h"
11 MathNestInset::MathNestInset(idx_type nargs)
12 : MathDimInset(), cells_(nargs)
16 MathInset::idx_type MathNestInset::nargs() const
22 MathXArray & MathNestInset::xcell(idx_type i)
28 MathXArray const & MathNestInset::xcell(idx_type i) const
34 MathArray & MathNestInset::cell(idx_type i)
36 return cells_[i].data_;
40 MathArray const & MathNestInset::cell(idx_type i) const
42 return cells_[i].data_;
46 void MathNestInset::substitute(MathMacro const & m)
48 for (idx_type i = 0; i < nargs(); ++i)
49 cell(i).substitute(m);
53 void MathNestInset::metrics(MathMetricsInfo const & mi) const
55 MathMetricsInfo m = mi;
57 for (idx_type i = 0; i < nargs(); ++i) {
64 void MathNestInset::draw(Painter & pain, int x, int y) const
66 for (idx_type i = 0; i < nargs(); ++i)
67 xcell(i).draw(pain, x + xcell(i).xo(), y + xcell(i).yo());
71 bool MathNestInset::idxNext(idx_type & idx, pos_type & pos) const
73 if (idx + 1 >= nargs())
81 bool MathNestInset::idxRight(idx_type & idx, pos_type & pos) const
83 return idxNext(idx, pos);
87 bool MathNestInset::idxPrev(idx_type & idx, pos_type & pos) const
92 pos = cell(idx).size();
97 bool MathNestInset::idxLeft(idx_type & idx, pos_type & pos) const
99 return idxPrev(idx, pos);
103 bool MathNestInset::idxFirst(idx_type & i, pos_type & pos) const
113 bool MathNestInset::idxLast(idx_type & i, pos_type & pos) const
118 pos = cell(i).size();
123 bool MathNestInset::idxHome(idx_type & /* idx */, pos_type & pos) const
132 bool MathNestInset::idxEnd(idx_type & idx, pos_type & pos) const
134 pos_type n = cell(idx).size();
142 void MathNestInset::dump() const
144 WriteStream os(lyxerr);
145 os << "---------------------------------------------\n";
148 for (idx_type i = 0; i < nargs(); ++i)
149 os << cell(i) << "\n";
150 os << "---------------------------------------------\n";
154 void MathNestInset::validate(LaTeXFeatures & features) const
156 for (idx_type i = 0; i < nargs(); ++i)
157 cell(i).validate(features);
161 bool MathNestInset::match(MathInset * p) const
163 if (nargs() != p->nargs())
165 for (idx_type i = 0; i < nargs(); ++i)
166 if (!cell(i).match(p->cell(i)))
172 void MathNestInset::replace(ReplaceData & rep)
174 for (idx_type i = 0; i < nargs(); ++i)
175 cell(i).replace(rep);
179 bool MathNestInset::contains(MathArray const & ar)
181 for (idx_type i = 0; i < nargs(); ++i)
182 if (cell(i).contains(ar))
188 bool MathNestInset::editing() const
190 return mathcursor && mathcursor->isInside(this);