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