]> git.lyx.org Git - lyx.git/blob - src/mathed/math_fontinset.C
4283014d81110ed960ccd90993b61ac6b3fa1289
[lyx.git] / src / mathed / math_fontinset.C
1 #include <config.h>
2
3 #ifdef __GNUG__
4 #pragma implementation
5 #endif
6
7 #include "math_fontinset.h"
8 #include "debug.h"
9 #include "math_mathmlstream.h"
10 #include "math_streamstr.h"
11 #include "math_support.h"
12 #include "math_parser.h"
13 #include "LaTeXFeatures.h"
14 #include "textpainter.h"
15 #include "frontends/Painter.h"
16
17
18
19 MathFontInset::MathFontInset(latexkeys const * key)
20         : MathNestInset(1), key_(key)
21 {
22         //lock(true);
23 }
24
25
26 MathInset * MathFontInset::clone() const
27 {
28         return new MathFontInset(*this);
29 }
30
31
32 MathInset::mode_type MathFontInset::currentMode() const
33 {
34         return key_->extra == "mathmode" ? MATH_MODE : TEXT_MODE;
35 }
36
37
38 void MathFontInset::metrics(MathMetricsInfo & mi) const
39 {
40         MathFontSetChanger dummy(mi.base, key_->name.c_str());
41         dim_ = xcell(0).metrics(mi);
42         metricsMarkers();
43 }
44
45
46 void MathFontInset::draw(MathPainterInfo & pi, int x, int y) const
47 {
48         //lyxerr << "MathFontInset::draw\n";
49         //MathNestInset::draw(pi, x, y);
50         MathFontSetChanger dummy(pi.base, key_->name.c_str());
51         xcell(0).draw(pi, x + 1, y);
52         drawMarkers(pi, x, y);
53 }
54
55
56 void MathFontInset::metricsT(TextMetricsInfo const & mi) const
57 {
58         dim_ = xcell(0).metricsT(mi);
59 }
60
61
62 void MathFontInset::drawT(TextPainter & pain, int x, int y) const
63 {
64         //lyxerr << "drawing font code: " << code_ << '\n';
65         xcell(0).drawT(pain, x, y);
66 }
67
68
69 void MathFontInset::write(WriteStream & os) const
70 {
71         os << '\\' << key_->name << '{' << cell(0) << '}';
72 }
73
74
75 void MathFontInset::normalize(NormalStream & os) const
76 {
77         os << "[font " << key_->name << " " << cell(0) << "]";
78 }
79
80
81 void MathFontInset::validate(LaTeXFeatures & features) const
82 {
83         // Make sure amssymb is put in preamble if Blackboard Bold or
84         // Fraktur used:
85         if (key_->name == "mathfrak" || key_->name == "mathbb")
86                 features.require("amssymb");
87 }
88
89
90 void MathFontInset::infoize(std::ostream & os) const
91 {
92         os << "Font: " << key_->name;
93 }