]> git.lyx.org Git - lyx.git/blob - src/mathed/math_fontinset.C
split LyXText::rowlist_ into individual Paragraph::rows_ chunks
[lyx.git] / src / mathed / math_fontinset.C
1 #include <config.h>
2
3 #include "math_fontinset.h"
4 #include "math_mathmlstream.h"
5 #include "math_streamstr.h"
6 #include "math_support.h"
7 #include "math_parser.h"
8 #include "LaTeXFeatures.h"
9 #include "support/LOstream.h"
10 #include "textpainter.h"
11
12 using std::auto_ptr;
13
14
15 MathFontInset::MathFontInset(latexkeys const * key)
16         : MathNestInset(1), key_(key)
17 {}
18
19
20 auto_ptr<InsetBase> MathFontInset::clone() const
21 {
22         return auto_ptr<InsetBase>(new MathFontInset(*this));
23 }
24
25
26 MathInset::mode_type MathFontInset::currentMode() const
27 {
28         if (key_->extra == "mathmode")
29                 return MATH_MODE;
30         if (key_->extra == "textmode")
31                 return TEXT_MODE;
32         return UNDECIDED_MODE;
33 }
34
35
36 void MathFontInset::metrics(MetricsInfo & mi, Dimension & dim) const
37 {
38         FontSetChanger dummy(mi.base, key_->name.c_str());
39         cell(0).metrics(mi, dim_);
40         metricsMarkers(1);
41         dim = dim_;
42 }
43
44
45 void MathFontInset::draw(PainterInfo & pi, int x, int y) const
46 {
47         FontSetChanger dummy(pi.base, key_->name.c_str());
48         cell(0).draw(pi, x + 1, y);
49         drawMarkers(pi, x, y);
50 }
51
52
53 void MathFontInset::metricsT(TextMetricsInfo const & mi, Dimension & /*dim*/) const
54 {
55         cell(0).metricsT(mi, dim_);
56 }
57
58
59 void MathFontInset::drawT(TextPainter & pain, int x, int y) const
60 {
61         cell(0).drawT(pain, x, y);
62 }
63
64
65 string MathFontInset::name() const
66 {
67         return key_->name;
68 }
69
70
71 void MathFontInset::validate(LaTeXFeatures & features) const
72 {
73         MathNestInset::validate(features);
74         // Make sure amssymb is put in preamble if Blackboard Bold or
75         // Fraktur used:
76         if (key_->name == "mathfrak" || key_->name == "mathbb")
77                 features.require("amssymb");
78 }
79
80
81 void MathFontInset::infoize(std::ostream & os) const
82 {
83         os << "Font: " << key_->name;
84 }