]> git.lyx.org Git - lyx.git/blob - src/mathed/InsetMathFont.cpp
* moved atom_dim_ to coord cache in the buffer view to make it dependent on the buffe...
[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
15 #include "LaTeXFeatures.h"
16 #include "MathData.h"
17 #include "MathStream.h"
18 #include "MathParser.h"
19 #include "MetricsInfo.h"
20
21 #include <ostream>
22
23
24 namespace lyx {
25
26 InsetMathFont::InsetMathFont(latexkeys const * key)
27         : InsetMathNest(1), key_(key)
28 {}
29
30
31 Inset * InsetMathFont::clone() const
32 {
33         return new InsetMathFont(*this);
34 }
35
36
37 InsetMath::mode_type InsetMathFont::currentMode() const
38 {
39         if (key_->extra == "mathmode")
40                 return MATH_MODE;
41         if (key_->extra == "textmode")
42                 return TEXT_MODE;
43         return UNDECIDED_MODE;
44 }
45
46
47 void InsetMathFont::metrics(MetricsInfo & mi, Dimension & dim) const
48 {
49         FontSetChanger dummy(mi.base, key_->name);
50         cell(0).metrics(mi, dim);
51         metricsMarkers(dim);
52 }
53
54
55 void InsetMathFont::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         setPosCache(pi, x, y);
61 }
62
63
64 void InsetMathFont::metricsT(TextMetricsInfo const & mi, Dimension &) const
65 {
66         // FIXME: BROKEN!
67         Dimension dim;
68         cell(0).metricsT(mi, dim);
69 }
70
71
72 void InsetMathFont::drawT(TextPainter & pain, int x, int y) const
73 {
74         cell(0).drawT(pain, x, y);
75 }
76
77
78 docstring InsetMathFont::name() const
79 {
80         return key_->name;
81 }
82
83
84 void InsetMathFont::validate(LaTeXFeatures & features) const
85 {
86         InsetMathNest::validate(features);
87         // Make sure amssymb is put in preamble if Blackboard Bold or
88         // Fraktur used:
89         if (key_->name == "mathfrak" || key_->name == "mathbb")
90                 features.require("amssymb");
91         if (key_->name == "text")
92                 features.require("amsmath");
93         if (key_->name == "textipa")
94                 features.require("tipa");
95 }
96
97
98 void InsetMathFont::infoize(odocstream & os) const
99 {
100         os << "Font: " << key_->name;
101 }
102
103
104 } // namespace lyx