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