]> git.lyx.org Git - features.git/commitdiff
Implemented controller-view split for minipage and preamble popups.
authorAngus Leeming <leeming@lyx.org>
Tue, 27 Mar 2001 16:03:28 +0000 (16:03 +0000)
committerAngus Leeming <leeming@lyx.org>
Tue, 27 Mar 2001 16:03:28 +0000 (16:03 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1838 a592a061-630c-0410-9148-cb99ea01b6c8

22 files changed:
src/frontends/controllers/ChangeLog
src/frontends/controllers/ControlError.C
src/frontends/controllers/ControlMinipage.C [new file with mode: 0644]
src/frontends/controllers/ControlMinipage.h [new file with mode: 0644]
src/frontends/controllers/ControlPreamble.C [new file with mode: 0644]
src/frontends/controllers/ControlPreamble.h [new file with mode: 0644]
src/frontends/controllers/ControlPrint.C
src/frontends/controllers/GUI.h
src/frontends/controllers/Makefile.am
src/frontends/xforms/ChangeLog
src/frontends/xforms/Dialogs.C
src/frontends/xforms/FormCharacter.h
src/frontends/xforms/FormMinipage.C
src/frontends/xforms/FormMinipage.h
src/frontends/xforms/FormPreamble.C
src/frontends/xforms/FormPreamble.h
src/frontends/xforms/form_minipage.C
src/frontends/xforms/form_minipage.h
src/frontends/xforms/form_preamble.C
src/frontends/xforms/form_preamble.h
src/frontends/xforms/forms/form_minipage.fd
src/frontends/xforms/forms/form_preamble.fd

index 9af84c78eac74517fe0b44c9bfef04e6224cbb4a..25d23f559cd8716dc4340b12c9706058998d6980 100644 (file)
@@ -1,8 +1,10 @@
 2001-03-27  Angus Leeming  <a.leeming@ic.ac.uk>
 
+       * ControlMinipage.[Ch]:
+       * ControlPreamble.[Ch]:
        * ControlPrint.[Ch]:
-       * ControlSplash.[Ch]: new files; controller for the Print popup and
-       Splash screen respectively.
+       * ControlSplash.[Ch]: new files; controller for the Minipage, Preamble
+       and Print popups and Splash screen, respectively.
 
        * ViewBase.h (ViewSplash): new base class for GUI-specific Splash
        screens.
index 4a178607d9bae7ff53edbc27b56665c9e9aa23a7..0c571e1876de7b537cd8e245dbe28f31e4873717 100644 (file)
 #include "buffer.h"
 #include "insets/inseterror.h"
 
-using SigC::slot;
-
 ControlError::ControlError(LyXView & lv, Dialogs & d)
        : ControlInset<InsetError, string>(lv, d)
 {
-       d_.showError.connect(slot(this, &ControlError::showInset));
+       d_.showError.connect(SigC::slot(this, &ControlError::showInset));
 }
 
 string const ControlError::getParams(InsetError const & inset)
diff --git a/src/frontends/controllers/ControlMinipage.C b/src/frontends/controllers/ControlMinipage.C
new file mode 100644 (file)
index 0000000..14f1741
--- /dev/null
@@ -0,0 +1,70 @@
+/* This file is part of
+ * ====================================================== 
+ *
+ *           LyX, The Document Processor
+ *
+ *           Copyright 2001 The LyX Team.
+ *
+ * ======================================================
+ *
+ * \author Juergen Vigna, jug@sad.it
+ * \author Angus Leeming, a.leeming@ic.ac.uk
+ */
+
+#include <config.h>
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+#include "ControlMinipage.h"
+#include "Dialogs.h"
+#include "LyXView.h"
+#include "buffer.h"
+
+using SigC::slot;
+
+ControlMinipage::ControlMinipage(LyXView & lv, Dialogs & d)
+       : ControlInset<InsetMinipage, MinipageParams>(lv, d)
+{
+       d_.showMinipage.connect(slot(this, &ControlMinipage::showInset));
+       d_.updateMinipage.connect(slot(this, &ControlMinipage::showInset));
+}
+
+
+void ControlMinipage::applyParamsToInset()
+{
+       inset()->width(params().width);
+       inset()->widthp(params().widthp);
+       inset()->pos(params().pos);
+}
+
+
+void ControlMinipage::applyParamsNoInset()
+{
+}
+
+
+MinipageParams const ControlMinipage::getParams(InsetMinipage const & inset)
+{
+       return MinipageParams(inset);
+}
+
+
+MinipageParams::MinipageParams()
+       : widthp(0), pos(InsetMinipage::top)
+{}
+
+MinipageParams::MinipageParams(InsetMinipage const & inset)
+       : width(inset.width()), widthp(inset.widthp()), pos(inset.pos())
+{}
+
+bool MinipageParams::operator==(MinipageParams const & o) const
+{
+       return (width == o.width && widthp == o.widthp && pos == o.pos);
+}
+
+bool MinipageParams::operator!=(MinipageParams const & o) const
+{
+       return !(*this == o);
+}
diff --git a/src/frontends/controllers/ControlMinipage.h b/src/frontends/controllers/ControlMinipage.h
new file mode 100644 (file)
index 0000000..bc72227
--- /dev/null
@@ -0,0 +1,71 @@
+/* This file is part of
+ * ======================================================
+ * 
+ *           LyX, The Document Processor
+ *      
+ *          Copyright 2001 The LyX Team.
+ *
+ *======================================================
+ *
+ * \file ControlMinipage.h
+ * \author Juergen Vigna, jug@sad.it
+ * \author Angus Leeming, a.leeming@ic.ac.uk
+ */
+
+#ifndef CONTROLMINIPAGE_H
+#define CONTROLMINIPAGE_H
+
+#ifdef __GNUG__
+#pragma interface
+#endif
+
+#include "ControlInset.h"
+#include "insets/insetminipage.h" // InsetMinipage::Position
+
+/** This should be moved back into insetminipage.h and InsetMinipage should
+    contain an instance of it. */
+
+struct MinipageParams {
+       ///
+       MinipageParams();
+       ///
+       MinipageParams(InsetMinipage const &);
+       ///
+       bool operator==(MinipageParams const &) const;
+       ///
+       bool operator!=(MinipageParams const &) const;
+       
+       ///
+       string width;
+       ///
+       int widthp;
+       ///
+       InsetMinipage::Position pos;
+};
+
+
+class InsetMinipage;
+class MinipageParams;
+
+/** A controller for Minipage dialogs.
+ */
+class ControlMinipage : public ControlInset<InsetMinipage, MinipageParams>  {
+public:
+       ///
+       ControlMinipage(LyXView &, Dialogs &);
+
+private:
+       /// Dispatch the changed parameters to the kernel.
+       virtual void applyParamsToInset();
+       /// 
+       virtual void applyParamsNoInset();
+       /// 
+       virtual void clearDaughterParams() {}
+       /// get the parameters from the string passed to createInset.
+       virtual MinipageParams const getParams(string const &)
+               { return MinipageParams(); }
+       /// get the parameters from the inset passed to showInset.
+       virtual MinipageParams const getParams(InsetMinipage const &);
+};
+
+#endif
diff --git a/src/frontends/controllers/ControlPreamble.C b/src/frontends/controllers/ControlPreamble.C
new file mode 100644 (file)
index 0000000..d298300
--- /dev/null
@@ -0,0 +1,63 @@
+/**
+ * \file FormPreamble.C
+ * Copyright 2001 The LyX Team.
+ * See the file COPYING.
+ *
+ * \author Edwin Leuven, leuven@fee.uva.nl
+ */
+
+#include <config.h>
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+#include "ControlPreamble.h"
+#include "LyXView.h"
+#include "Dialogs.h"
+#include "buffer.h"
+#include "lyxrc.h"
+#include "Liason.h"
+
+
+ControlPreamble::ControlPreamble(LyXView & lv, Dialogs & d)
+       : ControlDialog<ControlConnectBD>(lv, d)
+{
+    d_.showPreamble.connect(SigC::slot(this, &ControlPreamble::show));
+}
+
+
+void ControlPreamble::apply()
+{
+       if (!lv_.view()->available())
+               return;
+   
+       view().apply();
+
+       lv_.buffer()->params.preamble = params();
+       lv_.buffer()->markDirty();
+       Liason::setMinibuffer(&lv_, _("LaTeX preamble set"));
+}
+
+
+string & ControlPreamble::params() const
+{
+       Assert(params_);
+       return *params_;
+}
+
+
+void ControlPreamble::setParams()
+{
+       if (params_) delete params_;
+       params_ = new string(lv_.buffer()->params.preamble);
+}
+
+
+void ControlPreamble::clearParams()
+{
+       if (params_) {
+               delete params_;
+               params_ = 0;
+       }
+}
diff --git a/src/frontends/controllers/ControlPreamble.h b/src/frontends/controllers/ControlPreamble.h
new file mode 100644 (file)
index 0000000..71907fc
--- /dev/null
@@ -0,0 +1,40 @@
+/**
+ * \file ControlPreamble.h
+ * Copyright 2001 The LyX Team.
+ * See the file COPYING.
+ *
+ * \author Edwin Leuven, leuven@fee.uva.nl
+ */
+
+#ifndef CONTROLPREAMBLE_H
+#define CONTROLPREAMBLE_H
+
+#ifdef __GNUG__
+#pragma interface
+#endif
+
+#include "ControlDialogs.h"
+
+/** A controller for Preamble dialogs.
+ */
+class ControlPreamble : public ControlDialog<ControlConnectBD> {
+public:
+       ///
+       ControlPreamble(LyXView &, Dialogs &);
+
+       ///
+       string & params() const;
+
+private:
+       /// Get changed parameters and Dispatch them to the kernel.
+       virtual void apply();
+       /// set the params before show or update.
+       virtual void setParams();
+       /// clean-up on hide.
+       virtual void clearParams();
+    
+       ///
+       string * params_;
+};
+
+#endif // CONTROLPREAMBLE_H
index ed9d21a3bf382019c43ffde28d9dc89574ad035a..183b8e0b2beb20fa41efbf4c71caa40232cd7941 100644 (file)
@@ -69,6 +69,8 @@ void ControlPrint::setParams()
 {
        if (params_) delete params_;
        params_ = new PrinterParams(getPrinterParams(lv_.buffer()));
+
+       bc().valid(); // so that the user can press Ok
 }
 
 
index fbe6a4ddf2ac3d0b4470f0364139beb571ab069a..3881ec756426e8ac5001aa8d4eeac7520124249e 100644 (file)
@@ -168,6 +168,34 @@ public:
 };
 
 
