5 #include "math_nestinset.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 for (idx_type i = 0; i < nargs(); ++i)
60 void MathNestInset::draw(Painter & pain, int x, int y) const
62 for (idx_type i = 0; i < nargs(); ++i)
63 xcell(i).draw(pain, x + xcell(i).xo(), y + xcell(i).yo());
67 bool MathNestInset::idxNext(idx_type & idx, pos_type & pos) const
69 if (idx + 1 >= nargs())
77 bool MathNestInset::idxRight(idx_type & idx, pos_type & pos) const
79 return idxNext(idx, pos);
83 bool MathNestInset::idxPrev(idx_type & idx, pos_type & pos) const
88 pos = cell(idx).size();
93 bool MathNestInset::idxLeft(idx_type & idx, pos_type & pos) const
95 return idxPrev(idx, pos);
99 bool MathNestInset::idxFirst(idx_type & i, pos_type & pos) const
109 bool MathNestInset::idxLast(idx_type & i, pos_type & pos) const
114 pos = cell(i).size();
119 bool MathNestInset::idxHome(idx_type & /* idx */, pos_type & pos) const
128 bool MathNestInset::idxEnd(idx_type & idx, pos_type & pos) const
130 pos_type n = cell(idx).size();
138 void MathNestInset::dump() const
140 MathWriteInfo os(lyxerr);
141 os << "---------------------------------------------\n";
144 for (idx_type i = 0; i < nargs(); ++i)
145 os << cell(i) << "\n";
146 os << "---------------------------------------------\n";
150 void MathNestInset::push_back(MathAtom const & t)
153 cells_.back().data_.push_back(t);
155 lyxerr << "can't push without a cell\n";
159 void MathNestInset::validate(LaTeXFeatures & features) const
161 for (idx_type i = 0; i < nargs(); ++i)
162 cell(i).validate(features);
166 bool MathNestInset::covers(int x, int y) const
170 int x0 = xcell(0).xo();
171 int y0 = xcell(0).yo() - xcell(0).ascent();
172 int x1 = xcell(0).xo() + xcell(0).width();
173 int y1 = xcell(0).yo() + xcell(0).descent();
174 for (idx_type i = 1; i < nargs(); ++i) {
175 x0 = min(x0, xcell(i).xo());
176 y0 = min(y0, xcell(i).yo() - xcell(i).ascent());
177 x1 = max(x1, xcell(i).xo() + xcell(i).width());
178 y1 = max(y1, xcell(i).yo() + xcell(i).descent());
180 return x >= x0 && x <= x1 && y >= y0 && y <= y1;