]> git.lyx.org Git - lyx.git/blob - src/mathed/math_fontinset.C
no special treatment for scriptinsets
[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         if (key_->extra == "mathmode")
35                 return MATH_MODE;
36         if (key_->extra == "textmode")
37                 return TEXT_MODE;
38         return UNDECIDED_MODE;
39 }
40
41
42 void MathFontInset::metrics(MathMetricsInfo & mi) const
43 {
44         MathFontSetChanger dummy(mi.base, key_->name.c_str());
45         dim_ = xcell(0).metrics(mi);
46         metricsMarkers();
47 }
48
49
50 void MathFontInset::draw(MathPainterInfo & pi, int x, int y) const
51 {
52         //lyxerr << "MathFontInset::draw\n";
53         //MathNestInset::draw(pi, x, y);
54         MathFontSetChanger dummy(pi.base, key_->name.c_str());
55         xcell(0).draw(pi, x + 1, y);
56         drawMarkers(pi, x, y);
57 }
58
59
60 void MathFontInset::metricsT(TextMetricsInfo const & mi) const
61 {
62         dim_ = xcell(0).metricsT(mi);
63 }
64
65
66 void MathFontInset::drawT(TextPainter & pain, int x, int y) const
67 {
68         //lyxerr << "drawing font code: " << code_ << '\n';
69         xcell(0).drawT(pain, x, y);
70 }
71
72
73 void MathFontInset::write(WriteStream & os) const
74 {
75         os << '\\' << key_->name << '{' << cell(0) << '}';
76 }
77
78
79 void MathFontInset::normalize(NormalStream & os) const
80 {
81         os << "[font " << key_->name << " " << cell(0) << "]";
82 }
83
84
85 void MathFontInset::validate(LaTeXFeatures & features) const
86 {
87         // Make sure amssymb is put in preamble if Blackboard Bold or
88         // Fraktur used:
89         if (key_->name == "mathfrak" || key_->name == "mathbb")
90                 features.require("amssymb");
91 }
92
93
94 void MathFontInset::infoize(std::ostream & os) const
95 {
96         os << "Font: " << key_->name;
97 }