X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fmathed%2Fmath_inset.C;h=9bc23390677907a362a73df3f06b728794f56084;hb=2da8fcabdc695b8bb139d7252b923ef6b9aa29dd;hp=8685048ebed3fd444fc42d1bb58d0fb960abfb6d;hpb=ec5d8718c51e86b6300de5de29732634cace81d3;p=lyx.git diff --git a/src/mathed/math_inset.C b/src/mathed/math_inset.C index 8685048ebe..9bc2339067 100644 --- a/src/mathed/math_inset.C +++ b/src/mathed/math_inset.C @@ -15,88 +15,25 @@ * the GNU General Public Licence version 2 or later. */ -#include - #ifdef __GNUG__ #pragma implementation #endif #include "math_inset.h" -#include "mathed/support.h" -#include "Painter.h" #include "debug.h" int MathInset::workwidth; -MathInset::MathInset(string const & name, MathInsetTypes ot, int nargs) - : 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) -{ -} - -bool MathInset::hasLimits() const -{ - return false; -} - - -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(); } @@ -106,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; } @@ -130,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; } @@ -144,95 +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) -{ - return cells_[i].data_; -} - -MathArray const & MathInset::cell(int i) const +MathXArray const & MathInset::xcell(int) const { - return cells_[i].data_; + lyxerr << "I don't have a cell\n"; + return dummyCell; } -void MathInset::setData(MathArray const & a, int idx) +MathArray & MathInset::cell(int) { - cells_[idx].data_ = a; + 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; @@ -245,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; } @@ -294,12 +193,18 @@ bool MathInset::idxFirstDown(int &, int &) const return false; } -bool MathInset::idxDelete(int) + +void MathInset::idxDelete(int &, bool & popit, bool & deleteit) { - return false; + popit = false; + deleteit = false; } +void MathInset::idxDeleteRange(int, int) +{} + + bool MathInset::idxLastUp(int &, int &) const { return false; @@ -312,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(); @@ -320,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; @@ -329,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(byte 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"; } @@ -368,8 +264,39 @@ 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 &) const +{} + + +std::vector MathInset::idxBetween(int from, int to) const +{ + std::vector res; + for (int i = from; i <= to; ++i) + 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"; +}