X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fmathed%2Fmath_inset.C;h=9bc23390677907a362a73df3f06b728794f56084;hb=2da8fcabdc695b8bb139d7252b923ef6b9aa29dd;hp=b5980fc019530eeea4bbb7a63ff6fdc26233793b;hpb=9ccefe810b24031894fff8cf3dd39c1bc7f31241;p=lyx.git diff --git a/src/mathed/math_inset.C b/src/mathed/math_inset.C index b5980fc019..9bc2339067 100644 --- a/src/mathed/math_inset.C +++ b/src/mathed/math_inset.C @@ -26,67 +26,14 @@ int MathInset::workwidth; -MathInset::MathInset(int nargs, string const & name, MathInsetTypes ot) - : name_(name), objtype(ot), width_(0), ascent_(0), descent_(0), - size_(LM_ST_DISPLAY), cells_(nargs), xo_(0), yo_(0) +MathInset::MathInset() + : size_(LM_ST_DISPLAY), xo_(0), yo_(0) {} -int MathInset::ascent() const -{ - return ascent_; -} - - -int MathInset::descent() const -{ - return descent_; -} - - -int MathInset::width() const -{ - return width_; -} - - int MathInset::height() const { - return ascent_ + descent_; -} - - -int MathInset::limits() const -{ - return false; -} - - -void MathInset::limits(int) -{ -} - -string const & MathInset::name() const -{ - return name_; -} - - -MathInsetTypes MathInset::GetType() const -{ - return objtype; -} - - -void MathInset::SetType(MathInsetTypes t) -{ - objtype = t; -} - - -void MathInset::SetName(string const & n) -{ - name_ = n; + return ascent() + descent(); } @@ -96,14 +43,15 @@ MathStyles MathInset::size() const } -void MathInset::size(MathStyles s) +void MathInset::size(MathStyles s) const { size_ = s; } + std::ostream & operator<<(std::ostream & os, MathInset const & inset) { - inset.Write(os, false); + inset.write(os, false); return os; } @@ -120,13 +68,13 @@ int MathInset::yo() const } -void MathInset::xo(int x) +void MathInset::xo(int x) const { xo_ = x; } -void MathInset::yo(int y) +void MathInset::yo(int y) const { yo_ = y; } @@ -134,89 +82,70 @@ void MathInset::yo(int y) int MathInset::nargs() const { - return cells_.size(); + return 0; } +MathXArray dummyCell; -MathXArray & MathInset::xcell(int i) -{ - return cells_[i]; -} - -MathXArray const & MathInset::xcell(int i) const +MathXArray & MathInset::xcell(int) { - return cells_[i]; + lyxerr << "I don't have a cell\n"; + return dummyCell; } - -MathArray & MathInset::cell(int i) +MathXArray const & MathInset::xcell(int) const { - return cells_[i].data_; + lyxerr << "I don't have a cell\n"; + return dummyCell; } -MathArray const & MathInset::cell(int i) const + +MathArray & MathInset::cell(int) { - return cells_[i].data_; + lyxerr << "I don't have a cell\n"; + return dummyCell.data_; } -void MathInset::substitute(MathArray & array, MathMacro const & m) const +MathArray const & MathInset::cell(int) const { - MathInset * p = clone(); - for (int i = 0; i < nargs(); ++i) - p->cell(i).substitute(m); - array.push_back(p); + lyxerr << "I don't have a cell\n"; + return dummyCell.data_; } -void MathInset::Metrics(MathStyles st) -{ - size_ = st; - for (int i = 0; i < nargs(); ++i) - xcell(i).Metrics(st); -} -void MathInset::draw(Painter & pain, int x, int y) +void MathInset::substitute(MathArray & array, MathMacro const &) const { - xo_ = x; - yo_ = y; - for (int i = 0; i < nargs(); ++i) - xcell(i).draw(pain, x + xcell(i).xo(), y + xcell(i).yo()); + array.push_back(clone()); } -bool MathInset::idxNext(int & idx, int & pos) const +bool MathInset::idxNext(int &, int &) const { - if (idx + 1 >= nargs()) - return false; - ++idx; - pos = 0; - return true; + return false; } -bool MathInset::idxRight(int & idx, int & pos) const +bool MathInset::idxRight(int &, int &) const { - return idxNext(idx, pos); + return false; } -bool MathInset::idxPrev(int & idx, int & pos) const +bool MathInset::idxPrev(int &, int &) const { - if (idx == 0) - return false; - --idx; - pos = cell(idx).size(); - return true; + return false; } -bool MathInset::idxLeft(int & idx, int & pos) const +bool MathInset::idxLeft(int &, int &) const { - return idxPrev(idx, pos); + return false; } + bool MathInset::idxUp(int &, int &) const { return false; @@ -229,41 +158,27 @@ bool MathInset::idxDown(int &, int &) const } -bool MathInset::idxFirst(int & i, int & pos) const +bool MathInset::idxFirst(int &, int &) const { - if (nargs() == 0) - return false; - i = 0; - pos = 0; - return true; + return false; } -bool MathInset::idxLast(int & i, int & pos) const + +bool MathInset::idxLast(int &, int &) const { - if (nargs() == 0) - return false; - i = nargs() - 1; - pos = cell(i).size(); - return true; + return false; } -bool MathInset::idxHome(int & /* idx */, int & pos) const +bool MathInset::idxHome(int &, int &) const { - if (pos == 0) - return false; - pos = 0; - return true; + return false; } -bool MathInset::idxEnd(int & idx, int & pos) const +bool MathInset::idxEnd(int &, int &) const { - if (pos == cell(idx).size()) - return false; - - pos = cell(idx).size(); - return true; + return false; } @@ -278,12 +193,14 @@ bool MathInset::idxFirstDown(int &, int &) const return false; } + void MathInset::idxDelete(int &, bool & popit, bool & deleteit) { popit = false; deleteit = false; } + void MathInset::idxDeleteRange(int, int) {} @@ -300,7 +217,7 @@ bool MathInset::idxLastDown(int &, int &) const } -void MathInset::GetXY(int & x, int & y) const +void MathInset::getXY(int & x, int & y) const { x = xo(); y = yo(); @@ -308,7 +225,7 @@ void MathInset::GetXY(int & x, int & y) const /* -void MathInset::UserSetSize(MathStyles sz) +void MathInset::userSetSize(MathStyles sz) { if (sz >= 0) { size_ = sz; @@ -317,38 +234,29 @@ void MathInset::UserSetSize(MathStyles sz) } */ -void MathInset::WriteNormal(std::ostream & os) const +void MathInset::writeNormal(std::ostream & os) const { - os << "[" << name_ << "] "; + os << "[unknown] "; } void MathInset::dump() const { lyxerr << "---------------------------------------------\n"; - Write(lyxerr, false); - lyxerr << "\n"; - for (int i = 0; i < nargs(); ++i) - lyxerr << cell(i) << "\n"; - lyxerr << "---------------------------------------------\n"; + write(lyxerr, false); + lyxerr << "\n---------------------------------------------\n"; } -void MathInset::push_back(unsigned char ch, MathTextCodes fcode) +void MathInset::push_back(unsigned char, MathTextCodes) { - if (nargs()) - cells_.back().data_.push_back(ch, fcode); - else - lyxerr << "can't push without a cell\n"; + lyxerr << "can't push without a cell\n"; } -void MathInset::push_back(MathInset * p) +void MathInset::push_back(MathInset *) { - if (nargs()) - cells_.back().data_.push_back(p); - else - lyxerr << "can't push without a cell\n"; + lyxerr << "can't push without a cell\n"; } @@ -356,16 +264,15 @@ bool MathInset::covers(int x, int y) const { return x >= xo_ && - x <= xo_ + width_ && - y >= yo_ - ascent_ && - y <= yo_ + descent_; + x <= xo_ + width() && + y >= yo_ - ascent() && + y <= yo_ + descent(); } -void MathInset::Validate(LaTeXFeatures & features) const -{ - for (int i = 0; i < nargs(); ++i) - cell(i).Validate(features); -} + +void MathInset::validate(LaTeXFeatures &) const +{} + std::vector MathInset::idxBetween(int from, int to) const { @@ -374,3 +281,22 @@ std::vector MathInset::idxBetween(int from, int to) const res.push_back(i); return res; } + + +void MathInset::metrics(MathStyles st) const +{ + lyxerr << "MathInset::metrics() called directly!\n"; + size_ = st; +} + + +void MathInset::draw(Painter &, int, int) const +{ + lyxerr << "MathInset::draw() called directly!\n"; +} + + +void MathInset::write(std::ostream &, bool) const +{ + lyxerr << "MathInset::write() called directly!\n"; +}