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