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