]> git.lyx.org Git - lyx.git/blob - src/mathed/InsetMathFont.cpp
use bald pointers in clone()
[lyx.git] / src / mathed / InsetMathFont.cpp
1 /**
2  * \file InsetMathFont.cpp
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 "MathStream.h"
16 #include "MathParser.h"
17 #include "LaTeXFeatures.h"
18 #include "support/std_ostream.h"
19
20
21 namespace lyx {
22
23 InsetMathFont::InsetMathFont(latexkeys const * key)
24         : InsetMathNest(1), key_(key)
25 {}
26
27
28 Inset * InsetMathFont::clone() const
29 {
30         return new InsetMathFont(*this);
31 }
32
33
34 InsetMath::mode_type InsetMathFont::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 bool InsetMathFont::metrics(MetricsInfo & mi, Dimension & dim) const
45 {
46         FontSetChanger dummy(mi.base, key_->name);
47         cell(0).metrics(mi, dim);
48         metricsMarkers(dim);
49         if (dim_ == dim)
50                 return false;
51         dim_ = dim;
52         return true;
53 }
54
55
56 void InsetMathFont::draw(PainterInfo & pi, int x, int y) const
57 {
58         FontSetChanger dummy(pi.base, key_->name.c_str());
59         cell(0).draw(pi, x + 1, y);
60         drawMarkers(pi, x, y);
61         setPosCache(pi, x, y);
62 }
63
64
65 void InsetMathFont::metricsT(TextMetricsInfo const & mi, Dimension &) const
66 {
67         cell(0).metricsT(mi, dim_);
68 }
69
70
71 void InsetMathFont::drawT(TextPainter & pain, int x, int y) const
72 {
73         cell(0).drawT(pain, x, y);
74 }
75
76
77 docstring InsetMathFont::name() const
78 {
79         return key_->name;
80 }
81
82
83 void InsetMathFont::validate(LaTeXFeatures & features) const
84 {
85         InsetMathNest::validate(features);
86         // Make sure amssymb is put in preamble if Blackboard Bold or
87         // Fraktur used:
88         if (key_->name == "mathfrak" || key_->name == "mathbb")
89                 features.require("amssymb");
90         if (key_->name == "text")
91                 features.require("amsmath");
92         if (key_->name == "textipa")
93                 features.require("tipa");
94 }
95
96
97 void InsetMathFont::infoize(odocstream & os) const
98 {
99         os << "Font: " << key_->name;
100 }
101
102
103 } // namespace lyx