]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_data.C
fix #1073
[lyx.git] / src / mathed / math_data.C
index e4b9c50dda981ebf5fed09e8aeb8872e2f4a7430..4e0c68db489e408534ab51b1a13bc59c24b963b0 100644 (file)
@@ -1,8 +1,5 @@
 #include <config.h>
 
-#ifdef __GNUG__
-#pragma implementation
-#endif
 
 #include "math_data.h"
 #include "math_inset.h"
@@ -15,7 +12,7 @@
 #include "math_replace.h"
 #include "debug.h"
 #include "support/LAssert.h"
-#include "math_metricsinfo.h"
+#include "metricsinfo.h"
 #include "frontends/Painter.h"
 #include "textpainter.h"
 
@@ -113,7 +110,7 @@ void MathArray::dump() const
 {
        NormalStream ns(lyxerr);
        for (const_iterator it = begin(); it != end(); ++it)
-               ns << "<" << *it << ">";
+               ns << '<' << *it << '>';
 }
 
 
@@ -207,7 +204,7 @@ void MathArray::touch() const
 }
 
 
-Dimension const & MathArray::metrics(MathMetricsInfo & mi) const
+Dimension const & MathArray::metrics(MetricsInfo & mi) const
 {
        //if (clean_)
        //      return;
@@ -215,7 +212,7 @@ Dimension const & MathArray::metrics(MathMetricsInfo & mi) const
        drawn_  = false;
 
        mathed_char_dim(mi.base.font, 'I', dim_);
-       if (empty()) 
+       if (empty())
                return dim_;
 
        dim_.w = 0;
@@ -227,7 +224,7 @@ Dimension const & MathArray::metrics(MathMetricsInfo & mi) const
 }
 
 
-void MathArray::draw(MathPainterInfo & pi, int x, int y) const
+void MathArray::draw(PainterInfo & pi, int x, int y) const
 {
        //if (drawn_ && x == xo_ && y == yo_)
        //      return;
@@ -275,7 +272,7 @@ void MathArray::drawT(TextPainter & pain, int x, int y) const
 {
        //if (drawn_ && x == xo_ && y == yo_)
        //      return;
-       //lyxerr << "x: " << x << " y: " << y << " " << pain.workAreaHeight() << endl;
+       //lyxerr << "x: " << x << " y: " << y << ' ' << pain.workAreaHeight() << endl;
        xo_    = x;
        yo_    = y;
        drawn_ = true;
@@ -289,15 +286,15 @@ void MathArray::drawT(TextPainter & pain, int x, int y) const
 
 int MathArray::pos2x(size_type pos) const
 {
-       return pos2x(0, pos, 0);
+       return pos2x(pos, 0);
 }
 
 
-int MathArray::pos2x(size_type pos1, size_type pos2, int glue) const
+int MathArray::pos2x(size_type pos, int glue) const
 {
        int x = 0;
-       size_type target = min(pos2, size());
-       for (size_type i = pos1; i < target; ++i) {
+       size_type target = min(pos, size());
+       for (size_type i = 0; i < target; ++i) {
                const_iterator it = begin() + i;
                if ((*it)->getChar() == ' ')
                        x += glue;
@@ -309,14 +306,13 @@ int MathArray::pos2x(size_type pos1, size_type pos2, int glue) const
 
 MathArray::size_type MathArray::x2pos(int targetx) const
 {
-       return x2pos(0, targetx, 0);
+       return x2pos(targetx, 0);
 }
 
 
-MathArray::size_type MathArray::x2pos(size_type startpos, int targetx,
-       int glue) const
+MathArray::size_type MathArray::x2pos(int targetx, int glue) const
 {
-       const_iterator it = begin() + startpos;
+       const_iterator it = begin();
        int lastx = 0;
        int currx = 0;
        for (; currx < targetx && it < end(); ++it) {
@@ -325,7 +321,7 @@ MathArray::size_type MathArray::x2pos(size_type startpos, int targetx,
                        currx += glue;
                currx += (*it)->width();
        }
-       if (abs(lastx - targetx) < abs(currx - targetx) && it != begin() + startpos)
+       if (abs(lastx - targetx) < abs(currx - targetx) && it != begin())
                --it;
        return it - begin();
 }
@@ -358,6 +354,7 @@ void MathArray::boundingBox(int & x1, int & x2, int & y1, int & y2)
        y2 = yo_ + descent();
 }
 
+
 void MathArray::center(int & x, int & y) const
 {
        x = xo_ + width() / 2;
@@ -400,7 +397,7 @@ void MathArray::notifyCursorLeaves()
                        mathcursor->adjust(i, ar.size() - 1);
                }
        }
-               
+
        // glue adjacent font insets of the same kind
        for (pos_type i = 0; i + 1 < size(); ++i) {
                MathFontInset * p = operator[](i).nucleus()->asFontInset();
@@ -408,8 +405,8 @@ void MathArray::notifyCursorLeaves()
                if (p && q && p->name() == q->name()) {
                        p->cell(0).append(q->cell(0));
                        erase(i + 1);
+                       mathcursor->adjust(i, -1);
                }
-               mathcursor->adjust(i, -1);
        }
 
 }