mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-24 13:48:59 +00:00
Partial support for units
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20236 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
cc9fb465a6
commit
967c30e354
@ -273,7 +273,8 @@ ToolbarSet
|
||||
Toolbar "frac-square" "Fractions"
|
||||
Item "Standard \\frac" "math-insert \frac"
|
||||
Item "No hor. line \\atop" "math-insert \atop"
|
||||
Item "Nice \\nicefrac" "math-insert \nicefrac"
|
||||
Item "Nice (3/4) \\nicefrac" "math-insert \nicefrac"
|
||||
Item "Units (km/h) \\unitfrac" "math-insert \unitfrac"
|
||||
Item "Text frac (amsmath) \\tfrac" "math-insert \tfrac"
|
||||
Item "Display frac (amsmath) \\dfrac" "math-insert \dfrac"
|
||||
Item "Binomial \\choose" "math-insert \choose"
|
||||
|
@ -403,7 +403,7 @@ char const * simplefeatures[] = {
|
||||
"dvipost",
|
||||
"fancybox",
|
||||
"calc",
|
||||
"nicefrac",
|
||||
"units",
|
||||
"tipa",
|
||||
"framed",
|
||||
"pdfcolmk",
|
||||
|
@ -54,6 +54,11 @@ bool InsetMathFrac::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
dim.wid = cell(0).width() + cell(1).width() + 5;
|
||||
dim.asc = cell(0).height() + 5;
|
||||
dim.des = cell(1).height() - 5;
|
||||
} else if (kind_ == UNITFRAC) {
|
||||
ShapeChanger dummy2(mi.base.font, Font::UP_SHAPE);
|
||||
dim.wid = cell(0).width() + cell(1).width() + 5;
|
||||
dim.asc = cell(0).height() + 5;
|
||||
dim.des = cell(1).height() - 5;
|
||||
} else {
|
||||
dim.wid = std::max(cell(0).width(), cell(1).width()) + 2;
|
||||
dim.asc = cell(0).height() + 2 + 5;
|
||||
@ -77,16 +82,24 @@ void InsetMathFrac::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, Color::math);
|
||||
} else if (kind_ == UNITFRAC) {
|
||||
ShapeChanger dummy2(pi.base.font, Font::UP_SHAPE);
|
||||
cell(0).draw(pi, x + 2,
|
||||
y - cell(0).descent() - 5);
|
||||
cell(1).draw(pi, x + cell(0).width() + 5,
|
||||
y + cell(1).ascent() / 2);
|
||||
} 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 || kind_ == UNITFRAC) {
|
||||
pi.pain.line(x + cell(0).width(),
|
||||
y + dim_.des - 2,
|
||||
x + cell(0).width() + 5,
|
||||
y - dim_.asc + 2, Color::math);
|
||||
}
|
||||
if (kind_ == FRAC || kind_ == OVER)
|
||||
pi.pain.line(x + 1, y - 5,
|
||||
x + dim_.wid - 2, y - 5, Color::math);
|
||||
@ -111,7 +124,7 @@ void InsetMathFrac::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_ == OVER || kind_ == NICEFRAC)
|
||||
if (kind_ == FRAC || kind_ == OVER || kind_ == NICEFRAC || kind_ == UNITFRAC)
|
||||
pain.horizontalLine(x, y, dim_.width());
|
||||
}
|
||||
|
||||
@ -128,6 +141,7 @@ void InsetMathFrac::write(WriteStream & os) const
|
||||
break;
|
||||
case FRAC:
|
||||
case NICEFRAC:
|
||||
case UNITFRAC:
|
||||
InsetMathNest::write(os);
|
||||
break;
|
||||
}
|
||||
@ -143,6 +157,8 @@ docstring InsetMathFrac::name() const
|
||||
return from_ascii("over");
|
||||
case NICEFRAC:
|
||||
return from_ascii("nicefrac");
|
||||
case UNITFRAC:
|
||||
return from_ascii("unitfrac");
|
||||
case ATOP:
|
||||
return from_ascii("atop");
|
||||
}
|
||||
@ -183,8 +199,8 @@ void InsetMathFrac::mathmlize(MathStream & os) const
|
||||
|
||||
void InsetMathFrac::validate(LaTeXFeatures & features) const
|
||||
{
|
||||
if (kind_ == NICEFRAC)
|
||||
features.require("nicefrac");
|
||||
if (kind_ == NICEFRAC || kind_ == UNITFRAC)
|
||||
features.require("units");
|
||||
InsetMathNest::validate(features);
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,8 @@ public:
|
||||
FRAC,
|
||||
OVER,
|
||||
ATOP,
|
||||
NICEFRAC
|
||||
NICEFRAC,
|
||||
UNITFRAC
|
||||
};
|
||||
|
||||
///
|
||||
|
@ -370,6 +370,8 @@ MathAtom createInsetMath(docstring const & s)
|
||||
return MathAtom(new InsetMathFrac(InsetMathFrac::OVER));
|
||||
if (s == "nicefrac")
|
||||
return MathAtom(new InsetMathFrac(InsetMathFrac::NICEFRAC));
|
||||
if (s == "unitfrac")
|
||||
return MathAtom(new InsetMathFrac(InsetMathFrac::UNITFRAC));
|
||||
//if (s == "infer")
|
||||
// return MathAtom(new MathInferInset);
|
||||
if (s == "atop")
|
||||
|
Loading…
Reference in New Issue
Block a user