X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fmathed%2FInsetMathAMSArray.cpp;h=e615e1dff886e7cf2e997d397f73457a5300d91c;hb=704328d3488c75733ddeb9ad5439b1907e323e39;hp=a8fdf68346e110ff1322dc954d10ae6229fc6855;hpb=9d0ea8aeff32833a90b3fe64df0c5518a9e241be;p=lyx.git diff --git a/src/mathed/InsetMathAMSArray.cpp b/src/mathed/InsetMathAMSArray.cpp index a8fdf68346..e615e1dff8 100644 --- a/src/mathed/InsetMathAMSArray.cpp +++ b/src/mathed/InsetMathAMSArray.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. */ @@ -24,21 +24,24 @@ #include "support/lstrings.h" +#include #include -namespace lyx { +using namespace std; +using namespace lyx::support; -using support::bformat; +namespace lyx { -InsetMathAMSArray::InsetMathAMSArray(docstring const & name, int m, int n) - : InsetMathGrid(m, n), name_(name) +InsetMathAMSArray::InsetMathAMSArray(Buffer * buf, docstring const & name, + int m, int n) + : InsetMathGrid(buf, m, n), name_(name) {} -InsetMathAMSArray::InsetMathAMSArray(docstring const & name) - : InsetMathGrid(1, 1), name_(name) +InsetMathAMSArray::InsetMathAMSArray(Buffer * buf, docstring const & name) + : InsetMathGrid(buf, 1, 1), name_(name) {} @@ -88,14 +91,6 @@ void InsetMathAMSArray::metrics(MetricsInfo & mi, Dimension & dim) const } -Dimension const InsetMathAMSArray::dimension(BufferView const & bv) const -{ - Dimension dim = InsetMathGrid::dimension(bv); - dim.wid += 14; - return dim; -} - - void InsetMathAMSArray::draw(PainterInfo & pi, int x, int y) const { Dimension const dim = dimension(*pi.base.bv); @@ -111,25 +106,33 @@ void InsetMathAMSArray::draw(PainterInfo & pi, int x, int y) const bool InsetMathAMSArray::getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus & flag) const { - switch (cmd.action) { - case LFUN_TABULAR_FEATURE: { - docstring const & s = cmd.argument(); + switch (cmd.action()) { + case LFUN_INSET_MODIFY: { + istringstream is(to_utf8(cmd.argument())); + string s; + is >> s; + if (s != "tabular") + break; + is >> s; if (s == "add-vline-left" || s == "add-vline-right") { flag.message(bformat( - from_utf8(N_("Can't add vertical grid lines in '%1$s'")), name_)); - flag.enabled(false); + from_utf8(N_("Can't add vertical grid lines in '%1$s'")), + name_)); + flag.setEnabled(false); return true; } - return InsetMathGrid::getStatus(cur, cmd, flag); + break; } default: - return InsetMathGrid::getStatus(cur, cmd, flag); + break; } + return InsetMathGrid::getStatus(cur, cmd, flag); } void InsetMathAMSArray::write(WriteStream & os) const { + MathEnsurer ensurer(os); os << "\\begin{" << name_ << '}'; InsetMathGrid::write(os); os << "\\end{" << name_ << '}'; @@ -154,7 +157,12 @@ void InsetMathAMSArray::normalize(NormalStream & os) const void InsetMathAMSArray::validate(LaTeXFeatures & features) const { - features.require("amsmath"); + if (name_ == "CD") + // amscd is independent of amsmath although it is part of + // the amsmath bundle + features.require("amscd"); + else + features.require("amsmath"); InsetMathGrid::validate(features); }