X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fmathed%2FInsetMathTabular.cpp;h=e4123a565509cd6dd0b96875a42084a0e102104d;hb=3a544072a522845b192594dd2ab11fcb1fc80eeb;hp=2e17fb401238fe2604cbb70da412b44be3b3fe43;hpb=ed858d73e57ce7aa89e38c1bc4d799362edb0227;p=lyx.git diff --git a/src/mathed/InsetMathTabular.cpp b/src/mathed/InsetMathTabular.cpp index 2e17fb4012..e4123a5655 100644 --- a/src/mathed/InsetMathTabular.cpp +++ b/src/mathed/InsetMathTabular.cpp @@ -3,7 +3,7 @@ * This file is part of LyX, the document processor. * Licence details can be found in the file COPYING. * - * \author André Pönitz + * \author André Pönitz * * Full author contact details are available in file CREDITS. */ @@ -11,34 +11,31 @@ #include #include "InsetMathTabular.h" + #include "MathData.h" #include "MathStream.h" #include "MathStream.h" -#include "support/lstrings.h" -#include "support/std_ostream.h" +#include "MetricsInfo.h" -#include +#include "support/lstrings.h" +#include namespace lyx { -InsetMathTabular::InsetMathTabular(docstring const & name, int m, int n) - : InsetMathGrid(m, n), name_(name) +InsetMathTabular::InsetMathTabular(Buffer * buf, docstring const & name, int m, + int n) + : InsetMathGrid(buf, m, n), name_(name) {} -InsetMathTabular::InsetMathTabular(docstring const & name, int m, int n, - char valign, docstring const & halign) - : InsetMathGrid(m, n, valign, halign), name_(name) +InsetMathTabular::InsetMathTabular(Buffer * buf, docstring const & name, int m, + int n, char valign, docstring const & halign) + : InsetMathGrid(buf, m, n, valign, halign), name_(name) {} -InsetMathTabular::InsetMathTabular(docstring const & name, char valign, - docstring const & halign) - : InsetMathGrid(valign, halign), name_(name) -{} - Inset * InsetMathTabular::clone() const { @@ -46,40 +43,41 @@ Inset * InsetMathTabular::clone() const } -bool InsetMathTabular::metrics(MetricsInfo & mi, Dimension & dim) const +void InsetMathTabular::metrics(MetricsInfo & mi, Dimension & dim) const { - FontSetChanger dummy(mi.base, "textnormal"); + Changer dummy = mi.base.changeFontSet("textnormal"); InsetMathGrid::metrics(mi, dim); - dim.wid += 6; - if (dim_ == dim) - return false; - dim_ = dim; - return true; } void InsetMathTabular::draw(PainterInfo & pi, int x, int y) const { - FontSetChanger dummy(pi.base, "textnormal"); - InsetMathGrid::drawWithMargin(pi, x, y, 4, 2); + Changer dummy = pi.base.changeFontSet("textnormal"); + InsetMathGrid::draw(pi, x, y); } void InsetMathTabular::write(WriteStream & os) const { + ModeSpecifier specifier(os, TEXT_MODE); + if (os.fragile()) os << "\\protect"; os << "\\begin{" << name_ << '}'; + bool open = os.startOuterRow(); - if (v_align_ == 't' || v_align_ == 'b') - os << '[' << char(v_align_) << ']'; - os << '{' << halign() << "}\n"; + char const v = verticalAlignment(); + if (v == 't' || v == 'b') + os << '[' << v << ']'; + os << '{' << horizontalAlignments() << "}\n"; InsetMathGrid::write(os); if (os.fragile()) os << "\\protect"; os << "\\end{" << name_ << '}'; + if (open) + os.startOuterRow(); // adding a \n here is bad if the tabular is the last item // in an \eqnarray... }