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