2 * \file InsetMathTabular.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 "InsetMathTabular.h"
16 #include "MathStream.h"
17 #include "MathStream.h"
19 #include "MetricsInfo.h"
21 #include "support/lstrings.h"
27 InsetMathTabular::InsetMathTabular(Buffer * buf, docstring const & name, int m,
29 : InsetMathGrid(buf, m, n), name_(name)
33 InsetMathTabular::InsetMathTabular(Buffer * buf, docstring const & name, int m,
34 int n, char valign, docstring const & halign)
35 : InsetMathGrid(buf, m, n, valign, halign), name_(name)
40 Inset * InsetMathTabular::clone() const
42 return new InsetMathTabular(*this);
46 void InsetMathTabular::metrics(MetricsInfo & mi, Dimension & dim) const
48 Changer dummy = mi.base.changeFontSet("textnormal");
49 InsetMathGrid::metrics(mi, dim);
54 Dimension const InsetMathTabular::dimension(BufferView const & bv) const
56 Dimension dim = InsetMathGrid::dimension(bv);
62 void InsetMathTabular::draw(PainterInfo & pi, int x, int y) const
64 Changer dummy = pi.base.changeFontSet("textnormal");
65 InsetMathGrid::drawWithMargin(pi, x, y, 4, 2);
69 void InsetMathTabular::write(WriteStream & os) const
71 ModeSpecifier specifier(os, TEXT_MODE);
75 os << "\\begin{" << name_ << '}';
76 bool open = os.startOuterRow();
78 char const v = verticalAlignment();
79 if (v == 't' || v == 'b')
80 os << '[' << v << ']';
81 os << '{' << horizontalAlignments() << "}\n";
83 InsetMathGrid::write(os);
87 os << "\\end{" << name_ << '}';
90 // adding a \n here is bad if the tabular is the last item
95 void InsetMathTabular::infoize(odocstream & os) const
97 docstring name = name_;
98 name[0] = support::uppercase(name[0]);
103 void InsetMathTabular::normalize(NormalStream & os) const
105 os << '[' << name_ << ' ';
106 InsetMathGrid::normalize(os);
111 void InsetMathTabular::maple(MapleStream & os) const
114 InsetMathGrid::maple(os);