]> git.lyx.org Git - lyx.git/blob - src/mathed/InsetMathBoldSymbol.cpp
Improve the list of equations
[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         metricsMarkers(mi, dim);
57         ++dim.wid;  // for 'double stroke'
58 }
59
60
61 void InsetMathBoldSymbol::draw(PainterInfo & pi, int x, int y) const
62 {
63         Changer dummy = pi.base.changeEnsureMath();
64         //Changer dummy = pi.base.changeFontSet("mathbf");
65         cell(0).draw(pi, x + 1, y);
66         cell(0).draw(pi, x + 2, y);
67         drawMarkers(pi, x, y);
68 }
69
70
71 void InsetMathBoldSymbol::metricsT(TextMetricsInfo const & mi, Dimension & /*dim*/) const
72 {
73         // FIXME: BROKEN!
74         Dimension dim;
75         cell(0).metricsT(mi, dim);
76 }
77
78
79 void InsetMathBoldSymbol::drawT(TextPainter & pain, int x, int y) const
80 {
81         cell(0).drawT(pain, x, y);
82 }
83
84
85 void InsetMathBoldSymbol::validate(LaTeXFeatures & features) const
86 {
87         InsetMathNest::validate(features);
88         if (kind_ == AMS_BOLD)
89                 features.require("amsbsy");
90         else
91                 features.require("bm");
92 }
93
94
95 void InsetMathBoldSymbol::write(WriteStream & os) const
96 {
97         MathEnsurer ensurer(os);
98         switch (kind_) {
99         case AMS_BOLD:
100                 os << "\\boldsymbol{" << cell(0) << "}";
101                 break;
102         case BM_BOLD:
103                 os << "\\bm{" << cell(0) << "}";
104                 break;
105         case BM_HEAVY:
106                 os << "\\hm{" << cell(0) << "}";
107                 break;
108         }
109 }
110
111
112 void InsetMathBoldSymbol::mathmlize(MathStream & os) const
113 {
114         os << "<mstyle mathvariant='bold'>" << cell(0) << "</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