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