]> git.lyx.org Git - lyx.git/blob - src/mathed/InsetMathEnsureMath.cpp
Implement the EnsureMath inset in mathed for nesting math mode in text mode.
[lyx.git] / src / mathed / InsetMathEnsureMath.cpp
1 /**
2  * \file InsetMathEnsureMath.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  * \author Enrico Forestieri
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #include <config.h>
13
14 #include "InsetMathEnsureMath.h"
15
16 #include "MathStream.h"
17 #include "MathData.h"
18
19 #include <ostream>
20
21
22 namespace lyx {
23
24 InsetMathEnsureMath::InsetMathEnsureMath()
25         : InsetMathNest(1)
26 {}
27
28
29 Inset * InsetMathEnsureMath::clone() const
30 {
31         return new InsetMathEnsureMath(*this);
32 }
33
34
35 void InsetMathEnsureMath::metrics(MetricsInfo & mi, Dimension & dim) const
36 {
37         FontSetChanger dummy(mi.base, "mathnormal");
38         cell(0).metrics(mi, dim);
39         metricsMarkers(dim);
40 }
41
42
43 void InsetMathEnsureMath::draw(PainterInfo & pi, int x, int y) const
44 {
45         FontSetChanger dummy(pi.base, "mathnormal");
46         cell(0).draw(pi, x, y);
47         drawMarkers(pi, x, y);
48 }
49
50
51 void InsetMathEnsureMath::metricsT(TextMetricsInfo const & mi, Dimension & dim) const
52 {
53         cell(0).metricsT(mi, dim);
54 }
55
56
57 void InsetMathEnsureMath::drawT(TextPainter & pain, int x, int y) const
58 {
59         cell(0).drawT(pain, x, y);
60 }
61
62
63 void InsetMathEnsureMath::write(WriteStream & os) const
64 {
65         ModeSpecifier specifier(os, MATH_MODE);
66         os << "\\ensuremath{" << cell(0) << "}";
67 }
68
69
70 void InsetMathEnsureMath::infoize(odocstream & os) const
71 {
72         os << "EnsureMath";
73 }
74
75
76 } // namespace lyx