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 
InsetMathKern()25 InsetMathKern::InsetMathKern()
26 {
27 }
28 
29 
InsetMathKern(Length const & w)30 InsetMathKern::InsetMathKern(Length const & w)
31 	: wid_(w)
32 {
33 }
34 
35 
InsetMathKern(docstring const & s)36 InsetMathKern::InsetMathKern(docstring const & s)
37 	: wid_(to_utf8(s))
38 {
39 }
40 
41 
clone() const42 Inset * InsetMathKern::clone() const
43 {
44 	return new InsetMathKern(*this);
45 }
46 
47 
metrics(MetricsInfo & mi,Dimension & dim) const48 void InsetMathKern::metrics(MetricsInfo & mi, Dimension & dim) const
49 {
50 	dim.asc = 0;
51 	dim.des = 0;
52 	dim.wid = wid_.inPixels(mi.base);
53 }
54 
55 
draw(PainterInfo &,int,int) const56 void InsetMathKern::draw(PainterInfo &, int, int) const
57 {}
58 
59 
write(WriteStream & os) const60 void InsetMathKern::write(WriteStream & 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 
normalize(NormalStream & os) const71 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 
infoize2(odocstream & os) const80 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
89