]> git.lyx.org Git - lyx.git/blob - src/mathed/math_fontinset.C
c8669f4f5013b9d5b3efdfbf86e12c62a923631c
[lyx.git] / src / mathed / math_fontinset.C
1 #include <config.h>
2
3 #include "math_fontinset.h"
4 #include "math_mathmlstream.h"
5 #include "math_streamstr.h"
6 #include "math_support.h"
7 #include "math_parser.h"
8 #include "LaTeXFeatures.h"
9 #include "support/LOstream.h"
10 #include "textpainter.h"
11
12
13
14 MathFontInset::MathFontInset(latexkeys const * key)
15         : MathNestInset(1), key_(key)
16 {}
17
18
19 InsetBase * MathFontInset::clone() const
20 {
21         return new MathFontInset(*this);
22 }
23
24
25 MathInset::mode_type MathFontInset::currentMode() const
26 {
27         if (key_->extra == "mathmode")
28                 return MATH_MODE;
29         if (key_->extra == "textmode")
30                 return TEXT_MODE;
31         return UNDECIDED_MODE;
32 }
33
34
35 void MathFontInset::metrics(MetricsInfo & mi, Dimension & dim) const
36 {
37         FontSetChanger dummy(mi.base, key_->name.c_str());
38         cell(0).metrics(mi, dim_);
39         metricsMarkers(1);
40         dim = dim_;
41 }
42
43
44 void MathFontInset::draw(PainterInfo & pi, int x, int y) const
45 {
46         FontSetChanger dummy(pi.base, key_->name.c_str());
47         cell(0).draw(pi, x + 1, y);
48         drawMarkers(pi, x, y);
49 }
50
51
52 void MathFontInset::metricsT(TextMetricsInfo const & mi, Dimension & dim) const
53 {
54         cell(0).metricsT(mi, dim_);
55 }
56
57
58 void MathFontInset::drawT(TextPainter & pain, int x, int y) const
59 {
60         cell(0).drawT(pain, x, y);
61 }
62
63
64 string MathFontInset::name() const
65 {
66         return key_->name;
67 }
68
69
70 void MathFontInset::validate(LaTeXFeatures & features) const
71 {
72         MathNestInset::validate(features);
73         // Make sure amssymb is put in preamble if Blackboard Bold or
74         // Fraktur used:
75         if (key_->name == "mathfrak" || key_->name == "mathbb")
76                 features.require("amssymb");
77 }
78
79
80 void MathFontInset::infoize(std::ostream & os) const
81 {
82         os << "Font: " << key_->name;
83 }