See patch. No GUI support for now.

- Martin

Index: math_factory.C
===================================================================
--- math_factory.C      (revision 13546)
+++ math_factory.C      (working copy)
@@ -317,10 +317,12 @@ MathAtom createMathInset(string const & 
                return MathAtom(new MathBinomInset(s == "choose"));
        if (s == "over" || s == "frac")
                return MathAtom(new MathFracInset);
+       if (s == "nicefrac")
+               return MathAtom(new MathFracInset("nicefrac"));
        //if (s == "infer")
        //      return MathAtom(new MathInferInset);
        if (s == "atop")
-               return MathAtom(new MathFracInset(true));
+               return MathAtom(new MathFracInset("atop"));
        if (s == "lefteqn")
                return MathAtom(new MathLefteqnInset);
        if (s == "boldsymbol")
Index: math_fracinset.C
===================================================================
--- math_fracinset.C    (revision 13546)
+++ math_fracinset.C    (working copy)
@@ -24,8 +24,8 @@ using std::max;
 using std::auto_ptr;
 
 
-MathFracInset::MathFracInset(bool atop)
-       : atop_(atop)
+MathFracInset::MathFracInset(string kind)
+       : kind_(kind)
 {}
 
 
@@ -37,13 +37,13 @@ auto_ptr<InsetBase> MathFracInset::doClo
 
 MathFracInset * MathFracInset::asFracInset()
 {
-       return atop_ ? 0 : this;
+       return kind_ == "atop" ? 0 : this;
 }
 
 
 MathFracInset const * MathFracInset::asFracInset() const
 {
-       return atop_ ? 0 : this;
+       return kind_ == "atop" ? 0 : this;
 }
 
 
@@ -52,9 +52,15 @@ void MathFracInset::metrics(MetricsInfo 
        FracChanger dummy(mi.base);
        cell(0).metrics(mi);
        cell(1).metrics(mi);
-       dim.wid = max(cell(0).width(), cell(1).width()) + 2;
-       dim.asc = cell(0).height() + 2 + 5;
-       dim.des = cell(1).height() + 2 - 5;
+       if (kind_ == "nicefrac") {
+               dim.wid =  2 * max(cell(0).width(), cell(1).width());
+               dim.asc = cell(0).height() + 5;
+               dim.des = cell(1).height() - 5;
+       } else {
+               dim.wid = max(cell(0).width(), cell(1).width()) + 2;
+               dim.asc = cell(0).height() + 2 + 5;
+               dim.des = cell(1).height() + 2 - 5;
+       }
        metricsMarkers(dim);
        dim_ = dim;
 }
@@ -65,10 +71,24 @@ void MathFracInset::draw(PainterInfo & p
        setPosCache(pi, x, y);
        int m = x + dim_.wid / 2;
        FracChanger dummy(pi.base);
-       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 + dim_.wid - 2, y - 5, 
LColor::math);
+       if (kind_ == "nicefrac") {
+               cell(0).draw(pi, x + 2, 
+                               y - cell(0).descent() - 5);
+               cell(1).draw(pi, x + dim_.wid - cell(1).width() - 2,
+                               y + cell(1).ascent() - 5);
+       } else {
+               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 (kind_ == "nicefrac")
+               pi.pain.line(x + 2, y + cell(1).height() - 2 - 5, 
+                               x + dim_.wid - 2, 
+                               y - cell(0).height() + 2 - 5, LColor::math);
+       if (kind_ == "frac")
+               pi.pain.line(x + 1, y - 5, 
+                               x + dim_.wid - 2, y - 5, LColor::math);
        drawMarkers(pi, x, y);
 }
 
@@ -89,14 +109,14 @@ void MathFracInset::drawT(TextPainter & 
        int m = x + dim_.width() / 2;
        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_)
+       if (kind_ != "atop")
                pain.horizontalLine(x, y, dim_.width());
 }
 
 
 void MathFracInset::write(WriteStream & os) const
 {
-       if (atop_)
+       if (kind_ == "atop")
                os << '{' << cell(0) << "\\atop " << cell(1) << '}';
        else // it's \\frac
                MathNestInset::write(os);
@@ -105,7 +125,7 @@ void MathFracInset::write(WriteStream & 
 
 string MathFracInset::name() const
 {
-       return atop_ ? "atop" : "frac";
+       return kind_;
 }
 
 
Index: math_dfracinset.C
===================================================================
--- math_dfracinset.C   (revision 13546)
+++ math_dfracinset.C   (working copy)
@@ -24,7 +24,7 @@ using std::auto_ptr;
 
 
 MathDfracInset::MathDfracInset()
-       : MathFracInset(false)
+       : MathFracInset()
 {}
 
 
Index: math_tfracinset.C
===================================================================
--- math_tfracinset.C   (revision 13546)
+++ math_tfracinset.C   (working copy)
@@ -27,7 +27,7 @@ using std::auto_ptr;
 
 
 MathTfracInset::MathTfracInset()
-       : MathFracInset(false)
+       : MathFracInset()
 {}
 
 
Index: math_fracinset.h
===================================================================
--- math_fracinset.h    (revision 13546)
+++ math_fracinset.h    (working copy)
@@ -20,7 +20,7 @@
 class MathFracInset : public MathFracbaseInset {
 public:
        ///
-       explicit MathFracInset(bool atop = false);
+       explicit MathFracInset(std::string kind = "frac");
        ///
        void metrics(MetricsInfo & mi, Dimension & dim) const;
        ///
@@ -49,7 +49,7 @@ public:
 public:
        virtual std::auto_ptr<InsetBase> doClone() const;
        ///
-       bool const atop_;
+       std::string const kind_;
 };
 
 #endif

Attachment: pgpSUJ6OxLZP6.pgp
Description: PGP signature

Reply via email to