]> git.lyx.org Git - features.git/blob - src/mathed/InsetMathBoldSymbol.cpp
3cca1180fb589ad636dbcb4c471c4d0ab6144ff8
[features.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(Kind kind)
25         : InsetMathNest(1), kind_(kind)
26 {}
27
28
29 Inset * InsetMathBoldSymbol::clone() const
30 {
31         return new InsetMathBoldSymbol(*this);
32 }
33
34
35 void InsetMathBoldSymbol::metrics(MetricsInfo & mi, Dimension & dim) const
36 {
37         //FontSetChanger dummy(mi.base, "mathbf");
38         cell(0).metrics(mi, dim);
39         metricsMarkers(dim);
40         ++dim.wid;  // for 'double stroke'
41 }
42
43
44 void InsetMathBoldSymbol::draw(PainterInfo & pi, int x, int y) const
45 {
46         //FontSetChanger dummy(pi.base, "mathbf");
47         cell(0).draw(pi, x + 1, y);
48         cell(0).draw(pi, x + 2, y);
49         drawMarkers(pi, x, y);
50 }
51
52
53 void InsetMathBoldSymbol::metricsT(TextMetricsInfo const & mi, Dimension & /*dim*/) const
54 {
55         // FIXME: BROKEN!
56         Dimension dim;
57         cell(0).metricsT(mi, dim);
58 }
59
60
61 void InsetMathBoldSymbol::drawT(TextPainter & pain, int x, int y) const
62 {
63         cell(0).drawT(pain, x, y);
64 }
65
66
67 void InsetMathBoldSymbol::validate(LaTeXFeatures & features) const
68 {
69         InsetMathNest::validate(features);
70         if (kind_ == AMS_BOLD)
71                 features.require("amsbsy");
72         else
73                 features.require("bm");
74 }
75
76
77 void InsetMathBoldSymbol::write(WriteStream & os) const
78 {
79         bool brace = os.pendingBrace();
80         os.pendingBrace(false);
81         if (os.latex() && os.textMode()) {
82                 os << "\\ensuremath{";
83                 os.textMode(false);
84                 brace = true;
85         }
86         switch (kind_) {
87         case AMS_BOLD:
88                 os << "\\boldsymbol{" << cell(0) << "}";
89                 break;
90         case BM_BOLD:
91                 os << "\\bm{" << cell(0) << "}";
92                 break;
93         case BM_HEAVY:
94                 os << "\\hm{" << cell(0) << "}";
95                 break;
96         }
97         os.pendingBrace(brace);
98 }
99
100
101 void InsetMathBoldSymbol::infoize(odocstream & os) const
102 {
103         switch (kind_) {
104         case AMS_BOLD:
105                 os << "Boldsymbol ";
106                 break;
107         case BM_BOLD:
108                 os << "Boldsymbol (bm)";
109                 break;
110         case BM_HEAVY:
111                 os << "Heavysymbol (bm)";
112                 break;
113         }
114 }
115
116
117 } // namespace lyx