]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/InsetMathSubstack.cpp
add busy.gif to resources (in line with cmake)
[lyx.git] / src / mathed / InsetMathSubstack.cpp
index bea27a0231ae2e00cbb88bf7546e82b09fe93bb4..fccdf7b3c3aacedeaeaad18141d0819d69159e02 100644 (file)
@@ -3,34 +3,36 @@
  * 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 "InsetMathSubstack.h"
+
+#include "LaTeXFeatures.h"
 #include "MathData.h"
 #include "MathStream.h"
-#include "support/std_ostream.h"
 
 #include "FuncRequest.h"
 #include "FuncStatus.h"
-#include "gettext.h"
+#include "support/gettext.h"
 
 #include "support/lstrings.h"
 
+#include <ostream>
+
+using namespace std;
 
 namespace lyx {
 
 using support::bformat;
 
-using std::string;
 
-InsetMathSubstack::InsetMathSubstack()
-       : InsetMathGrid(1, 1)
+InsetMathSubstack::InsetMathSubstack(Buffer * buf)
+       : InsetMathGrid(buf, 1, 1)
 {}
 
 
@@ -60,22 +62,38 @@ void InsetMathSubstack::draw(PainterInfo & pi, int x, int y) const
 bool InsetMathSubstack::getStatus(Cursor & cur, FuncRequest const & cmd,
                FuncStatus & flag) const
 {
-       switch (cmd.action) {
-       case LFUN_TABULAR_FEATURE: {
+       switch (cmd.action()) {
+       case LFUN_INSET_MODIFY: {
+               istringstream is(to_utf8(cmd.argument()));
+               string s;
+               is >> s;
+               if (s != "tabular")
+                       break;
+               is >> s;
                string const name = "substack";
-               docstring const & s = cmd.argument();
                if (s == "add-vline-left" || s == "add-vline-right") {
                        flag.message(bformat(
                                from_utf8(N_("Can't add vertical grid lines in '%1$s'")),
                                from_utf8(name)));
-                       flag.enabled(false);
+                       flag.setEnabled(false);
+                       return true;
+               }
+               // in contrary to \subaray, the columns in \substack
+               // are always centered and this cannot be changed
+               if (s == "align-left" || s == "align-right") {
+                       flag.message(bformat(
+                               from_utf8(N_("Can't change horizontal alignment in '%1$s'")),
+                               from_utf8(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);
 }
 
 
@@ -87,6 +105,7 @@ void InsetMathSubstack::infoize(odocstream & os) const
 
 void InsetMathSubstack::write(WriteStream & os) const
 {
+       MathEnsurer ensurer(os);
        os << "\\substack{";
        InsetMathGrid::write(os);
        os << "}\n";
@@ -109,9 +128,25 @@ void InsetMathSubstack::maple(MapleStream & os) const
 }
 
 
+void InsetMathSubstack::htmlize(HtmlStream & os) const
+{
+       os << MTag("span", "class='substack'");
+       for (row_type row = 0; row < nrows(); ++row) 
+               os << MTag("span") << cell(index(row, 0)) << ETag("span");
+       os << ETag("span");
+}
+
+       
 void InsetMathSubstack::validate(LaTeXFeatures & features) const
 {
-       features.require("amsmath");
+       if (features.runparams().isLaTeX())
+               features.require("amsmath");
+       else if (features.runparams().math_flavor == OutputParams::MathAsHTML)
+               features.addPreambleSnippet("<style type=\"text/css\">\n"
+                       "span.substack{display: inline-block; vertical-align: middle; text-align:center; font-size: 75%;}\n"
+                       "span.substack span{display: block;}\n"
+                       "</style>");
+       
        InsetMathGrid::validate(features);
 }