mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 05:16:21 +00:00
Proper GUI feedback for leqno option
With these changes, equation numbers are shown properly on screen. When setting is default, we guess the side using these two rules * ams(art|book) and siamltex classes are leqno by default. This is signalled because the classes provide "leqno" (in amsdefs.inc). If there are other classes that do this in output, the relevant classes should be updated. * the language arabic_arabi also sets leqno by default. This is currently hardcoded for lack of a better idea. Besides, a few bugs are fixed: * use mathrm instead of mathbf for numbers metrics * set spacing between maths and labels in inches
This commit is contained in:
parent
d9464bfcd6
commit
f1dd80f464
@ -7,6 +7,9 @@
|
||||
# Including the maths stuff
|
||||
Format 63
|
||||
|
||||
# By default AMS articles & books use leqno option (as SIAM journals).
|
||||
Provides leqno 1
|
||||
|
||||
# the environments copied from the old amsart.layout are:
|
||||
# - Bibliography
|
||||
# - Title
|
||||
|
@ -667,6 +667,19 @@ void BufferParams::setDefSkip(VSpace const & vs)
|
||||
}
|
||||
|
||||
|
||||
BufferParams::MathNumber BufferParams::getMathNumber() const
|
||||
{
|
||||
if (math_number != DEFAULT)
|
||||
return math_number;
|
||||
// FIXME: do not hardcode language here
|
||||
else if (language->lang() == "arabic_arabi"
|
||||
|| documentClass().provides("leqno"))
|
||||
return LEFT;
|
||||
else
|
||||
return RIGHT;
|
||||
}
|
||||
|
||||
|
||||
string BufferParams::readToken(Lexer & lex, string const & token,
|
||||
FileName const & filepath)
|
||||
{
|
||||
|
@ -114,6 +114,10 @@ public:
|
||||
/// number formulas on left/right/default
|
||||
MathNumber math_number;
|
||||
|
||||
/// Convenience function for display: like math_number, but
|
||||
/// DEFAULT is replaced by the best guess we have.
|
||||
MathNumber getMathNumber() const;
|
||||
|
||||
/** Whether paragraphs are separated by using a indent like in
|
||||
* articles or by using a little skip like in letters.
|
||||
*/
|
||||
|
@ -558,13 +558,14 @@ void InsetMathHull::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
}
|
||||
|
||||
if (numberedType()) {
|
||||
Changer dummy = mi.base.changeFontSet("mathbf");
|
||||
Changer dummy = mi.base.changeFontSet("mathrm");
|
||||
int l = 0;
|
||||
for (row_type row = 0; row < nrows(); ++row)
|
||||
l = max(l, mathed_string_width(mi.base.font, nicelabel(row)));
|
||||
|
||||
if (l)
|
||||
dim.wid += 30 + l;
|
||||
// Value was hardcoded to 30 pixels
|
||||
dim.wid += Length(0.3, Length::IN).inPixels(mi.base) + l;
|
||||
}
|
||||
|
||||
// reserve some space for marker.
|
||||
@ -644,18 +645,36 @@ void InsetMathHull::draw(PainterInfo & pi, int x, int y) const
|
||||
Changer dummy2 = pi.base.font.changeStyle(display() ? LM_ST_DISPLAY
|
||||
: LM_ST_TEXT);
|
||||
|
||||
InsetMathGrid::draw(pi, x + 1, y);
|
||||
int xmath = x;
|
||||
BufferParams::MathNumber const math_number = buffer().params().getMathNumber();
|
||||
if (numberedType() && math_number == BufferParams::LEFT) {
|
||||
Changer dummy = pi.base.changeFontSet("mathrm");
|
||||
int l = 0;
|
||||
for (row_type row = 0; row < nrows(); ++row)
|
||||
l = max(l, mathed_string_width(pi.base.font, nicelabel(row)));
|
||||
|
||||
if (l)
|
||||
// Value was hardcoded to 30 pixels
|
||||
xmath += Length(0.3, Length::IN).inPixels(pi.base) + l;
|
||||
}
|
||||
|
||||
InsetMathGrid::draw(pi, xmath + 1, y);
|
||||
drawMarkers2(pi, x, y);
|
||||
|
||||
if (numberedType()) {
|
||||
int const xx = x + colinfo_.back().offset_ + colinfo_.back().width_ + 20;
|
||||
Changer dummy = pi.base.changeFontSet("mathrm");
|
||||
for (row_type row = 0; row < nrows(); ++row) {
|
||||
int const yy = y + rowinfo_[row].offset_;
|
||||
Changer dummy = pi.base.changeFontSet("mathrm");
|
||||
docstring const nl = nicelabel(row);
|
||||
pi.draw(xx, yy, nl);
|
||||
if (math_number == BufferParams::LEFT)
|
||||
pi.draw(x, yy, nl);
|
||||
else {
|
||||
int l = mathed_string_width(pi.base.font, nl);
|
||||
pi.draw(x + dim.wid - l, yy, nl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// drawing change line
|
||||
if (canPaintChange(*bv))
|
||||
pi.change_.paintCue(pi, x + 1, y + 1 - dim.asc,
|
||||
|
Loading…
Reference in New Issue
Block a user