]> git.lyx.org Git - lyx.git/blob - src/mathed/InsetMathXYMatrix.cpp
more latin1..utf8 schanges. all of src/* should be utf8 now
[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 namespace lyx {
21
22
23 InsetMathXYMatrix::InsetMathXYMatrix(Length const & s, char c)
24         : InsetMathGrid(1, 1), spacing_(s), spacing_code_(c)
25 {}
26
27
28 Inset * InsetMathXYMatrix::clone() const
29 {
30         return new InsetMathXYMatrix(*this);
31 }
32
33
34 int InsetMathXYMatrix::colsep() const
35 {
36         return 40;
37 }
38
39
40 int InsetMathXYMatrix::rowsep() const
41 {
42         return 40;
43 }
44
45
46 void InsetMathXYMatrix::metrics(MetricsInfo & mi, Dimension & dim) const
47 {
48         if (mi.base.style == LM_ST_DISPLAY)
49                 mi.base.style = LM_ST_TEXT;
50         InsetMathGrid::metrics(mi, dim);
51 }
52
53
54 void InsetMathXYMatrix::write(WriteStream & os) const
55 {
56         MathEnsurer ensurer(os);
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