]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_fracinset.C
small up/down tweaking
[lyx.git] / src / mathed / math_fracinset.C
index 5c5e06ce98190a82405d6ceef5041c06b2c6d4d5..1ad3d222250769de745471eaebeca47af407cbb7 100644 (file)
@@ -29,14 +29,20 @@ MathFracInset * MathFracInset::asFracInset()
 }
 
 
+MathFracInset const * MathFracInset::asFracInset() const
+{
+       return atop_ ? 0 : this;
+}
+
+
 void MathFracInset::metrics(MathMetricsInfo & mi) const
 {
        MathFracChanger dummy(mi.base);
-       xcell(0).metrics(mi);
-       xcell(1).metrics(mi);
-       width_   = max(xcell(0).width(), xcell(1).width()) + 2;
-       ascent_  = xcell(0).height() + 2 + 5;
-       descent_ = xcell(1).height() + 2 - 5;
+       cell(0).metrics(mi);
+       cell(1).metrics(mi);
+       dim_.w = max(cell(0).width(), cell(1).width()) + 2;
+       dim_.a = cell(0).height() + 2 + 5;
+       dim_.d = cell(1).height() + 2 - 5;
 }
 
 
@@ -44,8 +50,8 @@ void MathFracInset::draw(MathPainterInfo & pi, int x, int y) const
 {
        int m = x + width() / 2;
        MathFracChanger dummy(pi.base);
-       xcell(0).draw(pi, m - xcell(0).width() / 2, y - xcell(0).descent() - 2 - 5);
-       xcell(1).draw(pi, m - xcell(1).width() / 2, y + xcell(1).ascent()  + 2 - 5);
+       cell(0).draw(pi, m - cell(0).width() / 2, y - cell(0).descent() - 2 - 5);
+       cell(1).draw(pi, m - cell(1).width() / 2, y + cell(1).ascent()  + 2 - 5);
        if (!atop_)
                pi.pain.line(x + 1, y - 5, x + width() - 2, y - 5, LColor::math);
 }
@@ -53,19 +59,19 @@ void MathFracInset::draw(MathPainterInfo & pi, int x, int y) const
 
 void MathFracInset::metricsT(TextMetricsInfo const & mi) const
 {
-       xcell(0).metricsT(mi);
-       xcell(1).metricsT(mi);
-       width_   = max(xcell(0).width(), xcell(1).width());
-       ascent_  = xcell(0).height() + 1;
-       descent_ = xcell(1).height();
+       cell(0).metricsT(mi);
+       cell(1).metricsT(mi);
+       dim_.w = max(cell(0).width(), cell(1).width());
+       dim_.a = cell(0).height() + 1;
+       dim_.d = cell(1).height();
 }
 
 
 void MathFracInset::drawT(TextPainter & pain, int x, int y) const
 {
        int m = x + width() / 2;
-       xcell(0).drawT(pain, m - xcell(0).width() / 2, y - xcell(0).descent() - 1);
-       xcell(1).drawT(pain, m - xcell(1).width() / 2, y + xcell(1).ascent());
+       cell(0).drawT(pain, m - cell(0).width() / 2, y - cell(0).descent() - 1);
+       cell(1).drawT(pain, m - cell(1).width() / 2, y + cell(1).ascent());
        if (!atop_)
                pain.horizontalLine(x, y, width());
 }
@@ -75,30 +81,29 @@ void MathFracInset::write(WriteStream & os) const
 {
        if (atop_)
                os << '{' << cell(0) << "\\atop " << cell(1) << '}';
-       else
-               os << "\\frac{" << cell(0) << "}{" << cell(1) << '}';
+       else // it's \\frac
+               MathNestInset::write(os);
 }
 
 
-void MathFracInset::normalize(NormalStream & os) const
+string MathFracInset::name() const
 {
-       if (atop_)
-               os << "[atop ";
-       else
-               os << "[frac ";
-       os << cell(0) << ' ' << cell(1) << ']';
+       return atop_ ? "atop" : "frac";
 }
 
+
 void MathFracInset::maplize(MapleStream & os) const
 {
        os << '(' << cell(0) << ")/(" << cell(1) << ')';
 }
 
+
 void MathFracInset::mathematicize(MathematicaStream & os) const
 {
        os << '(' << cell(0) << ")/(" << cell(1) << ')';
 }
 
+
 void MathFracInset::octavize(OctaveStream & os) const
 {
        os << '(' << cell(0) << ")/(" << cell(1) << ')';