5 #include "math_nestinset.h"
9 MathNestInset::MathNestInset(idx_type nargs)
10 : MathDimInset(), cells_(nargs)
14 MathInset::idx_type MathNestInset::nargs() const
20 MathXArray & MathNestInset::xcell(idx_type i)
26 MathXArray const & MathNestInset::xcell(idx_type i) const
32 MathArray & MathNestInset::cell(idx_type i)
34 return cells_[i].data_;
38 MathArray const & MathNestInset::cell(idx_type i) const
40 return cells_[i].data_;
44 void MathNestInset::substitute(MathMacro const & m)
46 for (idx_type i = 0; i < nargs(); ++i)
47 cell(i).substitute(m);
51 void MathNestInset::metrics(MathMetricsInfo const & mi) const
53 for (idx_type i = 0; i < nargs(); ++i)
58 void MathNestInset::draw(Painter & pain, int x, int y) const
60 for (idx_type i = 0; i < nargs(); ++i)
61 xcell(i).draw(pain, x + xcell(i).xo(), y + xcell(i).yo());
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 MathWriteInfo 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::push_back(MathAtom const & t)
151 cells_.back().data_.push_back(t);
153 lyxerr << "can't push without a cell\n";
157 void MathNestInset::validate(LaTeXFeatures & features) const
159 for (idx_type i = 0; i < nargs(); ++i)
160 cell(i).validate(features);
164 bool MathNestInset::covers(int x, int y) const
168 int x0 = xcell(0).xo();
169 int y0 = xcell(0).yo() - xcell(0).ascent();
170 int x1 = xcell(0).xo() + xcell(0).width();
171 int y1 = xcell(0).yo() + xcell(0).descent();
172 for (idx_type i = 1; i < nargs(); ++i) {
173 x0 = min(x0, xcell(i).xo());
174 y0 = min(y0, xcell(i).yo() - xcell(i).ascent());
175 x1 = max(x1, xcell(i).xo() + xcell(i).width());
176 y1 = max(y1, xcell(i).yo() + xcell(i).descent());
178 return x >= x0 && x <= x1 && y >= y0 && y <= y1;