]> git.lyx.org Git - lyx.git/blob - src/mathed/InsetMathKern.cpp
* Inset and derivatives: insetName() -> name()
[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 #include "MathStream.h"
15 #include "MathStream.h"
16 #include "MathSupport.h"
17 #include "Dimension.h"
18
19
20 namespace lyx {
21
22 using std::string;
23 using std::auto_ptr;
24
25
26 InsetMathKern::InsetMathKern()
27 {
28         dim_.asc = 0;
29         dim_.des = 0;
30 }
31
32
33 InsetMathKern::InsetMathKern(Length const & w)
34         : wid_(w)
35 {
36         dim_.asc = 0;
37         dim_.des = 0;
38 }
39
40
41 InsetMathKern::InsetMathKern(docstring const & s)
42         : wid_(to_utf8(s))
43 {
44         dim_.asc = 0;
45         dim_.des = 0;
46 }
47
48
49 auto_ptr<Inset> InsetMathKern::doClone() const
50 {
51         return auto_ptr<Inset>(new InsetMathKern(*this));
52 }
53
54
55 bool InsetMathKern::metrics(MetricsInfo & mi, Dimension & dim) const
56 {
57         int wid_pixel = wid_.inPixels(0, mathed_char_width(mi.base.font, 'M'));
58         if (wid_pixel == dim_.wid)
59                 return false;
60         dim_.wid = wid_pixel;
61         dim = dim_;
62         return true;
63 }
64
65
66 void InsetMathKern::draw(PainterInfo &, int, int) const
67 {}
68
69
70 void InsetMathKern::write(WriteStream & os) const
71 {
72         os << "\\kern" << from_utf8(wid_.asLatexString()) << ' ';
73 }
74
75
76 void InsetMathKern::normalize(NormalStream & os) const
77 {
78         os << "[kern " << from_utf8(wid_.asLatexString()) << ']';
79 }
80
81
82 } // namespace lyx