]> git.lyx.org Git - lyx.git/blob - src/mathed/InsetMathFontOld.cpp
listerrors.lyx : Update a link.
[lyx.git] / src / mathed / InsetMathFontOld.cpp
1 /**
2  * \file InsetMathFontOld.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 "InsetMathFontOld.h"
14
15 #include "MathData.h"
16 #include "MathParser.h"
17 #include "MathStream.h"
18 #include "MathSupport.h"
19 #include "MetricsInfo.h"
20
21 #include <ostream>
22
23
24 namespace lyx {
25
26 InsetMathFontOld::InsetMathFontOld(Buffer * buf, latexkeys const * key)
27         : InsetMathNest(buf, 1), key_(key), current_mode_(TEXT_MODE)
28 {
29         //lock(true);
30 }
31
32
33 Inset * InsetMathFontOld::clone() const
34 {
35         return new InsetMathFontOld(*this);
36 }
37
38
39 void InsetMathFontOld::metrics(MetricsInfo & mi, Dimension & dim) const
40 {
41         current_mode_ = isTextFont(from_ascii(mi.base.fontname))
42                                 ? TEXT_MODE : MATH_MODE;
43
44         docstring const font = current_mode_ == MATH_MODE
45                                 ? "math" + key_->name : "text" + key_->name;
46
47         // When \cal is used in text mode, the font is not changed
48         bool really_change_font = font != "textcal";
49
50         FontSetChanger dummy(mi.base, font, really_change_font);
51         cell(0).metrics(mi, dim);
52         metricsMarkers(dim);
53 }
54
55
56 void InsetMathFontOld::draw(PainterInfo & pi, int x, int y) const
57 {
58         current_mode_ = isTextFont(from_ascii(pi.base.fontname))
59                                 ? TEXT_MODE : MATH_MODE;
60
61         docstring const font = current_mode_ == MATH_MODE
62                                 ? "math" + key_->name : "text" + key_->name;
63
64         // When \cal is used in text mode, the font is not changed
65         bool really_change_font = font != "textcal";
66
67         FontSetChanger dummy(pi.base, font, really_change_font);
68         cell(0).draw(pi, x + 1, y);
69         drawMarkers(pi, x, y);
70 }
71
72
73 void InsetMathFontOld::metricsT(TextMetricsInfo const & mi, Dimension & dim) const
74 {
75         cell(0).metricsT(mi, dim);
76 }
77
78
79 void InsetMathFontOld::drawT(TextPainter & pain, int x, int y) const
80 {
81         cell(0).drawT(pain, x, y);
82 }
83
84
85 void InsetMathFontOld::write(WriteStream & os) const
86 {
87         os << "{\\" << key_->name << ' ' << cell(0) << '}';
88 }
89
90
91 void InsetMathFontOld::normalize(NormalStream & os) const
92 {
93         os << "[font " << key_->name << ' ' << cell(0) << ']';
94 }
95
96
97 void InsetMathFontOld::infoize(odocstream & os) const
98 {
99         os << "Font: " << key_->name;
100 }
101
102
103 } // namespace lyx