]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_xdata.C
forward search in math insets. ugly. seems to work. don't ask why.
[lyx.git] / src / mathed / math_xdata.C
index 61ce8145be2cb751f752c20c1f96b22be3a58981..28f5d5c32e40c15a38ba710d1ff1bf29240cf669 100644 (file)
@@ -122,3 +122,58 @@ MathArray::size_type MathXArray::x2pos(int targetx) const
                --it;
        return it - begin();
 }
+
+
+int MathXArray::dist(int x, int y) const
+{
+       int xx = 0;
+       int yy = 0;
+
+       if (x < xo_)
+               xx = xo_ - x;
+       else if (x > xo_ + width_)
+               xx = x - xo_ - width_;
+
+       if (y < yo_ - ascent_)
+               yy = yo_ - ascent_ - y;
+       else if (y > yo_ + descent_)
+               yy = y - yo_ - descent_;
+
+       return xx + yy; 
+}
+
+
+void MathXArray::boundingBox(int & x1, int & x2, int & y1, int & y2)
+{
+       x1 = xo_;
+       x2 = xo_ + width_;
+       y1 = yo_ - ascent_;
+       y2 = yo_ + descent_;
+}
+
+/*
+void MathXArray::findPos(MathPosFinder & f) const
+{
+       double x = xo_;
+       double y = yo_; 
+       for (const_iterator it = begin(); it < end(); ++it) {
+               // check this position in the cell first
+               f.visit(x, y);
+               f.nextPos();
+
+               // check inset
+               MathInset const * p = it->nucleus();
+               p->findPos(f);
+
+               // move on
+               MathScriptInset const * q = (it + 1 == end()) ? 0 : asScript(it);
+               if (q) {
+                       x += q->width(p);
+                       f.nextPos();
+                       ++it;
+               } else {
+                       x += p->width();
+               }
+       }
+}
+*/