]> git.lyx.org Git - features.git/blob - src/mathed/InsetMathEnv.cpp
f04d87119f7d9f48bc5129452e2e92b39e228287
[features.git] / src / mathed / InsetMathEnv.cpp
1 /**
2  * \file InsetMathEnv.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 "InsetMathEnv.h"
14
15 #include "MathData.h"
16 #include "MathStream.h"
17 #include "MathStream.h"
18
19 #include <ostream>
20
21
22 namespace lyx {
23
24 InsetMathEnv::InsetMathEnv(docstring const & name)
25         : InsetMathNest(1), name_(name)
26 {}
27
28
29 Inset * InsetMathEnv::clone() const
30 {
31         return new InsetMathEnv(*this);
32 }
33
34
35 void InsetMathEnv::metrics(MetricsInfo & mi, Dimension & dim) const
36 {
37         cell(0).metrics(mi, dim);
38         metricsMarkers(dim);
39 }
40
41
42 void InsetMathEnv::draw(PainterInfo & pi, int x, int y) const
43 {
44         cell(0).draw(pi, x + 1, y);
45         drawMarkers(pi, x, y);
46 }
47
48
49 void InsetMathEnv::write(WriteStream & os) const
50 {
51         bool brace = os.pendingBrace();
52         os.pendingBrace(false);
53         if (os.latex() && os.textMode()) {
54                 os << "\\ensuremath{";
55                 os.textMode(false);
56                 brace = true;
57         }
58         os << "\\begin{" << name_ << '}' << cell(0) << "\\end{" << name_ << '}';
59         os.pendingBrace(brace);
60 }
61
62
63 void InsetMathEnv::normalize(NormalStream & os) const
64 {
65         os << "[env " << name_ << ' ' << cell(0) << ']';
66 }
67
68
69 void InsetMathEnv::infoize(odocstream & os) const
70 {
71         os << "Env: " << name_;
72 }
73
74
75 } // namespace lyx