]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/InsetMathXYMatrix.C
Allows editing when the Prefs dialog is opened; fix bug 3140:
[lyx.git] / src / mathed / InsetMathXYMatrix.C
index 0e39a8fbc9b50d58d0220722edca1c0c635dd7f5..cbeba96583ae52465fb65c9af7bd8a46726f2f4f 100644 (file)
@@ -11,7 +11,6 @@
 #include <config.h>
 
 #include "InsetMathXYMatrix.h"
-#include "MathMLStream.h"
 #include "MathStream.h"
 
 #include "LaTeXFeatures.h"
@@ -21,8 +20,8 @@
 namespace lyx {
 
 
-InsetMathXYMatrix::InsetMathXYMatrix()
-       : InsetMathGrid(1, 1)
+InsetMathXYMatrix::InsetMathXYMatrix(LyXLength const & s, char c)
+       : InsetMathGrid(1, 1), spacing_(s), spacing_code_(c)
 {}
 
 
@@ -44,25 +43,58 @@ int InsetMathXYMatrix::rowsep() const
 }
 
 
-void InsetMathXYMatrix::metrics(MetricsInfo & mi, Dimension & dim) const
+bool InsetMathXYMatrix::metrics(MetricsInfo & mi, Dimension & dim) const
 {
        if (mi.base.style == LM_ST_DISPLAY)
                mi.base.style = LM_ST_TEXT;
        InsetMathGrid::metrics(mi, dim);
+       if (dim_ == dim)
+               return false;
+       dim_ = dim;
+       return true;
 }
 
 
 void InsetMathXYMatrix::write(WriteStream & os) const
 {
-       os << "\\xymatrix{";
+       os << "\\xymatrix";
+       switch (spacing_code_) {
+       case 'R':
+       case 'C':
+       case 'M':
+       case 'W':
+       case 'H':
+       case 'L':
+               os << '@' << spacing_code_ << '='
+                  << from_ascii(spacing_.asLatexString());
+               break;
+       default:
+               if (!spacing_.empty())
+                       os << "@=" << from_ascii(spacing_.asLatexString());
+       }
+       os << '{';
        InsetMathGrid::write(os);
        os << "}\n";
 }
 
 
-void InsetMathXYMatrix::infoize(std::ostream & os) const
+void InsetMathXYMatrix::infoize(odocstream & os) const
 {
        os << "xymatrix ";
+       switch (spacing_code_) {
+       case 'R':
+       case 'C':
+       case 'M':
+       case 'W':
+       case 'H':
+       case 'L':
+               os << spacing_code_ << ' '
+                  << from_ascii(spacing_.asLatexString()) << ' ';
+               break;
+       default:
+               if (!spacing_.empty())
+                       os << from_ascii(spacing_.asLatexString()) << ' ';
+       }
        InsetMathGrid::infoize(os);
 }
 
@@ -83,4 +115,11 @@ void InsetMathXYMatrix::maple(MapleStream & os) const
 }
 
 
+void InsetMathXYMatrix::validate(LaTeXFeatures & features) const
+{
+       features.require("xy");
+       InsetMathGrid::validate(features);
+}
+
+
 } // namespace lyx