]> git.lyx.org Git - lyx.git/blob - src/mathed/math_fontinset.C
lyxfont.h no longer #includes LColor.h.
[lyx.git] / src / mathed / math_fontinset.C
1 /**
2  * \file math_fontinset.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author André Pönitz
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "math_fontinset.h"
14 #include "math_data.h"
15 #include "math_mathmlstream.h"
16 #include "math_parser.h"
17 #include "LaTeXFeatures.h"
18 #include "support/std_ostream.h"
19
20 using std::auto_ptr;
21
22
23 MathFontInset::MathFontInset(latexkeys const * key)
24         : MathNestInset(1), key_(key)
25 {}
26
27
28 auto_ptr<InsetBase> MathFontInset::clone() const
29 {
30         return auto_ptr<InsetBase>(new MathFontInset(*this));
31 }
32
33
34 MathInset::mode_type MathFontInset::currentMode() const
35 {
36         if (key_->extra == "mathmode")
37                 return MATH_MODE;
38         if (key_->extra == "textmode")
39                 return TEXT_MODE;
40         return UNDECIDED_MODE;
41 }
42
43
44 void MathFontInset::metrics(MetricsInfo & mi, Dimension & dim) const
45 {
46         FontSetChanger dummy(mi.base, key_->name.c_str());
47         cell(0).metrics(mi, dim_);
48         metricsMarkers(1);
49         dim = dim_;
50 }
51
52
53 void MathFontInset::draw(PainterInfo & pi, int x, int y) const
54 {
55         FontSetChanger dummy(pi.base, key_->name.c_str());
56         cell(0).draw(pi, x + 1, y);
57         drawMarkers(pi, x, y);
58 }
59
60
61 void MathFontInset::metricsT(TextMetricsInfo const & mi, Dimension & /*dim*/) const
62 {
63         cell(0).metricsT(mi, dim_);
64 }
65
66
67 void MathFontInset::drawT(TextPainter & pain, int x, int y) const
68 {
69         cell(0).drawT(pain, x, y);
70 }
71
72
73 string MathFontInset::name() const
74 {
75         return key_->name;
76 }
77
78
79 void MathFontInset::validate(LaTeXFeatures & features) const
80 {
81         MathNestInset::validate(features);
82         // Make sure amssymb is put in preamble if Blackboard Bold or
83         // Fraktur used:
84         if (key_->name == "mathfrak" || key_->name == "mathbb")
85                 features.require("amssymb");
86 }
87
88
89 void MathFontInset::infoize(std::ostream & os) const
90 {
91         os << "Font: " << key_->name;
92 }