]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/MathData.cpp
Move <algorithm> from DocIterator.h
[lyx.git] / src / mathed / MathData.cpp
index 42aa3cbb9b15b6b4c6940cd9e6f175c1b6833538..39d5f80184303c7f02f5813c7d90296af1d66f8d 100644 (file)
@@ -295,10 +295,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);
@@ -372,9 +374,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;
        }
 }
@@ -966,6 +968,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;