]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/xforms/FormMathsMatrix.C
Bugfixes: checkboxes to radiobuttons (from J�rgen S) and remove a little
[lyx.git] / src / frontends / xforms / FormMathsMatrix.C
index f8e95094417fa2392914f8b43495d929c72bfc7c..336321ede161e998013b09e901447f902c84088e 100644 (file)
 #pragma implementation
 #endif
 
+#include <algorithm>
+
 #include "FormMathsMatrix.h"
 #include "form_maths_matrix.h"
 #include "Dialogs.h"
 #include "LyXView.h"
-#include "lyxfunc.h"
 #include "Lsstream.h"
+#include "lyxfunc.h"
+#include "support/LAssert.h"
+#include "support/lyxalgo.h" // lyx::count
+
+#ifndef CXX_GLOBAL_CSTD
+using std::strlen;
+#endif
+
 
 static char h_align_str[80] = "c";
 static char v_align_c[] = "tcb";
 
-extern "C" int C_FormMathsMatrixAlignFilter(FL_OBJECT * ob, char const *,
-                                           char const * cur, int c)
-{
-       Assert(ob);
-       FormMathsMatrix * pre = static_cast<FormMathsMatrix *>(ob->u_vdata);
-       Assert(pre);
-       return pre->AlignFilter(cur, c);
+
+extern "C" {
+       
+       static
+       int C_FormMathsMatrixAlignFilter(FL_OBJECT * ob, char const *,
+                                        char const * cur, int c)
+       {
+               lyx::Assert(ob);
+               FormMathsMatrix * pre =
+                       static_cast<FormMathsMatrix *>(ob->u_vdata);
+               lyx::Assert(pre);
+               return pre->AlignFilter(cur, c);
+       }
+       
 }
 
 
 FormMathsMatrix::FormMathsMatrix(LyXView * lv, Dialogs * d,
                               FormMathsPanel const & p)
-       : FormMathsSub(lv, d, p, _("Maths Matrix"))
+       : FormMathsSub(lv, d, p, _("Maths Matrix"), false)
 {}
 
 
@@ -78,10 +94,10 @@ void FormMathsMatrix::apply()
        int const nx = int(fl_get_slider_value(dialog_->slider_columns) + 0.5);
        int const ny = int(fl_get_slider_value(dialog_->slider_rows) + 0.5);
  
-       std::ostringstream ost;
-       ost << nx << ' ' << ny << ' ' << c << sh;
+       ostringstream ost;
+       ost << nx << ' ' << ny << ' ' << c << ' ' << sh;
  
-       lv_->getLyXFunc()->Dispatch(LFUN_INSERT_MATRIX, ost.str().c_str());
+       lv_->getLyXFunc()->dispatch(LFUN_INSERT_MATRIX, ost.str().c_str());
 }
 
 bool FormMathsMatrix::input(FL_OBJECT * ob, long)
@@ -103,12 +119,15 @@ bool FormMathsMatrix::input(FL_OBJECT * ob, long)
 
 int FormMathsMatrix::AlignFilter(char const * cur, int c)
 {
-       int n = int(fl_get_slider_value(dialog_->slider_columns)+0.5) -
-               int(strlen(cur));
+       size_t len = strlen(cur);
+       
+       int const n = int(fl_get_slider_value(dialog_->slider_columns) + 0.5) -
+               int(len) +
+               int(lyx::count(cur, cur + len, '|'));
        if (n < 0)
                return FL_INVALID;
 
-       if (c == 'c' || c == 'l' || c == 'r'
+       if (c == 'c' || c == 'l' || c == 'r' || c == '|')
                return FL_VALID;
  
        return FL_INVALID;