]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_nestinset.C
oh well
[lyx.git] / src / mathed / math_nestinset.C
index 5dccb4b5595670d1e2746dc1362ff1ec6c234c71..6a11a9dbfee62ee6a0d4805bc02ae358d9bfd767 100644 (file)
@@ -3,6 +3,8 @@
 #endif
 
 #include "math_nestinset.h"
+#include "math_cursor.h"
+#include "math_mathmlstream.h"
 #include "debug.h"
 
 
@@ -48,20 +50,14 @@ void MathNestInset::substitute(MathMacro const & m)
 }
 
 
-void MathNestInset::metrics(MathStyles st) const
+void MathNestInset::metrics(MathMetricsInfo const & mi) const
 {
-       size_ = st;
-       for (idx_type i = 0; i < nargs(); ++i)
-               xcell(i).metrics(st);
-}
-
-
-void MathNestInset::draw(Painter & pain, int x, int y) const
-{
-       xo(x);
-       yo(y);
-       for (idx_type i = 0; i < nargs(); ++i)
-               xcell(i).draw(pain, x + xcell(i).xo(), y + xcell(i).yo());
+       MathMetricsInfo m = mi;
+       m.inset = this;
+       for (idx_type i = 0; i < nargs(); ++i) {
+               m.idx = i;
+               xcell(i).metrics(m);
+       }
 }
 
 
@@ -131,7 +127,6 @@ bool MathNestInset::idxEnd(idx_type & idx, pos_type & pos) const
        pos_type n = cell(idx).size();
        if (pos == n)
                return false;
-
        pos = n;
        return true;
 }
@@ -139,26 +134,51 @@ bool MathNestInset::idxEnd(idx_type & idx, pos_type & pos) const
 
 void MathNestInset::dump() const
 {
-       lyxerr << "---------------------------------------------\n";
-       write(lyxerr, false);
-       lyxerr << "\n";
+       WriteStream os(lyxerr);
+       os << "---------------------------------------------\n";
+       write(os);
+       os << "\n";
        for (idx_type i = 0; i < nargs(); ++i)
-               lyxerr << cell(i) << "\n";
-       lyxerr << "---------------------------------------------\n";
+               os << cell(i) << "\n";
+       os << "---------------------------------------------\n";
 }
 
 
-void MathNestInset::push_back(MathAtom const & t)
+void MathNestInset::validate(LaTeXFeatures & features) const
 {
-       if (nargs())
-               cells_.back().data_.push_back(t);
-       else
-               lyxerr << "can't push without a cell\n";
+       for (idx_type i = 0; i < nargs(); ++i)
+               cell(i).validate(features);
 }
 
 
-void MathNestInset::validate(LaTeXFeatures & features) const
+bool MathNestInset::match(MathInset * p) const
 {
+       if (nargs() != p->nargs())
+               return false;
        for (idx_type i = 0; i < nargs(); ++i)
-               cell(i).validate(features);
+               if (!cell(i).match(p->cell(i)))
+                       return false;
+       return true;
+}
+
+
+void MathNestInset::replace(ReplaceData & rep)
+{
+       for (idx_type i = 0; i < nargs(); ++i)
+               cell(i).replace(rep);
+}
+
+
+bool MathNestInset::contains(MathArray const & ar)
+{
+       for (idx_type i = 0; i < nargs(); ++i)
+               if (cell(i).contains(ar))
+                       return true;
+       return false;
+}
+
+
+bool MathNestInset::editing() const
+{
+       return mathcursor && mathcursor->isInside(this);
 }