]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_data.C
revert Buffer LyxText->InsetText commit
[lyx.git] / src / mathed / math_data.C
index 9094764faeda85cbd901e6d5432982808a49717c..7617621047e771cd031f7eaa09e28b1375f5cda7 100644 (file)
 #include <config.h>
 
 #include "math_data.h"
-#include "math_inset.h"
-#include "math_cursor.h"
-#include "math_deliminset.h"
 #include "math_fontinset.h"
 #include "math_scriptinset.h"
 #include "math_mathmlstream.h"
 #include "math_support.h"
 #include "math_replace.h"
 #include "debug.h"
-#include "support/LAssert.h"
-#include "metricsinfo.h"
-#include "math_data.h"
+#include "LColor.h"
+
 #include "frontends/Painter.h"
-#include "textpainter.h"
 
-using namespace lyx::support;
+#include <boost/assert.hpp>
 
-using std::max;
-using std::min;
 using std::abs;
 using std::endl;
+using std::min;
+using std::ostringstream;
 
 
 MathArray::MathArray()
@@ -53,14 +48,14 @@ void MathArray::substitute(MathMacro const & m)
 
 MathAtom & MathArray::operator[](pos_type pos)
 {
-       Assert(pos < size());
+       BOOST_ASSERT(pos < size());
        return base_type::operator[](pos);
 }
 
 
 MathAtom const & MathArray::operator[](pos_type pos) const
 {
-       Assert(pos < size());
+       BOOST_ASSERT(pos < size());
        return base_type::operator[](pos);
 }
 
@@ -73,7 +68,7 @@ void MathArray::insert(size_type pos, MathAtom const & t)
 
 void MathArray::insert(size_type pos, MathArray const & ar)
 {
-       Assert(pos <= size());
+       BOOST_ASSERT(pos <= size());
        base_type::insert(begin() + pos, ar.begin(), ar.end());
 }
 
@@ -144,7 +139,7 @@ bool MathArray::matchpart(MathArray const & ar, pos_type pos) const
                return false;
        const_iterator it = begin() + pos;
        for (const_iterator jt = ar.begin(); jt != ar.end(); ++jt, ++it)
-               if (!(*jt)->match(*it))
+               if (asString(*it) != asString(*jt))
                        return false;
        return true;
 }
@@ -171,9 +166,9 @@ void MathArray::replace(ReplaceData & rep)
 
 bool MathArray::find1(MathArray const & ar, size_type pos) const
 {
-       //lyxerr << "finding '" << ar << "' in '" << *this << "'" << endl;
+       lyxerr << "finding '" << ar << "' in '" << *this << "'" << endl;
        for (size_type i = 0, n = ar.size(); i < n; ++i)
-               if (!operator[](pos + i)->match(ar[i]))
+               if (asString(operator[](pos + i)) != asString(ar[i]))
                        return false;
        return true;
 }
@@ -237,7 +232,7 @@ void MathArray::metrics(MetricsInfo & mi) const
                for (const_iterator it = begin(), et = end(); it != et; ++it) {
                        (*it)->metrics(mi, d);
                        dim_ += d;
-                       it->width_ = d.wid;
+                       //it->width_ = d.wid;
                }
        }
 }
@@ -268,9 +263,9 @@ void MathArray::draw(PainterInfo & pi, int x, int y) const
        }
 
        for (const_iterator it = begin(), et = end(); it != et; ++it) {
-               pi.width = it->width_;
+               //pi.width = it->width_;
                (*it)->draw(pi, x, y);
-               x += it->width_;
+               x += (*it)->width();
        }
 }
 
@@ -299,7 +294,8 @@ void MathArray::drawT(TextPainter & pain, int x, int y) const
 
        for (const_iterator it = begin(), et = end(); it != et; ++it) {
                (*it)->drawT(pain, x, y);
-               x += it->width_;
+               //x += (*it->width_;
+               x += 2;
        }
 }
 
@@ -318,7 +314,9 @@ int MathArray::pos2x(size_type pos, int glue) const
                const_iterator it = begin() + i;
                if ((*it)->getChar() == ' ')
                        x += glue;
-               x += it->width_;
+               //lyxerr << "char: " << (*it)->getChar()
+               //      << "width: " << (*it)->width() << std::endl;
+               x += (*it)->width();
        }
        return x;
 }
@@ -339,7 +337,7 @@ MathArray::size_type MathArray::x2pos(int targetx, int glue) const
                lastx = currx;
                if ((*it)->getChar() == ' ')
                        currx += glue;
-               currx += it->width_;
+               currx += (*it)->width();
        }
        if (abs(lastx - targetx) < abs(currx - targetx) && it != begin())
                --it;
@@ -375,6 +373,13 @@ void MathArray::boundingBox(int & x1, int & x2, int & y1, int & y2)
 }
 
 
+bool MathArray::contains(int x, int y) const
+{
+       return xo_ <= x && x <= xo_ + width()
+              && yo_ - ascent() <= y && y <= yo_ + descent();
+}
+
+
 void MathArray::center(int & x, int & y) const
 {
        x = xo_ + width() / 2;
@@ -407,6 +412,7 @@ void MathArray::notifyCursorLeaves()
 {
        // do not recurse!
 
+/*
        // remove base-only "scripts"
        for (pos_type i = 0; i + 1 < size(); ++i) {
                MathScriptInset * p = operator[](i).nucleus()->asScriptInset();
@@ -428,5 +434,5 @@ void MathArray::notifyCursorLeaves()
                        mathcursor->adjust(i, -1);
                }
        }
-
+*/
 }