A bit more re-organization.
[lyx.git] / src / mathed / InsetMathXYMatrix.cpp
blob39ac88586ab88dd458957c2e6a70b23b15474147
1 /**
2 * \file InsetMathXYMatrix.cpp
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author André Pönitz
8 * Full author contact details are available in file CREDITS.
9 */
11 #include <config.h>
13 #include "InsetMathXYMatrix.h"
15 #include "LaTeXFeatures.h"
16 #include "MathStream.h"
18 #include <ostream>
20 namespace lyx {
23 InsetMathXYMatrix::InsetMathXYMatrix(Buffer * buf, Length const & s, char c)
24 : InsetMathGrid(buf, 1, 1), spacing_(s), spacing_code_(c)
29 Inset * InsetMathXYMatrix::clone() const
31 return new InsetMathXYMatrix(*this);
35 int InsetMathXYMatrix::colsep() const
37 return 40;
41 int InsetMathXYMatrix::rowsep() const
43 return 40;
47 void InsetMathXYMatrix::metrics(MetricsInfo & mi, Dimension & dim) const
49 if (mi.base.style == LM_ST_DISPLAY)
50 mi.base.style = LM_ST_TEXT;
51 InsetMathGrid::metrics(mi, dim);
55 void InsetMathXYMatrix::write(WriteStream & os) const
57 MathEnsurer ensurer(os);
58 os << "\\xymatrix";
59 switch (spacing_code_) {
60 case 'R':
61 case 'C':
62 case 'M':
63 case 'W':
64 case 'H':
65 case 'L':
66 os << '@' << spacing_code_ << '='
67 << from_ascii(spacing_.asLatexString());
68 break;
69 default:
70 if (!spacing_.empty())
71 os << "@=" << from_ascii(spacing_.asLatexString());
73 os << '{';
74 InsetMathGrid::write(os);
75 os << "}\n";
79 void InsetMathXYMatrix::infoize(odocstream & os) const
81 os << "xymatrix ";
82 switch (spacing_code_) {
83 case 'R':
84 case 'C':
85 case 'M':
86 case 'W':
87 case 'H':
88 case 'L':
89 os << spacing_code_ << ' '
90 << from_ascii(spacing_.asLatexString()) << ' ';
91 break;
92 default:
93 if (!spacing_.empty())
94 os << from_ascii(spacing_.asLatexString()) << ' ';
96 InsetMathGrid::infoize(os);
100 void InsetMathXYMatrix::normalize(NormalStream & os) const
102 os << "[xymatrix ";
103 InsetMathGrid::normalize(os);
104 os << ']';
108 void InsetMathXYMatrix::maple(MapleStream & os) const
110 os << "xymatrix(";
111 InsetMathGrid::maple(os);
112 os << ')';
116 void InsetMathXYMatrix::validate(LaTeXFeatures & features) const
118 features.require("xy");
119 InsetMathGrid::validate(features);
123 } // namespace lyx