]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_nestinset.C
oh well
[lyx.git] / src / mathed / math_nestinset.C
index 03c1c2f04ebc787e77c47b13270ae9a2f475fe3d..6a11a9dbfee62ee6a0d4805bc02ae358d9bfd767 100644 (file)
@@ -3,6 +3,7 @@
 #endif
 
 #include "math_nestinset.h"
+#include "math_cursor.h"
 #include "math_mathmlstream.h"
 #include "debug.h"
 
@@ -51,15 +52,12 @@ void MathNestInset::substitute(MathMacro const & m)
 
 void MathNestInset::metrics(MathMetricsInfo const & mi) const
 {
-       for (idx_type i = 0; i < nargs(); ++i)
-               xcell(i).metrics(mi);
-}
-
-
-void MathNestInset::draw(Painter & pain, int x, int y) const
-{
-       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);
+       }
 }
 
 
@@ -146,35 +144,41 @@ void MathNestInset::dump() const
 }
 
 
-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;
 }
 
 
-bool MathNestInset::covers(int x, int y) const
+void MathNestInset::replace(ReplaceData & rep)
 {
-       if (!nargs())
-               return false;
-       int x0 = xcell(0).xo();
-       int y0 = xcell(0).yo() - xcell(0).ascent();
-       int x1 = xcell(0).xo() + xcell(0).width();
-       int y1 = xcell(0).yo() + xcell(0).descent();
-       for (idx_type i = 1; i < nargs(); ++i) {
-               x0 = std::min(x0, xcell(i).xo());
-               y0 = std::min(y0, xcell(i).yo() - xcell(i).ascent());
-               x1 = std::max(x1, xcell(i).xo() + xcell(i).width());
-               y1 = std::max(y1, xcell(i).yo() + xcell(i).descent());
-       }
-       return x >= x0 && x <= x1 && y >= y0 && y <= y1;
+       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);
 }