]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/InsetMathAMSArray.cpp
Fix bug 5802 (http://bugzilla.lyx.org/show_bug.cgi?id=5802)
[lyx.git] / src / mathed / InsetMathAMSArray.cpp
index b3894e9322f8e215de185a827df1ecccccad9036..9bcff0c41ffdd742b613262f4d969aecfdf9ce51 100644 (file)
@@ -3,26 +3,28 @@
  * 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 <config.h>
 
-#include "LaTeXFeatures.h"
 #include "InsetMathAMSArray.h"
+
+#include "LaTeXFeatures.h"
 #include "MathData.h"
 #include "MathStream.h"
-#include "MathStream.h"
 #include "MathSupport.h"
+#include "MetricsInfo.h"
 
 #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 {
@@ -83,16 +85,16 @@ void InsetMathAMSArray::metrics(MetricsInfo & mi, Dimension & dim) const
        ArrayChanger dummy(mi.base);
        InsetMathGrid::metrics(mi, dim);
        dim.wid += 14;
-       dim_ = dim;
 }
 
 
 void InsetMathAMSArray::draw(PainterInfo & pi, int x, int y) const
 {
-       int const yy = y - dim_.ascent();
+       Dimension const dim = dimension(*pi.base.bv);
+       int const yy = y - dim.ascent();
        // Drawing the deco after an ArrayChanger does not work
-       mathed_draw_deco(pi, x + 1, yy, 5, dim_.height(), from_ascii(name_left()));
-       mathed_draw_deco(pi, x + dim_.width() - 8, yy, 5, dim_.height(), from_ascii(name_right()));
+       mathed_draw_deco(pi, x + 1, yy, 5, dim.height(), from_ascii(name_left()));
+       mathed_draw_deco(pi, x + dim.width() - 8, yy, 5, dim.height(), from_ascii(name_right()));
        ArrayChanger dummy(pi.base);
        InsetMathGrid::drawWithMargin(pi, x, y, 6, 8);
 }
@@ -107,7 +109,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);
@@ -120,6 +122,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_ << '}';
@@ -144,7 +147,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);
 }