From: Georg Baum Date: Wed, 19 Jul 2006 10:50:18 +0000 (+0000) Subject: Fix read in of \over (related to bug 2481) X-Git-Tag: 1.6.10~12923 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=117c98c41602b0416cdff10a5c5f5f724117ad8a;p=features.git Fix read in of \over (related to bug 2481) * src/mathed/math_factory.C (createMathInset): Create a MathFracInset of kind OVER for \over * src/mathed/math_fracinset.C (MathFracInset::draw): handle kind OVER (MathFracInset::drawT): ditto (MathFracInset::write): ditto (MathFracInset::name): ditto (MathFracInset::extraBraces): ditto * src/mathed/math_fracinset.h (Kind): New kind OVER git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@14487 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/mathed/math_factory.C b/src/mathed/math_factory.C index d55fc094db..97da7b6b15 100644 --- a/src/mathed/math_factory.C +++ b/src/mathed/math_factory.C @@ -320,8 +320,10 @@ MathAtom createMathInset(string const & s) return MathAtom(new MathStackrelInset); if (s == "binom" || s == "choose") return MathAtom(new MathBinomInset(s == "choose")); - if (s == "over" || s == "frac") + if (s == "frac") return MathAtom(new MathFracInset); + if (s == "over") + return MathAtom(new MathFracInset(MathFracInset::OVER)); if (s == "nicefrac") return MathAtom(new MathFracInset(MathFracInset::NICEFRAC)); //if (s == "infer") diff --git a/src/mathed/math_fracinset.C b/src/mathed/math_fracinset.C index 2ba15ab462..34e979af52 100644 --- a/src/mathed/math_fracinset.C +++ b/src/mathed/math_fracinset.C @@ -77,18 +77,17 @@ void MathFracInset::draw(PainterInfo & pi, int x, int y) const y - cell(0).descent() - 5); cell(1).draw(pi, x + cell(0).width() + 5, y + cell(1).ascent() / 2); + pi.pain.line(x + cell(0).width(), + y + dim_.des - 2, + x + cell(0).width() + 5, + y - dim_.asc + 2, LColor::math); } 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 + cell(0).width(), - y + dim_.des - 2, - x + cell(0).width() + 5, - y - dim_.asc + 2, LColor::math); - if (kind_ == FRAC) + if (kind_ == FRAC || kind_ == OVER) pi.pain.line(x + 1, y - 5, x + dim_.wid - 2, y - 5, LColor::math); drawMarkers(pi, x, y); @@ -112,17 +111,26 @@ void MathFracInset::drawT(TextPainter & pain, int x, int y) const 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()); // ASCII art: ignore niceties - if (kind_ == FRAC || kind_ == NICEFRAC) + if (kind_ == FRAC || kind_ == OVER || kind_ == NICEFRAC) pain.horizontalLine(x, y, dim_.width()); } void MathFracInset::write(WriteStream & os) const { - if (kind_ == ATOP) + switch (kind_) { + case ATOP: os << '{' << cell(0) << "\\atop " << cell(1) << '}'; - else // it's \\frac + break; + case OVER: + // \\over is only for compatibility, normalize this to \\frac + os << "\\frac{" << cell(0) << "}{" << cell(1) << '}'; + break; + case FRAC: + case NICEFRAC: MathNestInset::write(os); + break; + } } @@ -131,19 +139,19 @@ string MathFracInset::name() const switch (kind_) { case FRAC: return "frac"; + case OVER: + return "over"; case NICEFRAC: return "nicefrac"; case ATOP: return "atop"; - default: - return string(); } } bool MathFracInset::extraBraces() const { - return kind_ == ATOP; + return kind_ == ATOP || kind_ == OVER; } diff --git a/src/mathed/math_fracinset.h b/src/mathed/math_fracinset.h index 1abb102f8f..53abf28184 100644 --- a/src/mathed/math_fracinset.h +++ b/src/mathed/math_fracinset.h @@ -22,6 +22,7 @@ public: /// enum Kind { FRAC, + OVER, ATOP, NICEFRAC };