]> git.lyx.org Git - lyx.git/blob - src/mathed/math_fontinset.C
merge MathArray and MathXArray classes.
[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
23
24 MathInset * MathFontInset::clone() const
25 {
26         return new MathFontInset(*this);
27 }
28
29
30 MathInset::mode_type MathFontInset::currentMode() const
31 {
32         if (key_->extra == "mathmode")
33                 return MATH_MODE;
34         if (key_->extra == "textmode")
35                 return TEXT_MODE;
36         return UNDECIDED_MODE;
37 }
38
39
40 void MathFontInset::metrics(MathMetricsInfo & mi) const
41 {
42         MathFontSetChanger dummy(mi.base, key_->name.c_str());
43         dim_ = cell(0).metrics(mi);
44         metricsMarkers();
45 }
46
47
48 void MathFontInset::draw(MathPainterInfo & pi, int x, int y) const
49 {
50         //lyxerr << "MathFontInset::draw\n";
51         //MathNestInset::draw(pi, x, y);
52         MathFontSetChanger dummy(pi.base, key_->name.c_str());
53         cell(0).draw(pi, x + 1, y);
54         drawMarkers(pi, x, y);
55 }
56
57
58 void MathFontInset::metricsT(TextMetricsInfo const & mi) const
59 {
60         dim_ = cell(0).metricsT(mi);
61 }
62
63
64 void MathFontInset::drawT(TextPainter & pain, int x, int y) const
65 {
66         //lyxerr << "drawing font code: " << code_ << '\n';
67         cell(0).drawT(pain, x, y);
68 }
69
70
71 string MathFontInset::name() const
72 {
73         return key_->name;
74 }
75
76
77 void MathFontInset::validate(LaTeXFeatures & features) const
78 {
79         // Make sure amssymb is put in preamble if Blackboard Bold or
80         // Fraktur used:
81         if (key_->name == "mathfrak" || key_->name == "mathbb")
82                 features.require("amssymb");
83 }
84
85
86 void MathFontInset::infoize(std::ostream & os) const
87 {
88         os << "Font: " << key_->name;
89 }