A bit more re-organization.
[lyx.git] / src / mathed / InsetMathXArrow.cpp
blobd9579ba5cf5996ec452626d4e4103746076dded5
1 /**
2 * \file InsetMathXArrow.cpp
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author André Pönitz
8 * Full author contact details are available in file CREDITS.
9 */
11 #include <config.h>
13 #include "InsetMathXArrow.h"
14 #include "MathData.h"
15 #include "MathStream.h"
16 #include "MathStream.h"
17 #include "MathSupport.h"
19 #include "LaTeXFeatures.h"
21 using namespace std;
23 namespace lyx {
26 InsetMathXArrow::InsetMathXArrow(Buffer * buf, docstring const & name)
27 : InsetMathFracBase(buf), name_(name)
31 Inset * InsetMathXArrow::clone() const
33 return new InsetMathXArrow(*this);
37 void InsetMathXArrow::metrics(MetricsInfo & mi, Dimension & dim) const
39 ScriptChanger dummy(mi.base);
40 Dimension dim0;
41 cell(0).metrics(mi, dim0);
42 Dimension dim1;
43 cell(1).metrics(mi, dim1);
44 dim.wid = max(dim0.width(), dim1.width()) + 10;
45 dim.asc = dim0.height() + 10;
46 dim.des = dim1.height();
47 metricsMarkers(dim);
51 void InsetMathXArrow::draw(PainterInfo & pi, int x, int y) const
53 ScriptChanger dummy(pi.base);
54 cell(0).draw(pi, x + 5, y - 10);
55 Dimension const & dim1 = cell(1).dimension(*pi.base.bv);
56 cell(1).draw(pi, x + 5, y + dim1.height());
57 Dimension const dim = dimension(*pi.base.bv);
58 mathed_draw_deco(pi, x + 1, y - 7, dim.wid - 2, 5, name_);
59 drawMarkers(pi, x, y);
63 void InsetMathXArrow::write(WriteStream & os) const
65 MathEnsurer ensurer(os);
66 os << '\\' << name_;
67 if (cell(1).size())
68 os << '[' << cell(1) << ']';
69 os << '{' << cell(0) << '}';
73 void InsetMathXArrow::normalize(NormalStream & os) const
75 os << "[xarrow " << name_ << ' ' << cell(0) << ' ' << cell(1) << ']';
79 void InsetMathXArrow::validate(LaTeXFeatures & features) const
81 features.require("amsmath");
82 InsetMathNest::validate(features);
86 } // namespace lyx