]> git.lyx.org Git - lyx.git/blob - src/mathed/InsetMathBoldSymbol.cpp
Merge branch 'master' of git.lyx.org:lyx
[lyx.git] / src / mathed / InsetMathBoldSymbol.cpp
1 /**
2  * \file InsetMathBoldSymbol.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 "InsetMathBoldSymbol.h"
14
15 #include "MathStream.h"
16 #include "MathData.h"
17 #include "LaTeXFeatures.h"
18
19 #include <ostream>
20
21
22 namespace lyx {
23
24 InsetMathBoldSymbol::InsetMathBoldSymbol(Buffer * buf, Kind kind)
25         : InsetMathNest(buf, 1), kind_(kind)
26 {}
27
28
29 Inset * InsetMathBoldSymbol::clone() const
30 {
31         return new InsetMathBoldSymbol(*this);
32 }
33
34
35 docstring InsetMathBoldSymbol::name() const
36 {
37         switch (kind_) {
38         case AMS_BOLD:
39                 return from_ascii("boldsymbol");
40         case BM_BOLD:
41                 return from_ascii("bm");
42         case BM_HEAVY:
43                 return from_ascii("hm");
44         }
45         // avoid compiler warning
46         return docstring();
47 }
48
49
50 void InsetMathBoldSymbol::metrics(MetricsInfo & mi, Dimension & dim) const
51 {
52         //FontSetChanger dummy(mi.base, "mathbf");
53         cell(0).metrics(mi, dim);
54         metricsMarkers(dim);
55         ++dim.wid;  // for 'double stroke'
56 }
57
58
59 void InsetMathBoldSymbol::draw(PainterInfo & pi, int x, int y) const
60 {
61         //FontSetChanger dummy(pi.base, "mathbf");
62         cell(0).draw(pi, x + 1, y);
63         cell(0).draw(pi, x + 2, y);
64         drawMarkers(pi, x, y);
65 }
66
67
68 void InsetMathBoldSymbol::metricsT(TextMetricsInfo const & mi, Dimension & /*dim*/) const
69 {
70         // FIXME: BROKEN!
71         Dimension dim;
72         cell(0).metricsT(mi, dim);
73 }
74
75
76 void InsetMathBoldSymbol::drawT(TextPainter & pain, int x, int y) const
77 {
78         cell(0).drawT(pain, x, y);
79 }
80
81
82 void InsetMathBoldSymbol::validate(LaTeXFeatures & features) const
83 {
84         InsetMathNest::validate(features);
85         if (kind_ == AMS_BOLD)
86                 features.require("amsbsy");
87         else
88                 features.require("bm");
89 }
90
91
92 void InsetMathBoldSymbol::write(WriteStream & os) const
93 {
94         MathEnsurer ensurer(os);
95         switch (kind_) {
96         case AMS_BOLD:
97                 os << "\\boldsymbol{" << cell(0) << "}";
98                 break;
99         case BM_BOLD:
100                 os << "\\bm{" << cell(0) << "}";
101                 break;
102         case BM_HEAVY:
103                 os << "\\hm{" << cell(0) << "}";
104                 break;
105         }
106 }
107
108
109 void InsetMathBoldSymbol::mathmlize(MathStream & os) const
110 {
111         os << "<mstyle mathvariant='bold'>" << cell(0) << "</mstyle>";
112 }
113
114
115 void InsetMathBoldSymbol::htmlize(HtmlStream & os) const
116 {
117         os << MTag("b") << cell(0) << ETag("b");
118 }
119
120
121 void InsetMathBoldSymbol::infoize(odocstream & os) const
122 {
123         switch (kind_) {
124         case AMS_BOLD:
125                 os << "Boldsymbol ";
126                 break;
127         case BM_BOLD:
128                 os << "Boldsymbol (bm)";
129                 break;
130         case BM_HEAVY:
131                 os << "Heavysymbol (bm)";
132                 break;
133         }
134 }
135
136
137 } // namespace lyx