]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_inset.C
small stuff
[lyx.git] / src / mathed / math_inset.C
index c086623e0b9e95e512d5b67390b6968c20555e7b..9bc23390677907a362a73df3f06b728794f56084 100644 (file)
 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,11 +43,12 @@ 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);
@@ -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)
 {}
 
@@ -319,7 +236,7 @@ void MathInset::userSetSize(MathStyles sz)
 
 void MathInset::writeNormal(std::ostream & os) const
 {
-       os << "[" << name_ << "] ";
+       os << "[unknown] ";
 }
 
 
@@ -327,28 +244,19 @@ void MathInset::dump() const
 {
        lyxerr << "---------------------------------------------\n";
        write(lyxerr, false);
-       lyxerr << "\n";
-       for (int i = 0; i < nargs(); ++i)
-               lyxerr << cell(i) << "\n";
-       lyxerr << "---------------------------------------------\n";
+       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<int> MathInset::idxBetween(int from, int to) const
 {
@@ -374,3 +281,22 @@ std::vector<int> 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";
+}