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