]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_rootinset.C
Fix to bug 2362: Deleting superscript also deletes subscript.
[lyx.git] / src / mathed / math_rootinset.C
index 3b41365508e13c2af4700e77016750500e37f1aa..8822ae1bf533b2622bd86c1557bb17f335bd2148 100644 (file)
 #include <config.h>
 
 #include "math_rootinset.h"
+#include "math_data.h"
 #include "math_mathmlstream.h"
-#include "frontends/Painter.h"
+#include "cursor.h"
+#include "LColor.h"
 
+#include "frontends/Painter.h"
 
 using std::max;
 using std::auto_ptr;
 
 
+
 MathRootInset::MathRootInset()
        : MathNestInset(2)
 {}
 
 
-auto_ptr<InsetBase> MathRootInset::clone() const
+auto_ptr<InsetBase> MathRootInset::doClone() const
 {
        return auto_ptr<InsetBase>(new MathRootInset(*this));
 }
@@ -34,11 +38,11 @@ auto_ptr<InsetBase> MathRootInset::clone() const
 void MathRootInset::metrics(MetricsInfo & mi, Dimension & dim) const
 {
        MathNestInset::metrics(mi);
-       dim_.asc = max(cell(0).ascent()  + 5, cell(1).ascent())  + 2;
-       dim_.des = max(cell(1).descent() + 5, cell(0).descent()) + 2;
-       dim_.wid = cell(0).width() + cell(1).width() + 10;
-       metricsMarkers(1);
-       dim = dim_;
+       dim.asc = max(cell(0).ascent()  + 5, cell(1).ascent())  + 2;
+       dim.des = max(cell(1).descent() + 5, cell(0).descent()) + 2;
+       dim.wid = cell(0).width() + cell(1).width() + 10;
+       metricsMarkers(dim);
+       dim_ = dim;
 }
 
 
@@ -76,13 +80,13 @@ void MathRootInset::normalize(NormalStream & os) const
 }
 
 
-bool MathRootInset::idxUpDown(idx_type & idx, pos_type & pos, bool up, int) const
+bool MathRootInset::idxUpDown(LCursor & cur, bool up) const
 {
-       bool target = !up; // up ? 0 : 1;
-       if (idx == target)
+       LCursor::idx_type const target = up ? 0 : 1;
+       if (cur.idx() == target)
                return false;
-       idx = target;
-       pos = target ? 0 : cell(0).size();
+       cur.idx() = target;
+       cur.pos() = up ? cur.lastpos() : 0;
        return true;
 }