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.
|
|
|
|
|
*
|
|
|
|
|
* \author Andr<EFBFBD> P<EFBFBD>nitz
|
|
|
|
|
*
|
|
|
|
|
* 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
|
|
|
|
|
|
|
|
|
#include "LaTeXFeatures.h"
|
2007-11-06 21:45:24 +00:00
|
|
|
|
#include "MathStream.h"
|
|
|
|
|
|
|
|
|
|
#include <ostream>
|
2006-02-22 12:26:06 +00:00
|
|
|
|
|
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
namespace lyx {
|
|
|
|
|
|
|
|
|
|
|
2007-04-28 12:58:49 +00:00
|
|
|
|
InsetMathXYMatrix::InsetMathXYMatrix(Length const & s, char c)
|
2006-10-31 19:10:30 +00:00
|
|
|
|
: InsetMathGrid(1, 1), spacing_(s), spacing_code_(c)
|
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
|
|
|
|
{
|
|
|
|
|
if (mi.base.style == LM_ST_DISPLAY)
|
|
|
|
|
mi.base.style = LM_ST_TEXT;
|
2006-09-16 18:11:38 +00:00
|
|
|
|
InsetMathGrid::metrics(mi, dim);
|
2006-02-22 12:26:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
|
void InsetMathXYMatrix::write(WriteStream & os) const
|
2006-02-22 12:26:06 +00:00
|
|
|
|
{
|
2006-10-31 19:10:30 +00:00
|
|
|
|
os << "\\xymatrix";
|
|
|
|
|
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());
|
|
|
|
|
}
|
|
|
|
|
os << '{';
|
2006-09-16 18:11:38 +00:00
|
|
|
|
InsetMathGrid::write(os);
|
2006-02-22 12:26:06 +00:00
|
|
|
|
os << "}\n";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-10-22 10:15:23 +00:00
|
|
|
|
void InsetMathXYMatrix::infoize(odocstream & os) const
|
2006-02-22 12:26:06 +00:00
|
|
|
|
{
|
|
|
|
|
os << "xymatrix ";
|
2006-10-31 19:10:30 +00:00
|
|
|
|
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-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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
} // namespace lyx
|