]> git.lyx.org Git - lyx.git/blob - src/mathed/math_xarrowinset.C
float2string #4 (Spacing)
[lyx.git] / src / mathed / math_xarrowinset.C
1 /**
2  * \file math_xarrowinset.C
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 "math_xarrowinset.h"
14 #include "math_data.h"
15 #include "math_mathmlstream.h"
16 #include "math_streamstr.h"
17 #include "math_support.h"
18
19 using std::string;
20 using std::auto_ptr;
21
22
23 MathXArrowInset::MathXArrowInset(string const & name)
24         : MathFracbaseInset(), name_(name)
25 {}
26
27
28 auto_ptr<InsetBase> MathXArrowInset::doClone() const
29 {
30         return auto_ptr<InsetBase>(new MathXArrowInset(*this));
31 }
32
33
34 void MathXArrowInset::metrics(MetricsInfo & mi, Dimension & dim) const
35 {
36         ScriptChanger dummy(mi.base);
37         cell(0).metrics(mi);
38         cell(1).metrics(mi);
39         dim.wid = std::max(cell(0).width(), cell(1).width()) + 10;
40         dim.asc = cell(0).height() + 10;
41         dim.des = cell(1).height();
42         metricsMarkers(dim);
43         dim_ = dim;
44 }
45
46
47 void MathXArrowInset::draw(PainterInfo & pi, int x, int y) const
48 {
49         ScriptChanger dummy(pi.base);
50         cell(0).draw(pi, x + 5, y - 10);
51         cell(1).draw(pi, x + 5, y + cell(1).height());
52         mathed_draw_deco(pi, x + 1, y - 7, width() - 2, 5, name_);
53         drawMarkers(pi, x, y);
54 }
55
56
57 void MathXArrowInset::write(WriteStream & os) const
58 {
59         os << '\\' << name_;
60         if (cell(1).size())
61                 os << '[' << cell(1) << ']';
62         os << '{' << cell(0) << '}';
63 }
64
65
66 void MathXArrowInset::normalize(NormalStream & os) const
67 {
68         os << "[xarrow " << name_ << ' ' <<  cell(0) << ' ' << cell(1) << ']';
69 }