]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/InsetMathFrac.cpp
Implement \case for AASTeX.
[lyx.git] / src / mathed / InsetMathFrac.cpp
index 3719904b925ca4df355c7705ed2845479e4d3c54..2ad44fc6ef392883ba69952108dcd9cd56949664 100644 (file)
@@ -140,6 +140,7 @@ MathClass InsetMathFrac::mathClass() const
        case CFRAC:
        case CFRACLEFT:
        case CFRACRIGHT:
+       case AASTEX_CASE:
                mc = MC_INNER;
                break;
        case NICEFRAC:
@@ -239,7 +240,8 @@ void InsetMathFrac::metrics(MetricsInfo & mi, Dimension & dim) const
        case DFRAC:
        case TFRAC:
        case OVER:
-       case ATOP: {
+       case ATOP:
+       case AASTEX_CASE: {
                int const dy = axis_height(mi.base);
                Changer dummy =
                        // \tfrac is always in text size
@@ -248,7 +250,8 @@ void InsetMathFrac::metrics(MetricsInfo & mi, Dimension & dim) const
                        (kind_ == CFRAC
                         || kind_ == CFRACLEFT
                         || kind_ == CFRACRIGHT
-                        || kind_ == DFRAC) ? mi.base.font.changeStyle(DISPLAY_STYLE) :
+                        || kind_ == DFRAC
+                        || kind_ == AASTEX_CASE) ? mi.base.font.changeStyle(DISPLAY_STYLE) :
                        // all others
                                              mi.base.changeFrac();
                Changer dummy2 = mi.base.changeEnsureMath();
@@ -321,7 +324,8 @@ void InsetMathFrac::draw(PainterInfo & pi, int x, int y) const
        case DFRAC:
        case TFRAC:
        case OVER:
-       case ATOP: {
+       case ATOP:
+       case AASTEX_CASE: {
                int const dy = axis_height(pi.base);
                Changer dummy =
                        // \tfrac is always in text size
@@ -330,7 +334,8 @@ void InsetMathFrac::draw(PainterInfo & pi, int x, int y) const
                        (kind_ == CFRAC
                         || kind_ == CFRACLEFT
                         || kind_ == CFRACRIGHT
-                        || kind_ == DFRAC) ? pi.base.font.changeStyle(DISPLAY_STYLE) :
+                        || kind_ == DFRAC
+                        || kind_ == AASTEX_CASE) ? pi.base.font.changeStyle(DISPLAY_STYLE) :
                        // all others
                                              pi.base.changeFrac();
                Dimension const dim1 = cell(1).dimension(*pi.base.bv);
@@ -422,6 +427,9 @@ void InsetMathFrac::write(TeXMathStream & os) const
        case CFRACRIGHT:
                os << "\\cfrac[r]{" << cell(0) << "}{" << cell(1) << '}';
                break;
+       case AASTEX_CASE:
+               os << "\\case{" << cell(0) << "}{" << cell(1) << '}';
+               break;
        }
 }
 
@@ -449,9 +457,11 @@ docstring InsetMathFrac::name() const
                return from_ascii("unit");
        case ATOP:
                return from_ascii("atop");
+       case AASTEX_CASE:
+               return from_ascii("case");
+       default:
+               return docstring();
        }
-       // shut up stupid compiler
-       return docstring();
 }
 
 
@@ -509,6 +519,7 @@ void InsetMathFrac::mathmlize(MathMLStream & ms) const
        case CFRAC:
        case CFRACLEFT:
        case CFRACRIGHT:
+       case AASTEX_CASE:
                ms << MTag("mfrac")
                   << MTag("mrow") << cell(0) << ETag("mrow")
                   << MTag("mrow") << cell(1) << ETag("mrow")
@@ -565,6 +576,7 @@ void InsetMathFrac::htmlize(HtmlStream & os) const
        case CFRAC:
        case CFRACLEFT:
        case CFRACRIGHT:
+       case AASTEX_CASE:
                os << MTag("span", "class='frac'")
                         << MTag("span", "class='numer'") << cell(0) << ETag("span")
                         << MTag("span", "class='denom'") << cell(1) << ETag("span")
@@ -604,12 +616,16 @@ void InsetMathFrac::validate(LaTeXFeatures & features) const
        if (kind_ == CFRAC || kind_ == CFRACLEFT || kind_ == CFRACRIGHT
                  || kind_ == DFRAC || kind_ == TFRAC)
                features.require("amsmath");
+       if (kind_ == AASTEX_CASE)
+               features.require("aastex_case");
+
        if (features.runparams().math_flavor == OutputParams::MathAsHTML)
                // CSS adapted from eLyXer
                features.addCSSSnippet(
                        "span.frac{display: inline-block; vertical-align: middle; text-align:center;}\n"
                        "span.numer{display: block;}\n"
                        "span.denom{display: block; border-top: thin solid #000040;}");
+
        InsetMathNest::validate(features);
 }