lyx_mirror/src/mathed/InsetMathDiagram.cpp
Jean-Marc Lasgouttes 02e82157ec Get rid of Inset::setPosCache
This helper method is used to set the inset position cache at drawing
time. However this is already done by the drawing code itself
(MathRow::draw, RowPainter::paintInset), so that there is no need to
do this same work again in a different place.

Note that the inset positions are still set in InsetTabular::draw for
each cell.

This commit comes with a mild risk attached (it might be that some of
these calls were useful after all!), but all of this is fixable.
2016-12-06 16:15:47 +01:00

113 lines
1.9 KiB
C++

/**
* \file InsetMathDiagram.cpp
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
* \author André Pönitz
* \author Ronen Abravanel
*
* Full author contact details are available in file CREDITS.
*/
#include <config.h>
#include "InsetMathDiagram.h"
#include "MathStream.h"
#include "LaTeXFeatures.h"
#include "MetricsInfo.h"
#include <ostream>
namespace lyx {
InsetMathDiagram::InsetMathDiagram(Buffer * buf) : InsetMathGrid(buf, 1, 1)
{
}
Inset * InsetMathDiagram::clone() const
{
return new InsetMathDiagram(*this);
}
int InsetMathDiagram::colsep() const
{
return 10;
}
int InsetMathDiagram::rowsep() const
{
return 10;
}
void InsetMathDiagram::metrics(MetricsInfo & mi, Dimension & dim) const
{
Changer dummy2 = mi.base.changeEnsureMath();
FontInfo & f = mi.base.font;
Changer dummy = (f.style() == LM_ST_DISPLAY) ? f.changeStyle(LM_ST_TEXT)
: Changer();
InsetMathGrid::metrics(mi, dim);
}
void InsetMathDiagram::draw(PainterInfo & pi, int x, int y) const
{
Changer dummy2 = pi.base.changeEnsureMath();
FontInfo & f = pi.base.font;
Changer dummy = (f.style() == LM_ST_DISPLAY) ? f.changeStyle(LM_ST_TEXT)
: Changer();
InsetMathGrid::draw(pi, x, y);
}
void InsetMathDiagram::write(WriteStream & os) const
{
MathEnsurer ensurer(os);
os << "\\Diagram";
bool open = os.startOuterRow();
os << '{';
InsetMathGrid::write(os);
os << "}\n";
if (open)
os.startOuterRow();
}
void InsetMathDiagram::infoize(odocstream & os) const
{
os << "Diagram ";
InsetMathGrid::infoize(os);
}
void InsetMathDiagram::normalize(NormalStream & os) const
{
os << "[Diagram ";
InsetMathGrid::normalize(os);
os << ']';
}
void InsetMathDiagram::maple(MapleStream & os) const
{
os << "Diagram(";
InsetMathGrid::maple(os);
os << ')';
}
void InsetMathDiagram::validate(LaTeXFeatures & features) const
{
features.require("feyn");
InsetMathGrid::validate(features);
}
} // namespace lyx