2 * \file InsetMathXArrow.cpp
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
8 * Full author contact details are available in file CREDITS.
13 #include "InsetMathXArrow.h"
15 #include "MathStream.h"
16 #include "MathStream.h"
17 #include "MathSupport.h"
19 #include "LaTeXFeatures.h"
25 InsetMathXArrow::InsetMathXArrow(docstring const & name)
26 : InsetMathFracBase(), name_(name)
30 Inset * InsetMathXArrow::clone() const
32 return new InsetMathXArrow(*this);
36 bool InsetMathXArrow::metrics(MetricsInfo & mi, Dimension & dim) const
38 ScriptChanger dummy(mi.base);
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();
52 void InsetMathXArrow::draw(PainterInfo & pi, int x, int y) const
54 ScriptChanger dummy(pi.base);
55 cell(0).draw(pi, x + 5, y - 10);
56 cell(1).draw(pi, x + 5, y + cell(1).height());
57 mathed_draw_deco(pi, x + 1, y - 7, width() - 2, 5, name_);
58 drawMarkers(pi, x, y);
62 void InsetMathXArrow::write(WriteStream & os) const
66 os << '[' << cell(1) << ']';
67 os << '{' << cell(0) << '}';
71 void InsetMathXArrow::normalize(NormalStream & os) const
73 os << "[xarrow " << name_ << ' ' << cell(0) << ' ' << cell(1) << ']';
77 void InsetMathXArrow::validate(LaTeXFeatures & features) const
79 features.require("amsmath");
80 InsetMathNest::validate(features);