]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/MathData.cpp
Cleanup headers
[lyx.git] / src / mathed / MathData.cpp
index 9bfd558fe2856d8e1475648b8c9b1963255cf25a..610a3e20eb64ebae7e237f77baa6c67ccf8ff5bf 100644 (file)
@@ -27,6 +27,7 @@
 #include "BufferView.h"
 #include "CoordCache.h"
 #include "Cursor.h"
+#include "Dimension.h"
 
 #include "mathed/InsetMathUnknown.h"
 
@@ -37,7 +38,6 @@
 #include "support/docstream.h"
 #include "support/gettext.h"
 #include "support/lassert.h"
-#include "support/lyxalgo.h"
 
 #include <cstdlib>
 
@@ -47,8 +47,7 @@ namespace lyx {
 
 
 MathData::MathData(Buffer * buf, const_iterator from, const_iterator to)
-       : base_type(from, to), minasc_(0), mindes_(0), slevel_(0),
-         sshift_(0), buffer_(buf)
+       : base_type(from, to), buffer_(buf)
 {}
 
 
@@ -295,10 +294,12 @@ void MathData::metrics(MetricsInfo & mi, Dimension & dim, bool tight) const
 
        // This is one of the the few points where the drawing font is known,
        // so that we can set the caret vertical dimensions.
-       mrow.caret_ascent = min(dim.asc, fm.maxAscent());
-       mrow.caret_descent = min(dim.des, fm.maxDescent());
+       mrow.caret_dim.asc = min(dim.asc, fm.maxAscent());
+       mrow.caret_dim.des = min(dim.des, fm.maxDescent());
+       mrow.caret_dim.wid = fm.lineWidth();
+
        /// do the same for math cells linearized in the row
-       MathRow caret_row = MathRow(mrow.caret_ascent, mrow.caret_descent);
+       MathRow caret_row = MathRow(mrow.caret_dim);
        for (auto const & e : mrow)
                if (e.type == MathRow::BEGIN && e.ar)
                        bv->setMathRow(e.ar, caret_row);
@@ -322,7 +323,7 @@ void MathData::drawSelection(PainterInfo & pi, int const x, int const y) const
        MathData const & c1 = inset->cell(s1.idx());
 
        if (s1.idx() == s2.idx() && &c1 == this) {
-               // selection indide cell
+               // selection inside cell
                Dimension const dim = bv->coordCache().getArrays().dim(&c1);
                int const beg = c1.pos2x(bv, s1.pos());
                int const end = c1.pos2x(bv, s2.pos());
@@ -372,9 +373,9 @@ void MathData::drawT(TextPainter & pain, int x, int y) const
        // FIXME: Abdel 16/10/2006
        // This drawT() method is never used, this is dead code.
 
-       for (const_iterator it = begin(), et = end(); it != et; ++it) {
-               (*it)->drawT(pain, x, y);
-               //x += (*it)->width_;
+       for (auto const & it : *this) {
+               it->drawT(pain, x, y);
+               //x += it->width_;
                x += 2;
        }
 }
@@ -386,12 +387,12 @@ int MathData::kerning(BufferView const * bv) const
 }
 
 
-void MathData::updateBuffer(ParIterator const & it, UpdateType utype)
+void MathData::updateBuffer(ParIterator const & it, UpdateType utype, bool const deleted)
 {
        // pass down
        for (size_t i = 0, n = size(); i != n; ++i) {
                MathAtom & at = operator[](i);
-               at.nucleus()->updateBuffer(it, utype);
+               at.nucleus()->updateBuffer(it, utype, deleted);
        }
 }
 
@@ -966,6 +967,18 @@ MathClass MathData::mathClass() const
 }
 
 
+MathClass MathData::lastMathClass() const
+{
+       MathClass res = MC_ORD;
+       for (MathAtom const & at : *this) {
+               MathClass mc = at->mathClass();
+               if (mc != MC_UNKNOWN)
+                       res = mc;
+       }
+       return res;
+}
+
+
 ostream & operator<<(ostream & os, MathData const & ar)
 {
        odocstringstream oss;