5 #include "math_nestinset.h"
6 #include "math_cursor.h"
7 #include "math_mathmlstream.h"
9 #include "frontends/Painter.h"
12 MathNestInset::MathNestInset(idx_type nargs)
13 : MathDimInset(), cells_(nargs), lock_(false)
17 MathInset::idx_type MathNestInset::nargs() const
23 MathXArray & MathNestInset::xcell(idx_type i)
29 MathXArray const & MathNestInset::xcell(idx_type i) const
35 MathArray & MathNestInset::cell(idx_type i)
37 return cells_[i].data_;
41 MathArray const & MathNestInset::cell(idx_type i) const
43 return cells_[i].data_;
47 void MathNestInset::substitute(MathMacro const & m)
49 for (idx_type i = 0; i < nargs(); ++i)
50 cell(i).substitute(m);
54 void MathNestInset::metrics(MathMetricsInfo const & mi) const
56 MathMetricsInfo m = mi;
58 for (idx_type i = 0; i < nargs(); ++i) {
65 bool MathNestInset::idxNext(idx_type & idx, pos_type & pos) const
67 if (idx + 1 >= nargs())
75 bool MathNestInset::idxRight(idx_type & idx, pos_type & pos) const
77 return idxNext(idx, pos);
81 bool MathNestInset::idxPrev(idx_type & idx, pos_type & pos) const
86 pos = cell(idx).size();
91 bool MathNestInset::idxLeft(idx_type & idx, pos_type & pos) const
93 return idxPrev(idx, pos);
97 bool MathNestInset::idxFirst(idx_type & i, pos_type & pos) const
107 bool MathNestInset::idxLast(idx_type & i, pos_type & pos) const
112 pos = cell(i).size();
117 bool MathNestInset::idxHome(idx_type & /* idx */, pos_type & pos) const
126 bool MathNestInset::idxEnd(idx_type & idx, pos_type & pos) const
128 pos_type n = cell(idx).size();
136 void MathNestInset::dump() const
138 WriteStream os(lyxerr);
139 os << "---------------------------------------------\n";
142 for (idx_type i = 0; i < nargs(); ++i)
143 os << cell(i) << "\n";
144 os << "---------------------------------------------\n";
148 //void MathNestInset::draw(MathPainterInfo & pi, int x, int y) const
149 void MathNestInset::draw(MathPainterInfo &, int, int) const
153 pi.pain.fillRectangle(x, y - ascent(), width(), height(),
159 void MathNestInset::validate(LaTeXFeatures & features) const
161 for (idx_type i = 0; i < nargs(); ++i)
162 cell(i).validate(features);
166 bool MathNestInset::match(MathInset * p) const
168 if (nargs() != p->nargs())
170 for (idx_type i = 0; i < nargs(); ++i)
171 if (!cell(i).match(p->cell(i)))
177 void MathNestInset::replace(ReplaceData & rep)
179 for (idx_type i = 0; i < nargs(); ++i)
180 cell(i).replace(rep);
184 bool MathNestInset::contains(MathArray const & ar)
186 for (idx_type i = 0; i < nargs(); ++i)
187 if (cell(i).contains(ar))
193 bool MathNestInset::editing() const
195 return mathcursor && mathcursor->isInside(this);
199 bool MathNestInset::lock() const
205 void MathNestInset::lock(bool l)
211 bool MathNestInset::isActive() const
217 MathArray MathNestInset::glue() const
220 for (unsigned i = 0; i < nargs(); ++i)
221 ar.push_back(cell(i));