X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fmathed%2Fmath_nestinset.C;h=fc316df70ca69566088d5ddc47a36fd1c3298299;hb=7435fca771bf7c8b4ca5d1801162f8c23112f3cf;hp=aed935a19fa9d88f99c600eb95d4e661796405c5;hpb=51e0c8bd1f265913a64fb46bc61fcfdb26f02303;p=lyx.git diff --git a/src/mathed/math_nestinset.C b/src/mathed/math_nestinset.C index aed935a19f..fc316df70c 100644 --- a/src/mathed/math_nestinset.C +++ b/src/mathed/math_nestinset.C @@ -6,68 +6,66 @@ #include "debug.h" -MathNestInset::MathNestInset(int nargs, string const & name) - : MathInset(name), cells_(nargs) +MathNestInset::MathNestInset(unsigned int nargs) + : MathDimInset(), cells_(nargs) {} -int MathNestInset::nargs() const +unsigned int MathNestInset::nargs() const { return cells_.size(); } -MathXArray & MathNestInset::xcell(int i) +MathXArray & MathNestInset::xcell(unsigned int i) { return cells_[i]; } -MathXArray const & MathNestInset::xcell(int i) const +MathXArray const & MathNestInset::xcell(unsigned int i) const { return cells_[i]; } -MathArray & MathNestInset::cell(int i) +MathArray & MathNestInset::cell(unsigned int i) { return cells_[i].data_; } -MathArray const & MathNestInset::cell(int i) const +MathArray const & MathNestInset::cell(unsigned int i) const { return cells_[i].data_; } -void MathNestInset::substitute(MathArray & array, MathMacro const & m) const +void MathNestInset::substitute(MathMacro const & m) { - MathNestInset * p = static_cast(clone()); - for (int i = 0; i < nargs(); ++i) - p->cell(i).substitute(m); - array.push_back(p); + for (unsigned int i = 0; i < nargs(); ++i) + cell(i).substitute(m); } -void MathNestInset::metrics(MathStyles st) +void MathNestInset::metrics(MathStyles st) const { size_ = st; - for (int i = 0; i < nargs(); ++i) + for (unsigned int i = 0; i < nargs(); ++i) xcell(i).metrics(st); } -void MathNestInset::draw(Painter & pain, int x, int y) +void MathNestInset::draw(Painter & pain, int x, int y) const { xo(x); yo(y); - for (int i = 0; i < nargs(); ++i) + for (unsigned int i = 0; i < nargs(); ++i) xcell(i).draw(pain, x + xcell(i).xo(), y + xcell(i).yo()); } -bool MathNestInset::idxNext(int & idx, int & pos) const +bool MathNestInset::idxNext(unsigned int & idx, unsigned int & pos) const { if (idx + 1 >= nargs()) return false; @@ -77,13 +75,13 @@ bool MathNestInset::idxNext(int & idx, int & pos) const } -bool MathNestInset::idxRight(int & idx, int & pos) const +bool MathNestInset::idxRight(unsigned int & idx, unsigned int & pos) const { return idxNext(idx, pos); } -bool MathNestInset::idxPrev(int & idx, int & pos) const +bool MathNestInset::idxPrev(unsigned int & idx, unsigned int & pos) const { if (idx == 0) return false; @@ -93,13 +91,13 @@ bool MathNestInset::idxPrev(int & idx, int & pos) const } -bool MathNestInset::idxLeft(int & idx, int & pos) const +bool MathNestInset::idxLeft(unsigned int & idx, unsigned int & pos) const { return idxPrev(idx, pos); } -bool MathNestInset::idxFirst(int & i, int & pos) const +bool MathNestInset::idxFirst(unsigned int & i, unsigned int & pos) const { if (nargs() == 0) return false; @@ -109,7 +107,7 @@ bool MathNestInset::idxFirst(int & i, int & pos) const } -bool MathNestInset::idxLast(int & i, int & pos) const +bool MathNestInset::idxLast(unsigned int & i, unsigned int & pos) const { if (nargs() == 0) return false; @@ -119,7 +117,7 @@ bool MathNestInset::idxLast(int & i, int & pos) const } -bool MathNestInset::idxHome(int & /* idx */, int & pos) const +bool MathNestInset::idxHome(unsigned int & /* idx */, unsigned int & pos) const { if (pos == 0) return false; @@ -128,12 +126,13 @@ bool MathNestInset::idxHome(int & /* idx */, int & pos) const } -bool MathNestInset::idxEnd(int & idx, int & pos) const +bool MathNestInset::idxEnd(unsigned int & idx, unsigned int & pos) const { - if (pos == cell(idx).size()) + unsigned int n = cell(idx).size(); + if (pos == n) return false; - pos = cell(idx).size(); + pos = n; return true; } @@ -143,21 +142,12 @@ void MathNestInset::dump() const lyxerr << "---------------------------------------------\n"; write(lyxerr, false); lyxerr << "\n"; - for (int i = 0; i < nargs(); ++i) + for (unsigned int i = 0; i < nargs(); ++i) lyxerr << cell(i) << "\n"; lyxerr << "---------------------------------------------\n"; } -void MathNestInset::push_back(unsigned char ch, MathTextCodes fcode) -{ - if (nargs()) - cells_.back().data_.push_back(ch, fcode); - else - lyxerr << "can't push without a cell\n"; -} - - void MathNestInset::push_back(MathInset * p) { if (nargs()) @@ -169,6 +159,6 @@ void MathNestInset::push_back(MathInset * p) void MathNestInset::validate(LaTeXFeatures & features) const { - for (int i = 0; i < nargs(); ++i) + for (unsigned int i = 0; i < nargs(); ++i) cell(i).validate(features); }