]> git.lyx.org Git - lyx.git/blob - src/mathed/InsetMathXYMatrix.cpp
545ffafebb32d7b7bc4c3dd785595d7569eac5b6
[lyx.git] / src / mathed / InsetMathXYMatrix.cpp
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.
5  *
6  * \author André Pönitz
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "InsetMathXYMatrix.h"
14
15 #include "LaTeXFeatures.h"
16 #include "MathStream.h"
17
18 namespace lyx {
19
20
21 InsetMathXYMatrix::InsetMathXYMatrix(Length const & s, char c)
22         : InsetMathGrid(1, 1), spacing_(s), spacing_code_(c)
23 {}
24
25
26 Inset * InsetMathXYMatrix::clone() const
27 {
28         return new InsetMathXYMatrix(*this);
29 }
30
31
32 int InsetMathXYMatrix::colsep() const
33 {
34         return 40;
35 }
36
37
38 int InsetMathXYMatrix::rowsep() const
39 {
40         return 40;
41 }
42
43
44 void InsetMathXYMatrix::metrics(MetricsInfo & mi, Dimension & dim) const
45 {
46         if (mi.base.style == LM_ST_DISPLAY)
47                 mi.base.style = LM_ST_TEXT;
48         InsetMathGrid::metrics(mi, dim);
49 }
50
51
52 void InsetMathXYMatrix::write(WriteStream & os) const
53 {
54         os << "\\xymatrix";
55         switch (spacing_code_) {
56         case 'R':
57         case 'C':
58         case 'M':
59         case 'W':
60         case 'H':
61         case 'L':
62                 os << '@' << spacing_code_ << '='
63                    << from_ascii(spacing_.asLatexString());
64                 break;
65         default:
66                 if (!spacing_.empty())
67                         os << "@=" << from_ascii(spacing_.asLatexString());
68         }
69         os << '{';
70         InsetMathGrid::write(os);
71         os << "}\n";
72 }
73
74
75 void InsetMathXYMatrix::infoize(odocstream & os) const
76 {
77         os << "xymatrix ";
78         switch (spacing_code_) {
79         case 'R':
80         case 'C':
81         case 'M':
82         case 'W':
83         case 'H':
84         case 'L':
85                 os << spacing_code_ << ' '
86                    << from_ascii(spacing_.asLatexString()) << ' ';
87                 break;
88         default:
89                 if (!spacing_.empty())
90                         os << from_ascii(spacing_.asLatexString()) << ' ';
91         }
92         InsetMathGrid::infoize(os);
93 }
94
95
96 void InsetMathXYMatrix::normalize(NormalStream & os) const
97 {
98         os << "[xymatrix ";
99         InsetMathGrid::normalize(os);
100         os << ']';
101 }
102
103
104 void InsetMathXYMatrix::maple(MapleStream & os) const
105 {
106         os << "xymatrix(";
107         InsetMathGrid::maple(os);
108         os << ')';
109 }
110
111
112 void InsetMathXYMatrix::validate(LaTeXFeatures & features) const
113 {
114         features.require("xy");
115         InsetMathGrid::validate(features);
116 }
117
118
119 } // namespace lyx