mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-13 17:20:55 +00:00
Fix bug 2481 and read in of \over (related to bug 2481)
* src/mathed/math_fracinset.[Ch] (MathFracInset::extraBraces): new, return true for \atop * src/mathed/math_binominset.[Ch] (MathBinomInset::extraBraces): new, return true for \choose * 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/branches/BRANCH_1_4_X@14615 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
8a7f9ac00f
commit
8d7df59e74
@ -68,6 +68,12 @@ void MathBinomInset::draw(PainterInfo & pi, int x, int y) const
|
||||
}
|
||||
|
||||
|
||||
bool MathBinomInset::extraBraces() const
|
||||
{
|
||||
return choose_;
|
||||
}
|
||||
|
||||
|
||||
void MathBinomInset::write(WriteStream & os) const
|
||||
{
|
||||
if (choose_)
|
||||
|
@ -28,6 +28,8 @@ public:
|
||||
void metrics(MetricsInfo & mi, Dimension & dim) const;
|
||||
///
|
||||
void draw(PainterInfo &, int x, int y) const;
|
||||
///
|
||||
bool extraBraces() const;
|
||||
private:
|
||||
virtual std::auto_ptr<InsetBase> doClone() const;
|
||||
///
|
||||
|
@ -24,7 +24,7 @@ using std::auto_ptr;
|
||||
|
||||
|
||||
MathDfracInset::MathDfracInset()
|
||||
: MathFracInset(false)
|
||||
: MathFracInset()
|
||||
{}
|
||||
|
||||
|
||||
|
@ -315,12 +315,14 @@ 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 == "infer")
|
||||
// return MathAtom(new MathInferInset);
|
||||
if (s == "atop")
|
||||
return MathAtom(new MathFracInset(true));
|
||||
return MathAtom(new MathFracInset(MathFracInset::ATOP));
|
||||
if (s == "lefteqn")
|
||||
return MathAtom(new MathLefteqnInset);
|
||||
if (s == "boldsymbol")
|
||||
|
@ -24,8 +24,8 @@ using std::max;
|
||||
using std::auto_ptr;
|
||||
|
||||
|
||||
MathFracInset::MathFracInset(bool atop)
|
||||
: atop_(atop)
|
||||
MathFracInset::MathFracInset(Kind kind)
|
||||
: kind_(kind)
|
||||
{}
|
||||
|
||||
|
||||
@ -37,13 +37,13 @@ auto_ptr<InsetBase> MathFracInset::doClone() const
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@ -67,7 +67,7 @@ void MathFracInset::draw(PainterInfo & pi, int x, int y) const
|
||||
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_)
|
||||
if (kind_ == FRAC || kind_ == OVER)
|
||||
pi.pain.line(x + 1, y - 5, x + dim_.wid - 2, y - 5, LColor::math);
|
||||
drawMarkers(pi, x, y);
|
||||
}
|
||||
@ -89,23 +89,46 @@ void MathFracInset::drawT(TextPainter & pain, int x, int y) const
|
||||
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_ == FRAC || kind_ == OVER)
|
||||
pain.horizontalLine(x, y, dim_.width());
|
||||
}
|
||||
|
||||
|
||||
void MathFracInset::write(WriteStream & os) const
|
||||
{
|
||||
if (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:
|
||||
MathNestInset::write(os);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
string MathFracInset::name() const
|
||||
{
|
||||
return atop_ ? "atop" : "frac";
|
||||
switch (kind_) {
|
||||
case FRAC:
|
||||
return "frac";
|
||||
case OVER:
|
||||
return "over";
|
||||
case ATOP:
|
||||
return "atop";
|
||||
}
|
||||
// shut up stupid compiler
|
||||
return string();
|
||||
}
|
||||
|
||||
|
||||
bool MathFracInset::extraBraces() const
|
||||
{
|
||||
return kind_ == ATOP || kind_ == OVER;
|
||||
}
|
||||
|
||||
|
||||
|
@ -20,7 +20,14 @@
|
||||
class MathFracInset : public MathFracbaseInset {
|
||||
public:
|
||||
///
|
||||
explicit MathFracInset(bool atop = false);
|
||||
enum Kind {
|
||||
FRAC,
|
||||
OVER,
|
||||
ATOP,
|
||||
};
|
||||
|
||||
///
|
||||
explicit MathFracInset(Kind kind = FRAC);
|
||||
///
|
||||
void metrics(MetricsInfo & mi, Dimension & dim) const;
|
||||
///
|
||||
@ -35,6 +42,8 @@ public:
|
||||
MathFracInset const * asFracInset() const;
|
||||
///
|
||||
std::string name() const;
|
||||
///
|
||||
bool extraBraces() const;
|
||||
|
||||
///
|
||||
void write(WriteStream & os) const;
|
||||
@ -49,7 +58,7 @@ public:
|
||||
public:
|
||||
virtual std::auto_ptr<InsetBase> doClone() const;
|
||||
///
|
||||
bool const atop_;
|
||||
Kind const kind_;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -27,7 +27,7 @@ using std::auto_ptr;
|
||||
|
||||
|
||||
MathTfracInset::MathTfracInset()
|
||||
: MathFracInset(false)
|
||||
: MathFracInset()
|
||||
{}
|
||||
|
||||
|
||||
|
@ -45,6 +45,9 @@ What's new
|
||||
- Make sure enough passes are made to update the table of contents
|
||||
when running latex (bug 2616).
|
||||
|
||||
- Don't add extra braces when reading documents containing \choose, \atop or
|
||||
\over (bug 2481).
|
||||
|
||||
* User Interface:
|
||||
|
||||
- Show an error box when failing to update the TeX Information dalog data.
|
||||
|
Loading…
Reference in New Issue
Block a user