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