+/** Specialization for Minipage dialog
+ */
+class ControlMinipage;
+
+template <class GUIview, class GUIbc>
+class GUIMinipage :
+       public GUI<ControlMinipage, GUIview, OkApplyCancelReadOnlyPolicy, GUIbc> {
+public:
+       ///
+       GUIMinipage(LyXView & lv, Dialogs & d)
+               : GUI<ControlMinipage, GUIview, OkApplyCancelReadOnlyPolicy, GUIbc>(lv, d) {}
+};
+
+
+/** Specialization for Preamble dialog
+ */
+class ControlPreamble;
+
+template <class GUIview, class GUIbc>
+class GUIPreamble :
+       public GUI<ControlPreamble, GUIview, NoRepeatedApplyReadOnlyPolicy, GUIbc> {
+public:
+       ///
+       GUIPreamble(LyXView & lv, Dialogs & d)
+               : GUI<ControlPreamble, GUIview, NoRepeatedApplyReadOnlyPolicy, GUIbc>(lv, d) {}
+};
+
+
 /** Specialization for Print dialog
  */
 class ControlPrint;
index 66752dc88e91ef0bc320b83cad00834e55847dbc..7a6784312d7b6111bb65303626795c6708da1349 100644 (file)
@@ -40,6 +40,10 @@ libcontrollers_la_SOURCES=\
        ControlInset.h \
        ControlLog.C \
        ControlLog.h \
