mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-23 18:24:48 +00:00
89662a6852
The goal of this patch is to be able to properly remove the space
needed for markers in the case of insets that are inside macros and do
not need these markers. This was attempted at 9a9a6a8
, but did not
work reliably.
To this end, the following simplifications are made:
* instead of drawing its own markers, each inset has a virtual method
marker() which prescribes either NO_MARKER, MARKER (normal bottom
marker) or MARKER2 (top and bottom marker). All explicit calls to
(draw|metrics)Markers(|2) are removed.
* the space necessary for the markers is now counted in the
before/above margins in the row structure. Therefore painting will
not happen at (x + 1, y), but just (x,y).
* the methods drawDecoration are removed.
* the helper methods InsetMath::(draw|metrics)Markers(|2) are removed
and replaced by a new function drawMarkers in MathRow.cpp.
Now the marker type is kept in the MathRow::Element object (and set to
NO_MARKER in not editable context) and the marker is accounted for in
MathRow::(metrics|draw).
Moreover, the extra pixel for the marker is taken on the before/After
space if possible. The marker will only require extra space when
before/after is 0.
See comment 168 of #8883 to understand what issues are fixed.
105 lines
1.7 KiB
C++
105 lines
1.7 KiB
C++
/**
|
|
* \file InsetMathComment.cpp
|
|
* This file is part of LyX, the document processor.
|
|
* Licence details can be found in the file COPYING.
|
|
*
|
|
* \author André Pönitz
|
|
*
|
|
* Full author contact details are available in file CREDITS.
|
|
*/
|
|
|
|
#include <config.h>
|
|
|
|
#include "InsetMathComment.h"
|
|
|
|
#include "MathData.h"
|
|
#include "MathStream.h"
|
|
#include "MathSupport.h"
|
|
|
|
#include <ostream>
|
|
|
|
|
|
namespace lyx {
|
|
|
|
InsetMathComment::InsetMathComment(Buffer * buf)
|
|
: InsetMathNest(buf, 1)
|
|
{}
|
|
|
|
|
|
InsetMathComment::InsetMathComment(MathData const & ar)
|
|
: InsetMathNest(const_cast<Buffer *>(ar.buffer()), 1)
|
|
{
|
|
cell(0) = ar;
|
|
}
|
|
|
|
|
|
InsetMathComment::InsetMathComment(Buffer * buf, docstring const & str)
|
|
: InsetMathNest(buf, 1)
|
|
{
|
|
// FIXME UNICODE
|
|
asArray(str, cell(0));
|
|
}
|
|
|
|
|
|
Inset * InsetMathComment::clone() const
|
|
{
|
|
return new InsetMathComment(*this);
|
|
}
|
|
|
|
|
|
void InsetMathComment::metrics(MetricsInfo & mi, Dimension & dim) const
|
|
{
|
|
cell(0).metrics(mi, dim);
|
|
}
|
|
|
|
|
|
void InsetMathComment::draw(PainterInfo & pi, int x, int y) const
|
|
{
|
|
cell(0).draw(pi, x, y);
|
|
}
|
|
|
|
|
|
void InsetMathComment::metricsT(TextMetricsInfo const & mi, Dimension & dim) const
|
|
{
|
|
cell(0).metricsT(mi, dim);
|
|
}
|
|
|
|
|
|
void InsetMathComment::drawT(TextPainter & pain, int x, int y) const
|
|
{
|
|
cell(0).drawT(pain, x, y);
|
|
}
|
|
|
|
|
|
void InsetMathComment::write(WriteStream & os) const
|
|
{
|
|
os << '%' << cell(0) << "\n";
|
|
}
|
|
|
|
|
|
void InsetMathComment::maple(MapleStream & os) const
|
|
{
|
|
os << '#' << cell(0) << "\n";
|
|
}
|
|
|
|
|
|
void InsetMathComment::mathmlize(MathStream & os) const
|
|
{
|
|
os << MTag("comment") << cell(0) << ETag("comment");
|
|
}
|
|
|
|
|
|
void InsetMathComment::htmlize(HtmlStream & os) const
|
|
{
|
|
os << "<!-- " << cell(0) << " -->";
|
|
}
|
|
|
|
|
|
void InsetMathComment::infoize(odocstream & os) const
|
|
{
|
|
os << "Comment";
|
|
}
|
|
|
|
|
|
} // namespace lyx
|