]> git.lyx.org Git - lyx.git/blob - src/mathed/InsetMathXYMatrix.cpp
Revert "Give a 2 pixels space for markers around math objects"
[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 "MathStream.h"
16
17 #include "LaTeXFeatures.h"
18 #include "MetricsInfo.h"
19
20 #include <ostream>
21
22 namespace lyx {
23
24
25 InsetMathXYMatrix::InsetMathXYMatrix(Buffer * buf, Length const & s, char c,
26         bool e) : InsetMathGrid(buf, 1, 1), spacing_(s), spacing_code_(c),
27         equal_spacing_(e)
28 {
29 }
30
31
32 Inset * InsetMathXYMatrix::clone() const
33 {
34         return new InsetMathXYMatrix(*this);
35 }
36
37
38 int InsetMathXYMatrix::colsep() const
39 {
40         return 40;
41 }
42
43
44 int InsetMathXYMatrix::rowsep() const
45 {
46         return 40;
47 }
48
49
50 void InsetMathXYMatrix::metrics(MetricsInfo & mi, Dimension & dim) const
51 {
52         Changer dummy2 = mi.base.changeEnsureMath();
53         Changer dummy = mi.base.changeArray();
54         InsetMathGrid::metrics(mi, dim);
55 }
56
57
58 void InsetMathXYMatrix::draw(PainterInfo & pi, int x, int y) const
59 {
60         Changer dummy2 = pi.base.changeEnsureMath();
61         Changer dummy = pi.base.changeArray();
62         InsetMathGrid::draw(pi, x, y);
63 }
64
65
66 void InsetMathXYMatrix::write(WriteStream & os) const
67 {
68         MathEnsurer ensurer(os);
69         os << "\\xymatrix";
70         bool open = os.startOuterRow();
71         if (equal_spacing_) {
72                 os << "@!";
73                 switch (spacing_code_) {
74                 case '0':
75                 case 'R':
76                 case 'C':
77                         os << spacing_code_;
78                 }
79         } else {
80                 switch (spacing_code_) {
81                 case 'R':
82                 case 'C':
83                 case 'M':
84                 case 'W':
85                 case 'H':
86                 case 'L':
87                         os << '@' << spacing_code_ << '='
88                            << from_ascii(spacing_.asLatexString());
89                         break;
90                 default:
91                         if (!spacing_.empty())
92                                 os << "@=" << from_ascii(spacing_.asLatexString());
93                 }
94         }
95         os << '{';
96         InsetMathGrid::write(os);
97         os << "}";
98         if (open)
99                 os.startOuterRow();
100         os << "\n";
101 }
102
103
104 void InsetMathXYMatrix::infoize(odocstream & os) const
105 {
106         os << "xymatrix ";
107         if (equal_spacing_) {
108                 switch (spacing_code_) {
109                 case '0':
110                 case 'R':
111                 case 'C':
112                         os << '!' << spacing_code_ << ' ';
113                 }
114         } else {
115                 switch (spacing_code_) {
116                 case 'R':
117                 case 'C':
118                 case 'M':
119                 case 'W':
120                 case 'H':
121                 case 'L':
122                         os << spacing_code_ << ' '
123                            << from_ascii(spacing_.asLatexString()) << ' ';
124                         break;
125                 default:
126                         if (!spacing_.empty())
127                                 os << from_ascii(spacing_.asLatexString()) << ' ';
128                 }
129         }
130         InsetMathGrid::infoize(os);
131 }
132
133
134 void InsetMathXYMatrix::normalize(NormalStream & os) const
135 {
136         os << "[xymatrix ";
137         InsetMathGrid::normalize(os);
138         os << ']';
139 }
140
141
142 void InsetMathXYMatrix::maple(MapleStream & os) const
143 {
144         os << "xymatrix(";
145         InsetMathGrid::maple(os);
146         os << ')';
147 }
148
149
150 void InsetMathXYMatrix::validate(LaTeXFeatures & features) const
151 {
152         features.require("xy");
153         InsetMathGrid::validate(features);
154 }
155
156
157 void InsetMathXYMatrix::mathmlize(MathStream &) const
158 {
159         throw MathExportException();
160 }
161
162
163 void InsetMathXYMatrix::htmlize(HtmlStream &) const 
164 {
165         throw MathExportException(); 
166 }
167
168
169 } // namespace lyx