]> git.lyx.org Git - lyx.git/blob - src/mathed/InsetMathFont.C
rename mathed/math_xinset into mathed/InsetMathX
[lyx.git] / src / mathed / InsetMathFont.C
1 /**
2  * \file InsetMathFont.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 "InsetMathFont.h"
14 #include "MathData.h"
15 #include "MathMLStream.h"
16 #include "MathParser.h"
17 #include "LaTeXFeatures.h"
18 #include "support/std_ostream.h"
19
20 using std::string;
21 using std::auto_ptr;
22
23
24 InsetMathFont::InsetMathFont(latexkeys const * key)
25         : InsetMathNest(1), key_(key)
26 {}
27
28
29 auto_ptr<InsetBase> InsetMathFont::doClone() const
30 {
31         return auto_ptr<InsetBase>(new InsetMathFont(*this));
32 }
33
34
35 InsetMath::mode_type InsetMathFont::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 InsetMathFont::metrics(MetricsInfo & mi, Dimension & dim) const
46 {
47         FontSetChanger dummy(mi.base, key_->name.c_str());
48         cell(0).metrics(mi, dim);
49         metricsMarkers(dim);
50         dim_ = dim;
51 }
52
53
54 void InsetMathFont::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         setPosCache(pi, x, y);
60 }
61
62
63 void InsetMathFont::metricsT(TextMetricsInfo const & mi, Dimension &) const
64 {
65         cell(0).metricsT(mi, dim_);
66 }
67
68
69 void InsetMathFont::drawT(TextPainter & pain, int x, int y) const
70 {
71         cell(0).drawT(pain, x, y);
72 }
73
74
75 string InsetMathFont::name() const
76 {
77         return key_->name;
78 }
79
80
81 void InsetMathFont::validate(LaTeXFeatures & features) const
82 {
83         InsetMathNest::validate(features);
84         // Make sure amssymb is put in preamble if Blackboard Bold or
85         // Fraktur used:
86         if (key_->name == "mathfrak" || key_->name == "mathbb")
87                 features.require("amssymb");
88         if (key_->name == "text")
89                 features.require("amsmath");
90         if (key_->name == "textipa")
91                 features.require("tipa");
92 }
93
94
95 void InsetMathFont::infoize(std::ostream & os) const
96 {
97         os << "Font: " << key_->name;
98 }