]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/InsetMathAMSArray.cpp
Routines for calculating numerical labels for BibTeX citations.
[lyx.git] / src / mathed / InsetMathAMSArray.cpp
index cfe9a179ae11d5958d8e8230f68bbd24285452ba..b9efc3d0e2853631d2c20c98e3cf0e97312cdb60 100644 (file)
@@ -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.
  */
 
 #include "FuncRequest.h"
 #include "FuncStatus.h"
-#include "gettext.h"
+#include "support/gettext.h"
 
 #include "support/lstrings.h"
-#include "support/std_ostream.h"
+
+#include <ostream>
 
 
 namespace lyx {
@@ -31,13 +32,14 @@ namespace lyx {
 using support::bformat;
 
 
-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)
 {}
 
 
@@ -87,14 +89,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);
@@ -116,7 +110,7 @@ bool InsetMathAMSArray::getStatus(Cursor & cur, FuncRequest const & cmd,
                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);
+                       flag.setEnabled(false);
                        return true;
                }
                return InsetMathGrid::getStatus(cur, cmd, flag);
@@ -129,6 +123,7 @@ bool InsetMathAMSArray::getStatus(Cursor & cur, FuncRequest const & cmd,
 
 void InsetMathAMSArray::write(WriteStream & os) const
 {
+       MathEnsurer ensurer(os);
        os << "\\begin{" << name_ << '}';
        InsetMathGrid::write(os);
        os << "\\end{" << name_ << '}';
@@ -153,7 +148,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);
 }