]> git.lyx.org Git - features.git/commitdiff
support for \cfrac in mathed, fixes bug 2473 and can also go to LyX 1.6.3
authorUwe Stöhr <uwestoehr@web.de>
Sat, 28 Feb 2009 02:43:26 +0000 (02:43 +0000)
committerUwe Stöhr <uwestoehr@web.de>
Sat, 28 Feb 2009 02:43:26 +0000 (02:43 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@28639 a592a061-630c-0410-9148-cb99ea01b6c8

src/mathed/InsetMathFrac.cpp
src/mathed/InsetMathFrac.h
src/mathed/InsetMathNest.cpp
src/mathed/MathFactory.cpp

index 05414da79b444676001358a264bb08a4696b7c09..558bbcddf6304e5416598edba9ed7bb3b6aca65a 100644 (file)
@@ -5,6 +5,7 @@
  *
  * \author Alejandro Aguilar Sierra
  * \author André Pönitz
+ * \author Uwe Stöhr
  *
  * Full author contact details are available in file CREDITS.
  */
@@ -466,6 +467,62 @@ void InsetMathTFrac::validate(LaTeXFeatures & features) const
 }
 
 
+/////////////////////////////////////////////////////////////////////
+//
+// InsetMathCFrac
+//
+/////////////////////////////////////////////////////////////////////
+
+
+Inset * InsetMathCFrac::clone() const
+{
+       return new InsetMathCFrac(*this);
+}
+
+
+void InsetMathCFrac::metrics(MetricsInfo & mi, Dimension & dim) const
+{
+       Dimension dim0, dim1;
+       cell(0).metrics(mi, dim0);
+       cell(1).metrics(mi, dim1);
+       dim.wid = max(dim0.wid, dim1.wid) + 2;
+       dim.asc = dim0.height() + 2 + 5;
+       dim.des = dim1.height() + 2 - 5;
+}
+
+
+void InsetMathCFrac::draw(PainterInfo & pi, int x, int y) const
+{
+       Dimension const dim = dimension(*pi.base.bv);
+       Dimension const & dim0 = cell(0).dimension(*pi.base.bv);
+       Dimension const & dim1 = cell(1).dimension(*pi.base.bv);
+       int m = x + dim.wid / 2;
+       cell(0).draw(pi, m - dim0.wid / 2, y - dim0.des - 2 - 5);
+       cell(1).draw(pi, m - dim1.wid / 2, y + dim1.asc  + 2 - 5);
+       pi.pain.line(x + 1, y - 5, x + dim.wid - 2, y - 5, Color_math);
+       setPosCache(pi, x, y);
+}
+
+
+docstring InsetMathCFrac::name() const
+{
+       return from_ascii("cfrac");
+}
+
+
+void InsetMathCFrac::mathmlize(MathStream & os) const
+{
+       os << MTag("mcfrac") << cell(0) << cell(1) << ETag("mcfrac");
+}
+
+
+void InsetMathCFrac::validate(LaTeXFeatures & features) const
+{
+       features.require("amsmath");
+       InsetMathNest::validate(features);
+}
+
+
 /////////////////////////////////////////////////////////////////////
 //
 // InsetMathBinom
index f782b74393e7572fb6f29d5d60d7a996374c7443..49d131d25a596948e270fbd35df3118f0f761931 100644 (file)
@@ -128,6 +128,26 @@ private:
 };
 
 
+/// \cfrac support
+class InsetMathCFrac : public InsetMathFrac {
+public:
+       ///
+       InsetMathCFrac() {}
+       ///
+       void metrics(MetricsInfo & mi, Dimension & dim) const;
+       ///
+       void draw(PainterInfo &, int x, int y) const;
+       ///
+       docstring name() const;
+       ///
+       void mathmlize(MathStream &) const;
+       ///
+       void validate(LaTeXFeatures & features) const;
+private:
+       Inset * clone() const;
+};
+
+
 /// Binom like objects
 class InsetMathBinom : public InsetMathFracBase {
 public:
index 2ee7c81abaebfe0e5ad3d0d1f90a790bcc8bbde3..4f3656a7364e4b6dee7c582fe3cf3f6ec8187d01 100644 (file)
@@ -1928,6 +1928,7 @@ MathCompletionList::MathCompletionList(Cursor const & cur)
        globals.push_back(from_ascii("\\color"));
        globals.push_back(from_ascii("\\normalcolor"));
        globals.push_back(from_ascii("\\textcolor"));
+       globals.push_back(from_ascii("\\cfrac"));
        globals.push_back(from_ascii("\\dfrac"));
        globals.push_back(from_ascii("\\tfrac"));
        globals.push_back(from_ascii("\\dbinom"));
index 943c7e8ff6b90d0d5354e0c0e5790fd682bccb2f..16b6a2e28d7ca4fd7a37c12accae2ea816b93170 100644 (file)
@@ -447,6 +447,8 @@ MathAtom createInsetMath(docstring const & s)
                return MathAtom(new InsetMathColor(true));
        if (s == "textcolor")
                return MathAtom(new InsetMathColor(false));
+       if (s == "cfrac")
+               return MathAtom(new InsetMathCFrac);
        if (s == "dfrac")
                return MathAtom(new InsetMathDFrac);
        if (s == "tfrac")