2006-02-22 12:26:06 +00:00
|
|
|
/**
|
2007-04-25 03:01:35 +00:00
|
|
|
* \file InsetMathXYMatrix.cpp
|
2006-02-22 12:26:06 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
2008-11-14 15:58:50 +00:00
|
|
|
* \author André Pönitz
|
2006-02-22 12:26:06 +00:00
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
2006-09-17 09:14:18 +00:00
|
|
|
#include "InsetMathXYMatrix.h"
|
2006-02-22 12:26:06 +00:00
|
|
|
|
2007-11-06 21:45:24 +00:00
|
|
|
#include "MathStream.h"
|
|
|
|
|
2016-06-04 08:41:13 +00:00
|
|
|
#include "LaTeXFeatures.h"
|
|
|
|
#include "MetricsInfo.h"
|
|
|
|
|
2008-05-06 10:36:32 +00:00
|
|
|
#include <ostream>
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
namespace lyx {
|
|
|
|
|
|
|
|
|
2009-12-13 21:32:08 +00:00
|
|
|
InsetMathXYMatrix::InsetMathXYMatrix(Buffer * buf, Length const & s, char c,
|
|
|
|
bool e) : InsetMathGrid(buf, 1, 1), spacing_(s), spacing_code_(c),
|
|
|
|
equal_spacing_(e)
|
2009-11-08 11:45:46 +00:00
|
|
|
{
|
|
|
|
}
|
2006-02-22 12:26:06 +00:00
|
|
|
|
|
|
|
|
2007-08-30 18:03:17 +00:00
|
|
|
Inset * InsetMathXYMatrix::clone() const
|
2006-02-22 12:26:06 +00:00
|
|
|
{
|
2007-08-30 22:30:31 +00:00
|
|
|
return new InsetMathXYMatrix(*this);
|
2006-02-22 12:26:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
int InsetMathXYMatrix::colsep() const
|
2006-02-22 12:26:06 +00:00
|
|
|
{
|
|
|
|
return 40;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
int InsetMathXYMatrix::rowsep() const
|
2006-02-22 12:26:06 +00:00
|
|
|
{
|
|
|
|
return 40;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-09-21 20:39:47 +00:00
|
|
|
void InsetMathXYMatrix::metrics(MetricsInfo & mi, Dimension & dim) const
|
2006-02-22 12:26:06 +00:00
|
|
|
{
|
2016-11-22 10:26:15 +00:00
|
|
|
Changer dummy2 = mi.base.changeEnsureMath();
|
2016-11-20 18:53:16 +00:00
|
|
|
Changer dummy = mi.base.changeArray();
|
2006-09-16 18:11:38 +00:00
|
|
|
InsetMathGrid::metrics(mi, dim);
|
2006-02-22 12:26:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-11-19 20:25:34 +00:00
|
|
|
void InsetMathXYMatrix::draw(PainterInfo & pi, int x, int y) const
|
|
|
|
{
|
2016-11-22 10:26:15 +00:00
|
|
|
Changer dummy2 = pi.base.changeEnsureMath();
|
2016-11-20 18:53:16 +00:00
|
|
|
Changer dummy = pi.base.changeArray();
|
2016-11-19 20:25:34 +00:00
|
|
|
InsetMathGrid::draw(pi, x, y);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-26 19:04:36 +00:00
|
|
|
void InsetMathXYMatrix::write(TeXMathStream & os) const
|
2006-02-22 12:26:06 +00:00
|
|
|
{
|
2008-06-17 11:10:43 +00:00
|
|
|
MathEnsurer ensurer(os);
|
2021-12-27 10:42:30 +00:00
|
|
|
if (os.fragile())
|
|
|
|
os << "\\protect";
|
2006-10-31 19:10:30 +00:00
|
|
|
os << "\\xymatrix";
|
2015-10-07 03:13:21 +00:00
|
|
|
bool open = os.startOuterRow();
|
2009-12-13 21:32:08 +00:00
|
|
|
if (equal_spacing_) {
|
|
|
|
os << "@!";
|
|
|
|
switch (spacing_code_) {
|
|
|
|
case '0':
|
|
|
|
case 'R':
|
|
|
|
case 'C':
|
|
|
|
os << spacing_code_;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
switch (spacing_code_) {
|
|
|
|
case 'R':
|
|
|
|
case 'C':
|
|
|
|
case 'M':
|
|
|
|
case 'W':
|
|
|
|
case 'H':
|
|
|
|
case 'L':
|
|
|
|
os << '@' << spacing_code_ << '='
|
|
|
|
<< from_ascii(spacing_.asLatexString());
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
if (!spacing_.empty())
|
|
|
|
os << "@=" << from_ascii(spacing_.asLatexString());
|
|
|
|
}
|
2006-10-31 19:10:30 +00:00
|
|
|
}
|
|
|
|
os << '{';
|
2006-09-16 18:11:38 +00:00
|
|
|
InsetMathGrid::write(os);
|
2015-10-07 03:13:21 +00:00
|
|
|
os << "}";
|
|
|
|
if (open)
|
|
|
|
os.startOuterRow();
|
|
|
|
os << "\n";
|
2006-02-22 12:26:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-10-22 10:15:23 +00:00
|
|
|
void InsetMathXYMatrix::infoize(odocstream & os) const
|
2006-02-22 12:26:06 +00:00
|
|
|
{
|
|
|
|
os << "xymatrix ";
|
2009-12-13 21:32:08 +00:00
|
|
|
if (equal_spacing_) {
|
|
|
|
switch (spacing_code_) {
|
|
|
|
case '0':
|
|
|
|
case 'R':
|
|
|
|
case 'C':
|
|
|
|
os << '!' << spacing_code_ << ' ';
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
switch (spacing_code_) {
|
|
|
|
case 'R':
|
|
|
|
case 'C':
|
|
|
|
case 'M':
|
|
|
|
case 'W':
|
|
|
|
case 'H':
|
|
|
|
case 'L':
|
|
|
|
os << spacing_code_ << ' '
|
|
|
|
<< from_ascii(spacing_.asLatexString()) << ' ';
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
if (!spacing_.empty())
|
|
|
|
os << from_ascii(spacing_.asLatexString()) << ' ';
|
|
|
|
}
|
2006-10-31 19:10:30 +00:00
|
|
|
}
|
2006-09-16 18:11:38 +00:00
|
|
|
InsetMathGrid::infoize(os);
|
2006-02-22 12:26:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
void InsetMathXYMatrix::normalize(NormalStream & os) const
|
2006-02-22 12:26:06 +00:00
|
|
|
{
|
|
|
|
os << "[xymatrix ";
|
2006-09-16 18:11:38 +00:00
|
|
|
InsetMathGrid::normalize(os);
|
2006-02-22 12:26:06 +00:00
|
|
|
os << ']';
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
void InsetMathXYMatrix::maple(MapleStream & os) const
|
2006-02-22 12:26:06 +00:00
|
|
|
{
|
|
|
|
os << "xymatrix(";
|
2006-09-16 18:11:38 +00:00
|
|
|
InsetMathGrid::maple(os);
|
2006-02-22 12:26:06 +00:00
|
|
|
os << ')';
|
|
|
|
}
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
2006-10-31 19:10:30 +00:00
|
|
|
void InsetMathXYMatrix::validate(LaTeXFeatures & features) const
|
|
|
|
{
|
|
|
|
features.require("xy");
|
|
|
|
InsetMathGrid::validate(features);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-26 19:02:46 +00:00
|
|
|
void InsetMathXYMatrix::mathmlize(MathMLStream &) const
|
2010-07-29 15:38:01 +00:00
|
|
|
{
|
|
|
|
throw MathExportException();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-07-03 17:53:14 +00:00
|
|
|
void InsetMathXYMatrix::htmlize(HtmlStream &) const
|
2010-07-29 15:38:01 +00:00
|
|
|
{
|
2017-07-03 17:53:14 +00:00
|
|
|
throw MathExportException();
|
2010-07-29 15:38:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
} // namespace lyx
|