]> git.lyx.org Git - lyx.git/blob - src/mathed/InsetMathEnsureMath.cpp
3fdb3fbba9beeff3cacae91ca710a0b9d05c284a
[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 "MathData.h"
17 #include "MathStream.h"
18 #include "MathSupport.h"
19
20 #include <ostream>
21
22
23 namespace lyx {
24
25 InsetMathEnsureMath::InsetMathEnsureMath(Buffer * buf)
26         : InsetMathNest(buf, 1)
27 {}
28
29
30 Inset * InsetMathEnsureMath::clone() const
31 {
32         return new InsetMathEnsureMath(*this);
33 }
34
35
36 void InsetMathEnsureMath::metrics(MetricsInfo & mi, Dimension & dim) const
37 {
38         bool really_change_font = isTextFont(from_ascii(mi.base.fontname));
39         FontSetChanger dummy(mi.base, "mathnormal", really_change_font);
40         cell(0).metrics(mi, dim);
41         metricsMarkers(dim);
42 }
43
44
45 void InsetMathEnsureMath::draw(PainterInfo & pi, int x, int y) const
46 {
47         bool really_change_font = isTextFont(from_ascii(pi.base.fontname));
48         FontSetChanger dummy(pi.base, "mathnormal", really_change_font);
49         cell(0).draw(pi, x, y);
50         drawMarkers(pi, x, y);
51 }
52
53
54 void InsetMathEnsureMath::metricsT(TextMetricsInfo const & mi, Dimension & dim) const
55 {
56         cell(0).metricsT(mi, dim);
57 }
58
59
60 void InsetMathEnsureMath::drawT(TextPainter & pain, int x, int y) const
61 {
62         cell(0).drawT(pain, x, y);
63 }
64
65
66 void InsetMathEnsureMath::write(WriteStream & os) const
67 {
68         ModeSpecifier specifier(os, MATH_MODE);
69         os << "\\ensuremath{" << cell(0) << "}";
70 }
71
72
73 void InsetMathEnsureMath::mathmlize(MathStream & os) const
74 {
75         os << cell(0);
76 }
77
78
79 void InsetMathEnsureMath::infoize(odocstream & os) const
80 {
81         os << "EnsureMath";
82 }
83
84
85 } // namespace lyx