+       ControlMinipage.C \
+       ControlMinipage.h \
+       ControlPreamble.C \
+       ControlPreamble.h \
        ControlPrint.C \
        ControlPrint.h \
        ControlRef.C \
index 3a4af75365c5b5770222b61e20790f7be6fb747f..05c8fd97fb50405c5a8d9a40147ac61f5c5a357f 100644 (file)
@@ -1,5 +1,7 @@
 2001-03-27  Angus Leeming  <a.leeming@ic.ac.uk>
 
+       * FormMinipage.[Ch]:
+       * forms/form_minipage.fd:
        * FormPrint.[Ch]:
        * forms/form_print.fd:
        * FormSplash.[Ch]: implemented controller-view split.
@@ -8,6 +10,8 @@
 
 2001-03-26  Angus Leeming  <a.leeming@ic.ac.uk>
 
+       * FormPreamble.[Ch]:
+       * forms/form_preamble.fd:
        * FormRef.[Ch]:
        * forms/form_ref.fd:
        * FormSearch.[Ch]:
index 94f5d602fdcc3969905f9cda52d9bba752753c71..6d3721e2fe2e3fe6e7f8aec0ad782d1ee21d3018 100644 (file)
@@ -28,6 +28,8 @@
 #include "ControlError.h"
 #include "ControlInclude.h"
 #include "ControlLog.h"
+#include "ControlMinipage.h"
+#include "ControlPreamble.h"
 #include "ControlPrint.h"
 #include "ControlRef.h"
 #include "ControlSearch.h"
@@ -48,6 +50,8 @@
 #include "form_credits.h"
 #include "form_error.h"
 #include "form_include.h"
+#include "form_minipage.h"
+#include "form_preamble.h"
 #include "form_print.h"
 #include "form_ref.h"
 #include "form_search.h"
@@ -64,6 +68,8 @@
 #include "FormError.h"
 #include "FormInclude.h"
 #include "FormLog.h"
+#include "FormMinipage.h"
+#include "FormPreamble.h"
 #include "FormPrint.h"
 #include "FormRef.h"
 #include "FormSearch.h"
 #include "FormIndex.h"
 #include "FormMathsPanel.h"
 #include "FormParagraph.h"
-#include "FormPreamble.h"
 #include "FormPreferences.h"
 #include "FormTabular.h"
 #include "FormToc.h"
-#include "FormMinipage.h"
 
 // Signal enabling all visible popups to be redrawn if so desired.
 // E.g., when the GUI colours have been remapped.
@@ -101,6 +105,8 @@ Dialogs::Dialogs(LyXView * lv)
        add(new GUIError<FormError, xformsBC>(*lv, *this));
        add(new GUIInclude<FormInclude, xformsBC>(*lv, *this));
        add(new GUILog<FormLog, xformsBC>(*lv, *this));
+       add(new GUIMinipage<FormMinipage, xformsBC>(*lv, *this));
+       add(new GUIPreamble<FormPreamble, xformsBC>(*lv, *this));
        add(new GUIPrint<FormPrint, xformsBC>(*lv, *this));
        add(new GUIRef<FormRef, xformsBC>(*lv, *this));
        add(new GUISearch<FormSearch, xformsBC>(*lv, *this));
@@ -114,11 +120,9 @@ Dialogs::Dialogs(LyXView * lv)
        add(new FormIndex(lv, this));
        add(new FormMathsPanel(lv, this));
        add(new FormParagraph(lv, this));
-       add(new FormPreamble(lv, this));
        add(new FormPreferences(lv, this));
        add(new FormTabular(lv, this));
        add(new FormToc(lv, this));
-       add(new FormMinipage(lv, this));
        
        // reduce the number of connections needed in
        // dialogs by a simple connection here.
index 648fea5c0246090bb7c220dd5e260674651ad887..e4a41d8b1813bd55397226c9d55c4f5bba67665d 100644 (file)
@@ -25,7 +25,7 @@ class Combox;
 struct FD_form_character;
 
 /** 
- * This class provides an XForms implementation of the FormCharacter Dialog.
+ * This class provides an XForms implementation of the Character Dialog.
  * The character dialog allows users to change the character settings
  * in their documents.
  */
@@ -36,12 +36,12 @@ public:
        FormCharacter(ControlCharacter &);
 private:
 
-       /// Build the popup
-       virtual void build();
-   
        /// Apply from popup
        virtual void apply();
    
+       /// Build the popup
+       virtual void build();
+   
        /// Nothing to update...
        virtual void update() {}
 
