]> git.lyx.org Git - features.git/blobdiff - src/frontends/xforms/FormMathsMatrix.C
change "support/std_sstream.h" to <sstream>
[features.git] / src / frontends / xforms / FormMathsMatrix.C
index 2e1eda7ea2bee1f625e69ba36599b0bedd71385f..6e02d401479151e61a84c46f7d848e89f116d105 100644 (file)
@@ -8,58 +8,59 @@
  * \author John Levon
  * \author Angus Leeming
  *
- * Full author contact details are available in file CREDITS
+ * Full author contact details are available in file CREDITS.
  */
 
 #include <config.h>
 
-#ifdef __GNUG__
-#pragma implementation
-#endif
-
 #include "FormMathsMatrix.h"
 #include "forms/form_maths_matrix.h"
 #include "ControlMath.h"
+
 #include "xformsBC.h"
 
-#include "support/LAssert.h"
+#include "controllers/ButtonController.h"
+
 #include "support/lyxalgo.h" // lyx::count
 
-#include "Lsstream.h"
+#include "lyx_forms.h"
+
+#include <sstream>
 
-#include FORMS_H_LOCATION
 
-#include <algorithm>
+using std::ostringstream;
 
 #ifndef CXX_GLOBAL_CSTD
 using std::strlen;
 #endif
 
+namespace lyx {
+namespace frontend {
 
-static char h_align_str[80] = "c";
-static char v_align_c[] = "tcb";
+namespace {
 
+char h_align_str[80] = "c";
+char v_align_c[] = "tcb";
 
-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);
-       }
 
+extern "C"
+int C_FormMathsMatrixAlignFilter(FL_OBJECT * ob, char const *,
+                                char const * cur, int c)
+{
+       BOOST_ASSERT(ob);
+       FormMathsMatrix * pre =
+               static_cast<FormMathsMatrix *>(ob->u_vdata);
+       BOOST_ASSERT(pre);
+       return pre->AlignFilter(cur, c);
 }
 
+} // namespace anon
+
 
-typedef FormCB<ControlMathSub, FormDB<FD_maths_matrix> > base_class;
+typedef FormController<ControlMath, FormView<FD_maths_matrix> > base_class;
 
-FormMathsMatrix::FormMathsMatrix()
-       : base_class(_("Maths Matrix"), false)
+FormMathsMatrix::FormMathsMatrix(Dialog & parent)
+       : base_class(parent, _("Math Matrix"), false)
 {}
 
 
@@ -67,7 +68,8 @@ void FormMathsMatrix::build()
 {
        dialog_.reset(build_maths_matrix(this));
 
-       fl_addto_choice(dialog_->choice_valign, _("Top | Center | Bottom"));
+       fl_addto_choice(dialog_->choice_valign,
+                       _("Top | Middle | Bottom").c_str());
        fl_set_choice(dialog_->choice_valign, 2);
        fl_set_input(dialog_->input_halign, h_align_str);
        dialog_->input_halign->u_vdata = this;
@@ -75,14 +77,14 @@ void FormMathsMatrix::build()
                            C_FormMathsMatrixAlignFilter);
        setPrehandler(dialog_->input_halign);
 
-       bc().setOK(dialog_->button_ok);
-       bc().setApply(dialog_->button_apply);
-       bc().setCancel(dialog_->button_close);
+       bcview().setOK(dialog_->button_ok);
+       bcview().setApply(dialog_->button_apply);
+       bcview().setCancel(dialog_->button_close);
 
-       bc().addReadOnly(dialog_->slider_rows);
-       bc().addReadOnly(dialog_->slider_columns);
-       bc().addReadOnly(dialog_->choice_valign);
-       bc().addReadOnly(dialog_->input_halign);
+       bcview().addReadOnly(dialog_->slider_rows);
+       bcview().addReadOnly(dialog_->slider_columns);
+       bcview().addReadOnly(dialog_->choice_valign);
+       bcview().addReadOnly(dialog_->input_halign);
 }
 
 
@@ -95,10 +97,10 @@ void FormMathsMatrix::apply()
 
        ostringstream os;
        os << nx << ' ' << ny << ' ' << c << ' ' << sh;
-       controller().dispatchFunc(LFUN_INSERT_MATRIX, STRCONV(os.str()));
+       controller().dispatchMatrix(os.str());
 }
 
-                             
+
 void FormMathsMatrix::update()
 {
        bc().valid();
@@ -128,7 +130,7 @@ int FormMathsMatrix::AlignFilter(char const * cur, int c)
 
        int const n = int(fl_get_slider_value(dialog_->slider_columns) + 0.5)
                - int(len)
-               + int(lyx::count(cur, cur + len, '|'));
+               + int(count(cur, cur + len, '|'));
        if (n < 0)
                return FL_INVALID;
 
@@ -137,3 +139,6 @@ int FormMathsMatrix::AlignFilter(char const * cur, int c)
 
        return FL_INVALID;
 }
+
+} // namespace frontend
+} // namespace lyx