]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/xforms/FormMathsDelim.C
Introduce LFUN_PRINT.
[lyx.git] / src / frontends / xforms / FormMathsDelim.C
index bb8e5a91ea47643cf2d7e23dac102551a645a7bd..a13a9cae872bdf6e2051846dfe1e886fb7af1879 100644 (file)
@@ -1,70 +1,61 @@
 /**
  * \file FormMathsDelim.C
- * 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
  * \author John Levon
- * \author Angus Leeming 
+ * \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 "FormMathsDelim.h"
 #include "forms/form_maths_delim.h"
+#include "ControlMath.h"
 
 #include "bmtable.h"
+#include "xformsBC.h"
 
-#include "debug.h"
-#include "funcrequest.h"
-#include "lyxfunc.h"
-
-#include "frontends/LyXView.h"
+#include "controllers/ButtonController.h"
 
-#include "support/lstrings.h"
+#include "support/std_sstream.h"
 
-#include "Lsstream.h"
-
-#include FORMS_H_LOCATION
+using std::ostringstream;
 
 #include "delim.xbm"
 #include "delim0.xpm"
 #include "delim1.xpm"
 
 
-static int const delim_rversion[] = {
+namespace {
+
+int const delim_rversion[] = {
        1,1,3,3,4,5,7,7,9,9,10,11,
-       13,13,14,15,16,17,19,19,20,21,22,23
+       3,13,15,15,16,17,19,19,20,21,22
 };
+int const delim_size = 
+       sizeof(delim_rversion) / sizeof(delim_rversion[0]);
 
-
-static char const * delim_values[] = {
+char const * delim_values[] = {
        "(", ")", "lceil",  "rceil",  "uparrow",  "Uparrow",
        "[", "]", "lfloor", "rfloor", "updownarrow", "Updownarrow",
-       "{", "}",  "/", "\\",  "downarrow",  "Downarrow",
+       "{", "}",  "/", "backslash",  "downarrow",  "Downarrow",
        "langle",  "rangle", "|", "Vert", ".", 0
 };
 
-using std::endl;
 
-FormMathsDelim::FormMathsDelim(LyXView & lv, Dialogs & d,
-                              FormMathsPanel const & p)
-       : FormMathsSub(lv, d, p, _("Maths Delimiters"), false)
-{}
+} // namespace anon
 
 
-FL_FORM * FormMathsDelim::form() const
-{
-       if (dialog_.get())
-               return dialog_->form;
-       return 0;
-}
+typedef FormController<ControlMath, FormView<FD_maths_delim> > base_class;
+
+FormMathsDelim::FormMathsDelim(Dialog & parent)
+       : base_class(parent, _("Math Delimiters"), false)
+{}
 
 
 void FormMathsDelim::build()
@@ -82,15 +73,15 @@ void FormMathsDelim::build()
                            delim_width, delim_height, delim_bits);
        fl_set_bmtable_maxitems(dialog_->bmtable, 23);
 
-       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_->bmtable);
-       bc().addReadOnly(dialog_->radio_right);
-       bc().addReadOnly(dialog_->radio_left);
-       bc().addReadOnly(dialog_->radio_both);
-       bc().addReadOnly(dialog_->button_pix);
+       bcview().addReadOnly(dialog_->bmtable);
+       bcview().addReadOnly(dialog_->radio_right);
+       bcview().addReadOnly(dialog_->radio_left);
+       bcview().addReadOnly(dialog_->radio_both);
+       bcview().addReadOnly(dialog_->button_pix);
 }
 
 
@@ -101,12 +92,17 @@ void FormMathsDelim::apply()
 
        ostringstream os;
        os << delim_values[left] << ' ' << delim_values[right];
+       controller().dispatchDelim(os.str());
+}
 
-       lv_.dispatch(FuncRequest(LFUN_MATH_DELIM, os.str().c_str()));
+
+void FormMathsDelim::update()
+{
+       bc().valid();
 }
 
 
-bool FormMathsDelim::input(FL_OBJECT *, long)
+ButtonPolicy::SMInput FormMathsDelim::input(FL_OBJECT *, long)
 {
        int left = int(dialog_->radio_left->u_ldata);
        int right= int(dialog_->radio_right->u_ldata);
@@ -125,7 +121,7 @@ bool FormMathsDelim::input(FL_OBJECT *, long)
                        if (both) {
                                right = delim_rversion[i];
                                // Add left delimiter in "both" case if right one was pressed:
-                               for (int j = 0; j <= 23; ++j) {
+                               for (int j = 0; j < delim_size; ++j) {
                                        if (delim_rversion[j] == left) {
                                                right = left;
                                                left = j;
@@ -135,13 +131,13 @@ bool FormMathsDelim::input(FL_OBJECT *, long)
                }
        }
 
-       // Re-initialize button_pix to solid blue 
+       // Re-initialize button_pix to solid blue
        // (not elegant but works, MV 24.5.2002)
        fl_free_pixmap_pixmap(dialog_->button_pix);
        fl_set_pixmap_data(dialog_->button_pix, const_cast<char**>(delim1));
        Pixmap p1;
        fl_get_pixmap_pixmap(dialog_->button_pix, &p1, 0);
-       
+
        fl_draw_bmtable_item(dialog_->bmtable, left, p1, 0, 0);
        fl_draw_bmtable_item(dialog_->bmtable, right, p1, 16, 0);
        fl_redraw_object(dialog_->button_pix);
@@ -149,5 +145,5 @@ bool FormMathsDelim::input(FL_OBJECT *, long)
        dialog_->radio_left->u_ldata  = left;
        dialog_->radio_right->u_ldata = right;
 
-       return true;
+       return ButtonPolicy::SMI_VALID;
 }