index 9ff5cc1f3877508447621f0ed9d1e411dcb00533..bf3cb4a6951a9f2ead6d5751738b852e7f84c66d 100644 (file)
@@ -1,15 +1,14 @@
-// -*- C++ -*-
 /* This file is part of
  * ====================================================== 
  *
  *           LyX, The Document Processor
  *
- *           Copyright 2000 The LyX Team.
+ *           Copyright 2001 The LyX Team.
  *
  * ======================================================
- */
-/* FormMinipage.C
- * FormMinipage Interface Class Implementation
+ *
+ * \file FormMinipage.C
+ * \author Juergen Vigna, jug@sad.it
  */
 
 #include <config.h>
 #pragma implementation
 #endif
 
+#include "xformsBC.h"
+#include "ControlMinipage.h"
 #include "FormMinipage.h"
 #include "form_minipage.h"
-#include "Dialogs.h"
-#include "LyXView.h"
-#include "buffer.h"
-#include "insets/insetminipage.h"
 #include "support/lstrings.h"
 
-FormMinipage::FormMinipage(LyXView * lv, Dialogs * d)
-       : FormInset(lv, d, _("Minipage Options")),
-         inset_(0)
-{
-    // let the dialog be shown
-    // This is a permanent connection so we won't bother
-    // storing a copy because we won't be disconnecting.
-    d->showMinipage.connect(SigC::slot(this, &FormMinipage::showInset));
-    d->updateMinipage.connect(SigC::slot(this, &FormMinipage::updateInset));
-}
-
-
-FL_FORM * FormMinipage::form() const
-{
-    if (dialog_.get())
-       return dialog_->form;
-    return 0;
-}
-
-
-void FormMinipage::connect()
-{
-    bc().valid(true);
-    FormBaseBD::connect();
-}
-
+typedef FormCB<ControlMinipage, FormDB<FD_form_minipage> > base_class;
 
-void FormMinipage::showInset(InsetMinipage * inset)
-{
-    if (inset == 0) return;
-
-    // If connected to another inset, disconnect from it.
-    if (inset_ != inset) {
-       ih_.disconnect();
-       ih_ = inset->hideDialog.connect(SigC::slot(this, &FormMinipage::hide));
-       inset_ = inset;
-    }
+FormMinipage::FormMinipage(ControlMinipage & c)
+       : base_class(c, _("Minipage Options"))
+{}
 
-    show();
-}
 
