]> git.lyx.org Git - lyx.git/blob - src/mathed/math_fontinset.C
cosmetics
[lyx.git] / src / mathed / math_fontinset.C
1 #include <config.h>
2
3 #ifdef __GNUG__
4 #pragma implementation
5 #endif
6
7 #include "math_fontinset.h"
8 #include "debug.h"
9 #include "math_mathmlstream.h"
10 #include "math_streamstr.h"
11 #include "math_support.h"
12 #include "LaTeXFeatures.h"
13 #include "textpainter.h"
14 #include "frontends/Painter.h"
15
16
17
18 MathFontInset::MathFontInset(string const & name)
19         : MathNestInset(1), name_(name)
20 {
21         //lock(true);
22 }
23
24
25 MathInset * MathFontInset::clone() const
26 {
27         return new MathFontInset(*this);
28 }
29
30
31 void MathFontInset::metrics(MathMetricsInfo & mi) const
32 {
33         MathFontSetChanger dummy(mi.base, name_.c_str());
34         xcell(0).metrics(mi);
35         ascent_  = xcell(0).ascent();
36         descent_ = xcell(0).descent() + 1;
37         width_   = xcell(0).width()   + 2;
38 }
39
40
41 void MathFontInset::draw(MathPainterInfo & pi, int x, int y) const
42 {
43         //lyxerr << "MathFontInset::draw\n";
44         //MathNestInset::draw(pi, x, y);
45         MathFontSetChanger dummy(pi.base, name_.c_str());
46         xcell(0).draw(pi, x + 1, y);
47         drawMarkers(pi, x, y);
48 }
49
50
51 void MathFontInset::metricsT(TextMetricsInfo const & mi) const
52 {
53         xcell(0).metricsT(mi);
54         width_   = xcell(0).width();
55         ascent_  = xcell(0).ascent();
56         descent_ = xcell(0).descent();
57 }
58
59
60 void MathFontInset::drawT(TextPainter & pain, int x, int y) const
61 {
62         //lyxerr << "drawing font code: " << code_ << '\n';
63         xcell(0).drawT(pain, x, y);
64 }
65
66
67 void MathFontInset::write(WriteStream & os) const
68 {
69         os << '\\' << name_ << '{' << cell(0) << '}';
70 }
71
72
73 void MathFontInset::normalize(NormalStream & os) const
74 {
75         os << "[font_ " << name_ << " " << cell(0) << "]";
76 }
77
78
79 void MathFontInset::validate(LaTeXFeatures & features) const
80 {
81         // Make sure amssymb is put in preamble if Blackboard Bold or
82         // Fraktur used:
83         if (name_ == "mathfrak" || name_ == "mathbb")
84                 features.require("amssymb");
85 }
86
87
88 void MathFontInset::infoize(std::ostream & os) const
89 {
90         os << "Font: " << name_;
91 }