]> git.lyx.org Git - lyx.git/blob - src/mathed/InsetMathKern.cpp
f99a210a9d398a76d821424ec3796392959e8c54
[lyx.git] / src / mathed / InsetMathKern.cpp
1 /**
2  * \file InsetMathKern.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 "InsetMathKern.h"
14
15 #include "MathStream.h"
16 #include "MathSupport.h"
17
18 #include "Dimension.h"
19 #include "MetricsInfo.h"
20
21 #include "support/docstring.h"
22
23 namespace lyx {
24
25 InsetMathKern::InsetMathKern()
26 {
27 }
28
29
30 InsetMathKern::InsetMathKern(Length const & w)
31         : wid_(w)
32 {
33 }
34
35
36 InsetMathKern::InsetMathKern(docstring const & s)
37         : wid_(to_utf8(s))
38 {
39 }
40
41
42 Inset * InsetMathKern::clone() const
43 {
44         return new InsetMathKern(*this);
45 }
46
47
48 void InsetMathKern::metrics(MetricsInfo & mi, Dimension & dim) const
49 {
50         dim.asc = 0;
51         dim.des = 0;
52         dim.wid = mi.base.inPixels(wid_);
53 }
54
55
56 void InsetMathKern::draw(PainterInfo &, int, int) const
57 {}
58
59
60 void InsetMathKern::write(TeXMathStream & os) const
61 {
62         if (wid_.empty())
63                 os << "\\kern" << ' ';
64         else if (wid_.unit() == Length::MU)
65                 os << "\\mkern" << from_utf8(wid_.asLatexString()) << ' ';
66         else
67                 os << "\\kern" << from_utf8(wid_.asLatexString()) << ' ';
68 }
69
70
71 void InsetMathKern::normalize(NormalStream & os) const
72 {
73         if (wid_.empty())
74                 os << "[kern]";
75         else
76                 os << "[kern " << from_utf8(wid_.asLatexString()) << ']';
77 }
78
79
80 void InsetMathKern::infoize2(odocstream & os) const
81 {
82         os << "Kern";
83         if (!wid_.empty())
84                 os << ": " << from_utf8(wid_.asLatexString());
85 }
86
87
88 } // namespace lyx