-
-void FormMinipage::updateInset(InsetMinipage * inset)
+void FormMinipage::build()
 {
-    if (inset == 0 || inset_ == 0) return;
+       dialog_.reset(build_minipage());
 
-    // If connected to another inset, disconnect from it.
-    if (inset_ != inset) {
-       ih_.disconnect();
-       ih_ = inset->hideDialog.connect(SigC::slot(this, &FormMinipage::hide));
-       inset_ = inset;
-    }
+       fl_set_input_return(dialog_->input_width, FL_RETURN_CHANGED);
+       fl_set_input_return(dialog_->input_widthp, FL_RETURN_CHANGED);
 
-    update();
-}
-
-void FormMinipage::build()
-{
-    dialog_.reset(build_minipage());
+       // Manage the ok, apply and cancel/close buttons
+       bc().setOK(dialog_->button_ok);
+       bc().setApply(dialog_->button_apply);
+       bc().setCancel(dialog_->button_cancel);
+       bc().setUndoAll(dialog_->button_restore);
 
-    fl_set_input_return(dialog_->input_width, FL_RETURN_CHANGED);
-    fl_set_input_return(dialog_->input_widthp, FL_RETURN_CHANGED);
+       bc().addReadOnly(dialog_->input_width);
+       bc().addReadOnly(dialog_->input_widthp);
+       bc().addReadOnly(dialog_->radio_top);
+       bc().addReadOnly(dialog_->radio_middle);
+       bc().addReadOnly(dialog_->radio_bottom);
 
-    // Manage the ok, apply and cancel/close buttons
-    bc().setOK(dialog_->button_ok);
-    bc().setApply(dialog_->button_apply);
-    bc().setCancel(dialog_->button_cancel);
-    bc().refresh();
+       bc().refresh();
 }
 
 
 void FormMinipage::apply()
 {
-#if 0
-    int ysize = int(fl_get_slider_value(dialog_->slider_columns) + 0.5);
-    int xsize = int(fl_get_slider_value(dialog_->slider_rows) + 0.5);
-
-    string tmp = tostr(xsize) + " " + tostr(ysize);
-    lv_->getLyXFunc()->Dispatch(LFUN_INSET_TABULAR, tmp);
-#endif
+       controller().params().width = fl_get_input(dialog_->input_width);
+       controller().params().widthp =
+               strToInt(fl_get_input(dialog_->input_widthp));
+
+       if (fl_get_button(dialog_->radio_top))
+               controller().params().pos = InsetMinipage::top;
+       else if (fl_get_button(dialog_->radio_middle))
+               controller().params().pos = InsetMinipage::center;
+       else
+               controller().params().pos = InsetMinipage::bottom;
 }
 
 
 void FormMinipage::update()
 {
-    if (!inset_)
-       return;
-    fl_set_input(dialog_->input_width, inset_->width().c_str());
-    fl_set_input(dialog_->input_widthp, tostr(inset_->widthp()).c_str());
+    fl_set_input(dialog_->input_width,
+                controller().params().width.c_str());
+    fl_set_input(dialog_->input_widthp,
+                tostr(controller().params().widthp).c_str());
                 
-    switch (inset_->pos()) {
+    switch (controller().params().pos) {
     case InsetMinipage::top:
        fl_set_button(dialog_->radio_top, 1);
        break;
@@ -127,5 +86,4 @@ void FormMinipage::update()
        fl_set_button(dialog_->radio_bottom, 1);
        break;
     }
-    bc().readOnly(lv_->buffer()->isReadonly());
 }
index bba936b244a7f0a9ad5a8ddba7c59ecac097add9..f0f92a96707fe9028654a7bfffa6e1bbef4e1e65 100644 (file)
@@ -1,77 +1,51 @@
-// -*- C++ -*-
 /* This file is part of
  * ======================================================
  * 
  *           LyX, The Document Processor
  *      
- *         Copyright 1995 Matthias Ettrich
- *          Copyright 1995-2000 The LyX Team.
+ *          Copyright 2001 The LyX Team.
  *
- *======================================================*/
-/* FormMinipage.h
- * FormMinipage Interface Class
+ *======================================================
+ *
+ * \file FormMinipage.h
+ * \author Juergen Vigna, jug@sad.it
  */
 
 #ifndef FORMMINIPAGE_H
 #define FORMMINIPAGE_H
 
-#include <boost/smart_ptr.hpp>
-
 #ifdef __GNUG__
 #pragma interface
 #endif
 
-#include "FormInset.h"
-#include "xformsBC.h"
+#include "FormBase.h"
 
 class LyXView;
 class Dialogs;
 class InsetMinipage;
 struct FD_form_minipage;
 
-/** This class provides an XForms implementation of the FormMinipage
+/** This class provides an XForms implementation of the Minipage
     Dialog.
  */
-class FormMinipage : public FormInset {
+class ControlMinipage;
+struct FD_form_minipage;
+
+class FormMinipage : public FormCB<ControlMinipage, FormDB<FD_form_minipage> > {
 public:
-       /// #FormMinipage x(LyXView ..., Dialogs ...);#
-       FormMinipage(LyXView *, Dialogs *);
+       ///
+       FormMinipage(ControlMinipage &);
 
 private:
-       /// Pointer to the actual instantiation of the ButtonController.
-       virtual xformsBC & bc();
-       /// Connect signals etc.
-       virtual void connect();
-
-       /// Slot launching dialog to an existing inset
-       void showInset(InsetMinipage *);
-       /// Slot launching dialog to an existing inset
-       void updateInset(InsetMinipage *);
-       /// Apply from dialog
+       /// Set the Params variable for the Controller.
        virtual void apply();
-       /// Update dialog before showing it
-       virtual void update();
-       /// Pointer to the actual instantiation of the xforms form
-       virtual FL_FORM * form() const;
-       /// Build the dialog
+       /// Build the dialog.
        virtual void build();
+       /// Update dialog before/whilst showing it.
+       virtual void update();
 
-       ///
+       /// Fdesign generated method
        FD_form_minipage * build_minipage();
-       
-       /// Real GUI implementation.
-       boost::scoped_ptr<FD_form_minipage> dialog_;
-       /// The ButtonController
-       ButtonController<OkApplyCancelReadOnlyPolicy, xformsBC> bc_;
-
-       /// pointer to the inset passed through showInset
-       InsetMinipage * inset_;
 };
 
-
-inline
-xformsBC & FormMinipage::bc()
-{
-       return bc_;
-}
-#endif
+#endif // FORMMINIPAGE_H
index b68f411708fbb82150a55e542a04c198feaef63c..9e37c1df3264942a828b91d21fcee8427945bfee 100644 (file)
@@ -8,83 +8,52 @@
 
 #include <config.h>
 
-#include FORMS_H_LOCATION
-
 #ifdef __GNUG__
 #pragma implementation
 #endif
 
-#include "form_preamble.h"
+#include "xformsBC.h"
+#include "ControlPreamble.h"
 #include "FormPreamble.h"
-#include "Dialogs.h"
-#include "Liason.h"
-#include "LyXView.h"
-#include "buffer.h"
-#include "gettext.h"
+#include "form_preamble.h"
 #include "xforms_helpers.h"
 
-using Liason::setMinibuffer;
-using SigC::slot;
+typedef FormCB<ControlPreamble, FormDB<FD_form_preamble> > base_class;
 
-FormPreamble::FormPreamble(LyXView * lv, Dialogs * d)
-       : FormBaseBD(lv, d, _("LaTeX preamble"))
-{
-    // let the popup be shown
-    // This is a permanent connection so we won't bother
-    // storing a copy because we won't be disconnecting.
-    d->showPreamble.connect(slot(this, &FormPreamble::show));
-}
-
-
-FL_FORM * FormPreamble::form() const
-{
-    if (dialog_.get()) return dialog_->form;
-    return 0;
-}
+FormPreamble::FormPreamble(ControlPreamble & c)
+       : base_class(c, _("LaTeX preamble"))
+{}
 
 
 void FormPreamble::build()
 {
-   dialog_.reset(build_preamble());
+       dialog_.reset(build_preamble());
    
-   fl_set_input_return(dialog_->input_preamble, FL_RETURN_CHANGED);
-   // Manage the ok, apply and cancel/close buttons
-   bc().setOK(dialog_->button_ok);
-   bc().setApply(dialog_->button_apply);
-   bc().setCancel(dialog_->button_cancel);
-   bc().addReadOnly(dialog_->input_preamble);
-   bc().refresh();
+       fl_set_input_return(dialog_->input_preamble, FL_RETURN_CHANGED);
+
+       // Manage the ok, apply and cancel/close buttons
+       bc().setOK(dialog_->button_ok);
+       bc().setApply(dialog_->button_apply);
+       bc().setCancel(dialog_->button_cancel);
+       bc().addReadOnly(dialog_->input_preamble);
+       bc().refresh();
 }
 
 
 void FormPreamble::apply()
 {
-   if (!lv_->view()->available() || !dialog_.get())
-     return;
-   
-   // is this needed?:
-   // lv_->view()->update(BufferView::SELECT | BufferView::FITCUR | BufferView::CHANGE);
-   
-   lv_->buffer()->params.preamble = fl_get_input(dialog_->input_preamble);
-   lv_->buffer()->markDirty();
-   setMinibuffer(lv_, _("LaTeX preamble set"));
+       controller().params() = fl_get_input(dialog_->input_preamble);
 }
 
 
 void FormPreamble::update()
 {
-   if (!dialog_.get())
-     return;
-
-   fl_set_input(dialog_->input_preamble,lv_->buffer()->params.preamble.c_str());
+       fl_set_input(dialog_->input_preamble, controller().params().c_str());
 
-   bool const enable = (! lv_->buffer()->isReadonly());
-   setEnabled(dialog_->input_preamble, enable);
-   setEnabled(dialog_->button_ok,      enable);
-   setEnabled(dialog_->button_apply,   enable);
-   
-   // need this?
-   // bc().readOnly(lv_->buffer()->isReadonly());
+       bool const enable = (!controller().isReadonly());
+       setEnabled(dialog_->input_preamble, enable);
+       setEnabled(dialog_->button_ok,      enable);
+       setEnabled(dialog_->button_apply,   enable);
 }
 
 
index ee43a0a6e55e8687744a5e5a551a0e16656651f3..27dd6d0ed40b4a042601f6d6947410764e699add 100644 (file)
@@ -1,4 +1,3 @@
-// -*- C++ -*-
 /**
  * \file FormPreamble.h
  * Copyright 2001 The LyX Team.
 #ifndef FORMPREAMBLE_H
 #define FORMPREAMBLE_H
 
-#include <boost/smart_ptr.hpp>
-
 #ifdef __GNUG__
 #pragma interface
 #endif
 
-#include "FormBaseDeprecated.h"
+#include "FormBase.h"
 
+class ControlPreamble;
 struct FD_form_preamble;
 
-/** This class provides an XForms implementation of the FormPreamble Dialog.
+/** This class provides an XForms implementation of the Preamble Dialog.
  */
-class FormPreamble : public FormBaseBD {
+class FormPreamble : public FormCB<ControlPreamble, FormDB<FD_form_preamble> > {
 public:
        ///
-       FormPreamble(LyXView *, Dialogs *);
+       FormPreamble(ControlPreamble &);
 private:
-       /// Pointer to the actual instantiation of the ButtonController.
-       virtual xformsBC & bc();
-
-       /// Filter the inputs
-       // virtual bool input(FL_OBJECT *, long);
-   
-       /// Build the popup
-       virtual void build();
        /// Apply from popup
        virtual void apply();
+       /// Build the popup
+       virtual void build();
        /// Update the popup.
        virtual void update();
-       ///
-       virtual FL_FORM * form() const;
    
        /// Fdesign generated method
        FD_form_preamble * build_preamble();
-   
-       /// Real GUI implementation.
-       boost::scoped_ptr<FD_form_preamble> dialog_;
-       /// The ButtonController
-       ButtonController<NoRepeatedApplyReadOnlyPolicy, xformsBC> bc_;
 };
 
 
-inline
-xformsBC & FormPreamble::bc()
-{
-  return bc_;
-}
-#endif
+#endif // FORMPREAMBLE_H
index 25c0ab0fbd4295c56ed8c81d931e33ee405b6049..ed97867bec68738bc1278895da178e5ad4728a4f 100644 (file)
@@ -35,7 +35,7 @@ FD_form_minipage * FormMinipage::build_minipage()
     fl_set_button_shortcut(obj, scex(_(dummy)), 1);
   }
     fl_set_object_lsize(obj, FL_NORMAL_SIZE);
-    fl_set_object_callback(obj, C_FormBaseDeprecatedInputCB, 0);
+    fl_set_object_callback(obj, C_FormBaseInputCB, 0);
   {
     // xgettext:no-c-format
     char const * const dummy = N_("or %|#o");
@@ -43,7 +43,7 @@ FD_form_minipage * FormMinipage::build_minipage()
     fl_set_button_shortcut(obj, scex(_(dummy)), 1);
   }
     fl_set_object_lsize(obj, FL_NORMAL_SIZE);
-    fl_set_object_callback(obj, C_FormBaseDeprecatedInputCB, 0);
+    fl_set_object_callback(obj, C_FormBaseInputCB, 0);
   obj = fl_add_text(FL_NORMAL_TEXT, 30, 10, 100, 20, _("Width"));
     fl_set_object_lsize(obj, FL_NORMAL_SIZE);
     fl_set_object_lalign(obj, FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
@@ -60,21 +60,21 @@ FD_form_minipage * FormMinipage::build_minipage()
     fl_set_button_shortcut(obj, scex(_(dummy)), 1);
   }
     fl_set_object_lsize(obj, FL_NORMAL_SIZE);
-    fl_set_object_callback(obj, C_FormBaseDeprecatedInputCB, 0);
+    fl_set_object_callback(obj, C_FormBaseInputCB, 0);
   {
     char const * const dummy = N_("Middle|#d");
     fdui->radio_middle = obj = fl_add_checkbutton(FL_RADIO_BUTTON, 249, 60, 152, 30, idex(_(dummy)));
     fl_set_button_shortcut(obj, scex(_(dummy)), 1);
   }
     fl_set_object_lsize(obj, FL_NORMAL_SIZE);
-    fl_set_object_callback(obj, C_FormBaseDeprecatedInputCB, 0);
+    fl_set_object_callback(obj, C_FormBaseInputCB, 0);
   {
     char const * const dummy = N_("Bottom|#B");
     fdui->radio_bottom = obj = fl_add_checkbutton(FL_RADIO_BUTTON, 249, 90, 152, 30, idex(_(dummy)));
     fl_set_button_shortcut(obj, scex(_(dummy)), 1);
   }
     fl_set_object_lsize(obj, FL_NORMAL_SIZE);
-    fl_set_object_callback(obj, C_FormBaseDeprecatedInputCB, 0);
+    fl_set_object_callback(obj, C_FormBaseInputCB, 0);
   fl_end_group();
 
   {
@@ -83,24 +83,24 @@ FD_form_minipage * FormMinipage::build_minipage()
     fl_set_button_shortcut(obj, scex(_(dummy)), 1);
   }
     fl_set_object_lsize(obj, FL_NORMAL_SIZE);
-    fl_set_object_callback(obj, C_FormBaseDeprecatedCancelCB, 0);
+    fl_set_object_callback(obj, C_FormBaseCancelCB, 0);
   {
     char const * const dummy = N_("Apply|#A");
     fdui->button_apply = obj = fl_add_button(FL_NORMAL_BUTTON, 230, 130, 90, 30, idex(_(dummy)));
     fl_set_button_shortcut(obj, scex(_(dummy)), 1);
   }
     fl_set_object_lsize(obj, FL_NORMAL_SIZE);
-    fl_set_object_callback(obj, C_FormBaseDeprecatedApplyCB, 0);
+    fl_set_object_callback(obj, C_FormBaseApplyCB, 0);
   fdui->button_ok = obj = fl_add_button(FL_RETURN_BUTTON, 130, 130, 90, 30, _("OK"));
     fl_set_object_lsize(obj, FL_NORMAL_SIZE);
-    fl_set_object_callback(obj, C_FormBaseDeprecatedOKCB, 0);
+    fl_set_object_callback(obj, C_FormBaseOKCB, 0);
   {
     char const * const dummy = N_("Restore|#R");
     fdui->button_restore = obj = fl_add_button(FL_NORMAL_BUTTON, 10, 130, 90, 30, idex(_(dummy)));
     fl_set_button_shortcut(obj, scex(_(dummy)), 1);
   }
     fl_set_object_lsize(obj, FL_NORMAL_SIZE);
-    fl_set_object_callback(obj, C_FormBaseDeprecatedRestoreCB, 0);
+    fl_set_object_callback(obj, C_FormBaseRestoreCB, 0);
   fl_end_form();
 
   fdui->form->fdui = fdui;
index e9f9349964cdfcd9f102f017b703ffa6a9b159e8..bf386ac471c75f705628b1ba3189c257953fd87c 100644 (file)
@@ -5,11 +5,11 @@
 #define FD_form_minipage_h_
 
 /** Callbacks, globals and object handlers **/
-extern  "C" void C_FormBaseDeprecatedInputCB(FL_OBJECT *, long);
-extern  "C" void C_FormBaseDeprecatedCancelCB(FL_OBJECT *, long);
-extern  "C" void C_FormBaseDeprecatedApplyCB(FL_OBJECT *, long);
-extern  "C" void C_FormBaseDeprecatedOKCB(FL_OBJECT *, long);
-extern  "C" void C_FormBaseDeprecatedRestoreCB(FL_OBJECT *, long);
+extern  "C" void C_FormBaseInputCB(FL_OBJECT *, long);
+extern  "C" void C_FormBaseCancelCB(FL_OBJECT *, long);
+extern  "C" void C_FormBaseApplyCB(FL_OBJECT *, long);
+extern  "C" void C_FormBaseOKCB(FL_OBJECT *, long);
+extern  "C" void C_FormBaseRestoreCB(FL_OBJECT *, long);
 
 
 /**** Forms and Objects ****/
index b8ac189cb3c5e271b414eb4e3c1cb7df37a4ab1c..85e301e14b607ed7fd663038b28c83c76a64103e 100644 (file)
@@ -32,7 +32,7 @@ FD_form_preamble * FormPreamble::build_preamble()
   }
     fl_set_object_lsize(obj, FL_NORMAL_SIZE);
     fl_set_object_gravity(obj, FL_SouthEast, FL_SouthEast);
-    fl_set_object_callback(obj, C_FormBaseDeprecatedOKCB, 0);
+    fl_set_object_callback(obj, C_FormBaseOKCB, 0);
   {
     char const * const dummy = N_("Apply|#A");
     fdui->button_apply = obj = fl_add_button(FL_NORMAL_BUTTON, 160, 380, 100, 30, idex(_(dummy)));
@@ -40,7 +40,7 @@ FD_form_preamble * FormPreamble::build_preamble()
   }
     fl_set_object_lsize(obj, FL_NORMAL_SIZE);
     fl_set_object_gravity(obj, FL_SouthEast, FL_SouthEast);
-    fl_set_object_callback(obj, C_FormBaseDeprecatedApplyCB, 0);
+    fl_set_object_callback(obj, C_FormBaseApplyCB, 0);
   {
     char const * const dummy = N_("Cancel|^[");
     fdui->button_cancel = obj = fl_add_button(FL_NORMAL_BUTTON, 270, 380, 100, 30, idex(_(dummy)));
@@ -48,11 +48,11 @@ FD_form_preamble * FormPreamble::build_preamble()
   }
     fl_set_object_lsize(obj, FL_NORMAL_SIZE);
     fl_set_object_gravity(obj, FL_SouthEast, FL_SouthEast);
-    fl_set_object_callback(obj, C_FormBaseDeprecatedCancelCB, 0);
+    fl_set_object_callback(obj, C_FormBaseCancelCB, 0);
   fdui->input_preamble = obj = fl_add_input(FL_MULTILINE_INPUT, 10, 10, 360, 360, "");
     fl_set_object_lsize(obj, FL_NORMAL_SIZE);
     fl_set_object_gravity(obj, FL_NorthWest, FL_SouthEast);
-    fl_set_object_callback(obj, C_FormBaseDeprecatedInputCB, 0);
+    fl_set_object_callback(obj, C_FormBaseInputCB, 0);
   fl_end_form();
 
   fdui->form->fdui = fdui;
index 51607f04a6fe5400f4c9abe764e7ffbd7f96899e..6e826d0ddb2dd3e5866a5ee412e0873e71a68314 100644 (file)
@@ -5,10 +5,10 @@
 #define FD_form_preamble_h_
 
 /** Callbacks, globals and object handlers **/
-extern  "C" void C_FormBaseDeprecatedOKCB(FL_OBJECT *, long);
-extern  "C" void C_FormBaseDeprecatedApplyCB(FL_OBJECT *, long);
-extern  "C" void C_FormBaseDeprecatedCancelCB(FL_OBJECT *, long);
-extern  "C" void C_FormBaseDeprecatedInputCB(FL_OBJECT *, long);
+extern  "C" void C_FormBaseOKCB(FL_OBJECT *, long);
+extern  "C" void C_FormBaseApplyCB(FL_OBJECT *, long);
+extern  "C" void C_FormBaseCancelCB(FL_OBJECT *, long);
+extern  "C" void C_FormBaseInputCB(FL_OBJECT *, long);
 
 
 /**** Forms and Objects ****/
index 5875aa9fed6580cfbbe29b98966d1646ea871c1c..5a3e22e25b6b15da4f9a44a18accae09c3ac065b 100644 (file)
@@ -81,7 +81,7 @@ shortcut:
 resize: FL_RESIZE_ALL
 gravity: FL_NoGravity FL_NoGravity
 name: input_width
-callback: C_FormBaseDeprecatedInputCB
+callback: C_FormBaseInputCB
 argument: 0
 
 --------------------
@@ -99,7 +99,7 @@ shortcut:
 resize: FL_RESIZE_ALL
 gravity: FL_NoGravity FL_NoGravity
 name: input_widthp
-callback: C_FormBaseDeprecatedInputCB
+callback: C_FormBaseInputCB
 argument: 0
 
 --------------------
@@ -171,7 +171,7 @@ shortcut:
 resize: FL_RESIZE_ALL
 gravity: FL_NoGravity FL_NoGravity
 name: radio_top
-callback: C_FormBaseDeprecatedInputCB
+callback: C_FormBaseInputCB
 argument: 0
 
 --------------------
@@ -189,7 +189,7 @@ shortcut:
 resize: FL_RESIZE_ALL
 gravity: FL_NoGravity FL_NoGravity
 name: radio_middle
-callback: C_FormBaseDeprecatedInputCB
+callback: C_FormBaseInputCB
 argument: 0
 
 --------------------
@@ -207,7 +207,7 @@ shortcut:
 resize: FL_RESIZE_ALL
 gravity: FL_NoGravity FL_NoGravity
 name: radio_bottom
-callback: C_FormBaseDeprecatedInputCB
+callback: C_FormBaseInputCB
 argument: 0
 
 --------------------
@@ -243,7 +243,7 @@ shortcut:
 resize: FL_RESIZE_ALL
 gravity: FL_NoGravity FL_NoGravity
 name: button_cancel
-callback: C_FormBaseDeprecatedCancelCB
+callback: C_FormBaseCancelCB
 argument: 0
 
 --------------------
@@ -261,7 +261,7 @@ shortcut:
 resize: FL_RESIZE_ALL
 gravity: FL_NoGravity FL_NoGravity
 name: button_apply
-callback: C_FormBaseDeprecatedApplyCB
+callback: C_FormBaseApplyCB
 argument: 0
 
 --------------------
@@ -279,7 +279,7 @@ shortcut: ^M
 resize: FL_RESIZE_ALL
 gravity: FL_NoGravity FL_NoGravity
 name: button_ok
-callback: C_FormBaseDeprecatedOKCB
+callback: C_FormBaseOKCB
 argument: 0
 
 --------------------
@@ -297,7 +297,7 @@ shortcut:
 resize: FL_RESIZE_ALL
 gravity: FL_NoGravity FL_NoGravity
 name: button_restore
-callback: C_FormBaseDeprecatedRestoreCB
+callback: C_FormBaseRestoreCB
 argument: 0
 
 ==============================
index e464e35fe106eed4ca68cc5f27dd2bc058a9e53e..65b17ed7ed7382d4567ad4ba6cec3447e8ed7090 100644 (file)
@@ -46,7 +46,7 @@ shortcut:
 resize: FL_RESIZE_NONE
 gravity: FL_SouthEast FL_SouthEast
 name: button_ok
-callback: C_FormBaseDeprecatedOKCB
+callback: C_FormBaseOKCB
 argument: 0
 
 --------------------
@@ -64,7 +64,7 @@ shortcut:
 resize: FL_RESIZE_NONE
 gravity: FL_SouthEast FL_SouthEast
 name: button_apply
-callback: C_FormBaseDeprecatedApplyCB
+callback: C_FormBaseApplyCB
 argument: 0
 
 --------------------
@@ -82,7 +82,7 @@ shortcut:
 resize: FL_RESIZE_NONE
 gravity: FL_SouthEast FL_SouthEast
 name: button_cancel
-callback: C_FormBaseDeprecatedCancelCB
+callback: C_FormBaseCancelCB
 argument: 0
 
 --------------------
@@ -100,7 +100,7 @@ shortcut:
 resize: FL_RESIZE_ALL
 gravity: FL_NorthWest FL_SouthEast
 name: input_preamble
-callback: C_FormBaseDeprecatedInputCB
+callback: C_FormBaseInputCB
 argument: 
 
 ==============================