]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/xforms/FormMathsMatrix.C
Introduce LFUN_PRINT.
[lyx.git] / src / frontends / xforms / FormMathsMatrix.C
index b443c57b3d241f47442f8a3be9bf201f05d48ddb..9a12b1684acf67535fd45c76a4a170fe2c0d6d74 100644 (file)
@@ -1,31 +1,35 @@
 /**
  * \file FormMathsMatrix.C
- * Copyright 2001 The LyX Team.
- * See the file COPYING.
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
  *
  * \author Alejandro Aguilar Sierra
- * \author Pablo De Napoli, pdenapo@dm.uba.ar
- * \author John Levon, moz@compsoc.man.ac.uk
- * \author Angus Leeming, a.leeming@ic.ac.uk
+ * \author Pablo De Napoli
+ * \author John Levon
+ * \author Angus Leeming
+ *
+ * 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 <algorithm>
+#include "xformsBC.h"
+
+#include "controllers/ButtonController.h"
 
-#include "FormMathsMatrix.h"
-#include "form_maths_matrix.h"
-#include "Dialogs.h"
-#include "frontends/LyXView.h"
-#include "Lsstream.h"
-#include "lyxfunc.h"
-#include "support/LAssert.h"
 #include "support/lyxalgo.h" // lyx::count
 
+#include "lyx_forms.h"
+
+#include "support/std_sstream.h"
+
+
+using std::ostringstream;
+
 #ifndef CXX_GLOBAL_CSTD
 using std::strlen;
 #endif
@@ -41,35 +45,29 @@ extern "C" {
        int C_FormMathsMatrixAlignFilter(FL_OBJECT * ob, char const *,
                                         char const * cur, int c)
        {
-               lyx::Assert(ob);
+               BOOST_ASSERT(ob);
                FormMathsMatrix * pre =
                        static_cast<FormMathsMatrix *>(ob->u_vdata);
-               lyx::Assert(pre);
+               BOOST_ASSERT(pre);
                return pre->AlignFilter(cur, c);
        }
 
 }
 
 
-FormMathsMatrix::FormMathsMatrix(LyXView * lv, Dialogs * d,
-                                FormMathsPanel const & p)
-       : FormMathsSub(lv, d, p, _("Maths Matrix"), false)
-{}
-
+typedef FormController<ControlMath, FormView<FD_maths_matrix> > base_class;
 
-FL_FORM * FormMathsMatrix::form() const
-{
-       if (dialog_.get())
-               return dialog_->form;
-       return 0;
-}
+FormMathsMatrix::FormMathsMatrix(Dialog & parent)
+       : base_class(parent, _("Math Matrix"), false)
+{}
 
 
 void FormMathsMatrix::build()
 {
-       dialog_.reset(build_maths_matrix());
+       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;
@@ -77,14 +75,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,16 +93,22 @@ 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);
 
-       ostringstream ost;
-       ost << nx << ' ' << ny << ' ' << c << ' ' << sh;
+       ostringstream os;
+       os << nx << ' ' << ny << ' ' << c << ' ' << sh;
+       controller().dispatchMatrix(os.str());
+}
+
 
-       lv_->getLyXFunc()->dispatch(LFUN_INSERT_MATRIX, ost.str().c_str());
+void FormMathsMatrix::update()
+{
+       bc().valid();
 }
 
-bool FormMathsMatrix::input(FL_OBJECT * ob, long)
+
+ButtonPolicy::SMInput FormMathsMatrix::input(FL_OBJECT * ob, long)
 {
        if (ob == dialog_->choice_valign ||
-           ob == dialog_->slider_rows) return true;
+           ob == dialog_->slider_rows) return ButtonPolicy::SMI_VALID;
 
        int const nx = int(fl_get_slider_value(dialog_->slider_columns)+0.5);
        for (int i = 0; i < nx; ++i)
@@ -114,17 +118,17 @@ bool FormMathsMatrix::input(FL_OBJECT * ob, long)
 
        fl_set_input(dialog_->input_halign, h_align_str);
        fl_redraw_object(dialog_->input_halign);
-       return true;
+       return ButtonPolicy::SMI_VALID;
 }
 
 
 int FormMathsMatrix::AlignFilter(char const * cur, int c)
 {
-       size_t len = strlen(cur);
+       size_t const len = strlen(cur);
 
-       int const n = int(fl_get_slider_value(dialog_->slider_columns) + 0.5) -
-               int(len) +
-               int(lyx::count(cur, cur + len, '|'));
+       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;