]> git.lyx.org Git - lyx.git/blob - src/mathed/InsetMathXYMatrix.C
Fixed bug 3449 by Stefan Schimanski:
[lyx.git] / src / mathed / InsetMathXYMatrix.C
1 /**
2  * \file InsetMathXYMatrix.C
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 #include "MathStream.h"
15
16 #include "LaTeXFeatures.h"
17 #include "support/std_ostream.h"
18
19
20 namespace lyx {
21
22
23 InsetMathXYMatrix::InsetMathXYMatrix(LyXLength const & s, char c)
24         : InsetMathGrid(1, 1), spacing_(s), spacing_code_(c)
25 {}
26
27
28 std::auto_ptr<InsetBase> InsetMathXYMatrix::doClone() const
29 {
30         return std::auto_ptr<InsetBase>(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 bool 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         if (dim_ == dim)
52                 return false;
53         dim_ = dim;
54         return true;
55 }
56
57
58 void InsetMathXYMatrix::write(WriteStream & os) const
59 {
60         os << "\\xymatrix";
61         switch (spacing_code_) {
62         case 'R':
63         case 'C':
64         case 'M':
65         case 'W':
66         case 'H':
67         case 'L':
68                 os << '@' << spacing_code_ << '='
69                    << from_ascii(spacing_.asLatexString());
70                 break;
71         default:
72                 if (!spacing_.empty())
73                         os << "@=" << from_ascii(spacing_.asLatexString());
74         }
75         os << '{';
76         InsetMathGrid::write(os);
77         os << "}\n";
78 }
79
80
81 void InsetMathXYMatrix::infoize(odocstream & os) const
82 {
83         os << "xymatrix ";
84         switch (spacing_code_) {
85         case 'R':
86         case 'C':
87         case 'M':
88         case 'W':
89         case 'H':
90         case 'L':
91                 os << spacing_code_ << ' '
92                    << from_ascii(spacing_.asLatexString()) << ' ';
93                 break;
94         default:
95                 if (!spacing_.empty())
96                         os << from_ascii(spacing_.asLatexString()) << ' ';
97         }
98         InsetMathGrid::infoize(os);
99 }
100
101
102 void InsetMathXYMatrix::normalize(NormalStream & os) const
103 {
104         os << "[xymatrix ";
105         InsetMathGrid::normalize(os);
106         os << ']';
107 }
108
109
110 void InsetMathXYMatrix::maple(MapleStream & os) const
111 {
112         os << "xymatrix(";
113         InsetMathGrid::maple(os);
114         os << ')';
115 }
116
117
118 void InsetMathXYMatrix::validate(LaTeXFeatures & features) const
119 {
120         features.require("xy");
121         InsetMathGrid::validate(features);
122 }
123
124
125 } // namespace lyx