]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/InsetMathRoot.cpp
de.po
[lyx.git] / src / mathed / InsetMathRoot.cpp
index 8650cb712d1c7a08a0685fc130f3b71b8048bbf8..e0b7efc90b222df3f32d8145162ab200dcbdc6e0 100644 (file)
@@ -22,6 +22,7 @@
 
 #include "frontends/Painter.h"
 
+#include "support/lassert.h"
 
 using namespace std;
 
@@ -47,19 +48,12 @@ void mathed_root_metrics(MetricsInfo & mi, MathData const & nucleus,
        Dimension dimr;
        if (root) {
                Changer script = mi.base.font.changeStyle(LM_ST_SCRIPTSCRIPT);
-               root->metrics(mi, dimr);
                // make sure that the dim is high enough for any character
-               Dimension fontDim;
-               math_font_max_dim(mi.base.font, fontDim.asc, fontDim.des);
-               dimr += fontDim;
+               root->metrics(mi, dimr, false);
        }
 
        Dimension dimn;
        nucleus.metrics(mi, dimn);
-       // make sure that the dim is high enough for any character
-       // Dimension fontDim;
-       // math_font_max_dim(mi.base.font, fontDim.asc, fontDim.des);
-       // dimn += fontDim;
 
        // Some room for the decoration
        // The width of left decoration was 9 pixels with a 10em font
@@ -91,7 +85,7 @@ void mathed_root_metrics(MetricsInfo & mi, MathData const & nucleus,
 
 void InsetMathRoot::metrics(MetricsInfo & mi, Dimension & dim) const
 {
-       mathed_root_metrics(mi, cell(1), &cell(0), dim);
+       mathed_root_metrics(mi, cell(0), &cell(1), dim);
 }
 
 
@@ -123,7 +117,7 @@ void mathed_draw_root(PainterInfo & pi, int x, int y, MathData const & nucleus,
        pi.pain.line(x + dim.width(), y - a + 2 * t,
                     x + wl, y - a + 2 * t, pi.base.font.color(),
                     Painter::line_solid, t);
-       xp[0] = x + wl;              yp[0] = y - a + 2 * t;
+       xp[0] = x + wl;              yp[0] = y - a + 2 * t + 1;
        xp[1] = x + wl - w / 2;      yp[1] = y + d;
        xp[2] = x + wl - w + h / 4;  yp[2] = y + d - h;
        xp[3] = x + wl - w;          yp[3] = y + d - h + h / 4;
@@ -134,26 +128,26 @@ void mathed_draw_root(PainterInfo & pi, int x, int y, MathData const & nucleus,
 
 void InsetMathRoot::draw(PainterInfo & pi, int x, int y) const
 {
-       mathed_draw_root(pi, x, y, cell(1), &cell(0), dimension(*pi.base.bv));
+       mathed_draw_root(pi, x, y, cell(0), &cell(1), dimension(*pi.base.bv));
 }
 
 
 void InsetMathRoot::write(WriteStream & os) const
 {
        MathEnsurer ensurer(os);
-       os << "\\sqrt[" << cell(0) << "]{" << cell(1) << '}';
+       os << "\\sqrt[" << cell(1) << "]{" << cell(0) << '}';
 }
 
 
 void InsetMathRoot::normalize(NormalStream & os) const
 {
-       os << "[root " << cell(0) << ' ' << cell(1) << ']';
+       os << "[root " << cell(1) << ' ' << cell(0) << ']';
 }
 
 
 bool InsetMathRoot::idxUpDown(Cursor & cur, bool up) const
 {
-       Cursor::idx_type const target = up ? 0 : 1;
+       Cursor::idx_type const target = up; //up ? 1 : 0;
        if (cur.idx() == target)
                return false;
        cur.idx() = target;
@@ -162,36 +156,78 @@ bool InsetMathRoot::idxUpDown(Cursor & cur, bool up) const
 }
 
 
+bool InsetMathRoot::idxForward(Cursor & cur) const
+{
+       // nucleus is 0 and is on the right
+       if (cur.idx() == 0)
+               return false;
+
+       cur.idx() = 0;
+       cur.pos() = 0;
+       return true;
+}
+
+
+bool InsetMathRoot::idxBackward(Cursor & cur) const
+{
+       // nucleus is 0 and is on the right
+       if (cur.idx() == 1)
+               return false;
+
+       cur.idx() = 1;
+       cur.pos() = cur.lastpos();
+       return true;
+}
+
+
+bool InsetMathRoot::idxFirst(Cursor & cur) const
+{
+       LASSERT(&cur.inset() == this, return false);
+       cur.idx() = 1;
+       cur.pos() = 0;
+       return true;
+}
+
+
+bool InsetMathRoot::idxLast(Cursor & cur) const
+{
+       LASSERT(&cur.inset() == this, return false);
+       cur.idx() = 0;
+       cur.pos() = cur.lastpos();
+       return true;
+}
+
+
 void InsetMathRoot::maple(MapleStream & os) const
 {
-       os << '(' << cell(1) << ")^(1/(" << cell(0) <<"))";
+       os << '(' << cell(0) << ")^(1/(" << cell(1) <<"))";
 }
 
 
 void InsetMathRoot::mathematica(MathematicaStream & os) const
 {
-       os << '(' << cell(1) << ")^(1/(" << cell(0) <<"))";
+       os << '(' << cell(0) << ")^(1/(" << cell(1) <<"))";
 }
 
 
 void InsetMathRoot::octave(OctaveStream & os) const
 {
-       os << '(' << cell(1) << ")^(1/(" << cell(0) <<"))";
+       os << '(' << cell(0) << ")^(1/(" << cell(1) <<"))";
 }
 
 
 void InsetMathRoot::mathmlize(MathStream & os) const
 {
-       os << MTag("mroot") << cell(1) << cell(0) << ETag("mroot");
+       os << MTag("mroot") << cell(0) << cell(1) << ETag("mroot");
 }
 
 
 void InsetMathRoot::htmlize(HtmlStream & os) const
 {
        os << MTag("span", "class='root'")
-          << MTag("sup") << cell(0) << ETag("sup")
+          << MTag("sup") << cell(1) << ETag("sup")
           << from_ascii("&radic;")
-          << MTag("span", "class='rootof'")    << cell(1) << ETag("span")
+          << MTag("span", "class='rootof'")    << cell(0) << ETag("span")
                 << ETag("span");
 }