]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/controllers/ControlConnections.h
John's character.C patch (bug fix).
[lyx.git] / src / frontends / controllers / ControlConnections.h
index f50601241e990aa3b7261a428057792a0348b4ae..ca27eeed33dd9527889b412feaca86724c38cd4a 100644 (file)
@@ -4,12 +4,28 @@
  *
  *           LyX, The Document Processor
  *
- *           Copyright 2000 The LyX Team.
+ *           Copyright 2001 The LyX Team.
  *
  * ======================================================
  *
  * \file ControlConnections.h
  * \author Angus Leeming <a.leeming@ic.ac.uk>
+ *
+ * ControlConnections.h contains the definition of three controller classes,
+ * ControlConnectBase, ControlConnectBI and ControlConnectBD.
+ *
+ * Together they control the connection/disconnection of signals with the LyX
+ * kernel. Controllers of individual dialogs interacting with the kernel through
+ * signals/slots will all be derived from ControlConnectBI or ControlConnectBD.
+ *
+ * A dialog is classed as "Buffer Dependent" if its contents change with the
+ * buffer (document). An example would be the Citation dialog. Such a dialog
+ * would be derived, therefore, from ControlConnectBD.
+ *
+ * Conversely, a dialog is "Buffer Independent" if its contents do not change
+ * when the buffer changes. An example would be the Copyright dialog. Such a
+ * dialog is therefore derived from ControlConnectBI.
+ *
  */
 
 #ifndef CONTROLCONNECTIONS_H
 #pragma interface
 #endif
 
-#include "ControlBase.h"
+#include "ControlButtons.h"
+
+class Dialogs;
+class LyXView;
 
 /** Base class to control connection/disconnection of signals with the LyX
     kernel. It is meant to be used solely as the parent class to
     ControlConnectBI and ControlConnectBD.
 */
-class ControlConnectBase : public ControlBase
+class ControlConnectBase : public ControlButtons
 {
 public:
+       ///
+       enum DocTypes {
+               ///
+               LATEX,
+               ///
+               LITERATE,
+               ///
+               LINUXDOC,
+               ///
+               DOCBOOK
+       };
        ///
        ControlConnectBase(LyXView &, Dialogs &);
+       /// The View may need to know if the buffer is read-only.
+       bool isReadonly() const;
+       /// 
+       DocTypes docType() const;
 
 protected:
+       /// True if the dialog depends on the buffer, else false.
+       virtual bool isBufferDependent() const = 0;
+
        /// Connect signals
        virtual void connect();
        /// Disconnect signals
@@ -42,6 +79,8 @@ protected:
        */
        void redraw();
 
+       /// Get at the kernel Dispatch methods we need to apply() parameters.
+       LyXView & lv_;
        /// Contains the signals we have to connect to.
        Dialogs & d_;
        /// Hide connection.
@@ -64,6 +103,8 @@ public:
         ControlConnectBI(LyXView &, Dialogs &);
 
 protected:
+       ///
+       virtual bool isBufferDependent() const { return false; }
        /// Connect signals
        virtual void connect();
 };
@@ -79,102 +120,21 @@ public:
        ControlConnectBD(LyXView &, Dialogs &);
 
 protected:
-       /** Slot connected to update signal.
-           Bool indicates if a buffer switch took place.
-           Default behaviour is to ignore this and simply update().
-       */
-       virtual void updateSlot(bool) { update(); }
+       ///
+       virtual bool isBufferDependent() const { return true; }
        /// Connect signals
        virtual void connect();
        /// Disconnect signals
        virtual void disconnect();
 
 private:
+       /** Slot connected to update signal.
+           Bool indicates if a buffer switch took place.
+           Default behaviour is to ignore this and simply update().
+       */
+       virtual void updateSlot(bool) { update(); }
        /// Update connection.
        SigC::Connection u_;
 };
 
-/** Base class to control connection/disconnection of signals with the LyX
-    kernel for Inset dialogs.
- */
-class Inset;
-
-template <class Inset>
-class ControlConnectInset : public ControlConnectBD
-{
-public:
-       ///
-       ControlConnectInset(LyXView &, Dialogs &);
-
-protected:
-       /// Slot connected to update signal.
-       virtual void updateSlot(bool);
-       /// Connect signals
-       void connectInset(Inset * = 0);
-       /// Disconnect signals
-       virtual void disconnect();
-       ///
-       void disconnectInset();
-
-protected:
-       /// pointer to the inset passed through connectInset
-       Inset * inset_;
-
-private:
-       /// inset::hide connection.
-       SigC::Connection ih_;
-};
-
-
-template <class Inset>
-ControlConnectInset<Inset>::ControlConnectInset(LyXView & lv, Dialogs & d)
-       : ControlConnectBD(lv, d),
-         inset_(0), ih_(0)
-{}
-
-
-template <class Inset>
-void ControlConnectInset<Inset>::updateSlot(bool switched)
-{
-       if (switched)
-               hide();
-       else
-               update();
-}
-
-
-template <class Inset>
-void ControlConnectInset<Inset>::disconnect()
-{
-       inset_ = 0;
-       ih_.disconnect();
-       ControlConnectBD::disconnect();
-}
-
-
-template <class Inset>
-void ControlConnectInset<Inset>::connectInset(Inset * inset)
-{
-       // If connected to another inset, disconnect from it.
-       if (inset_) {
-               ih_.disconnect();
-               inset_ = 0;
-       }
-
-       if (inset) {
-               inset_ = inset;
-               ih_ = inset->hideDialog.connect(
-                       slot(this, &ControlConnectInset::hide));
-       }
-       connect();
-}
-
-
-template <class Inset>
-void ControlConnectInset<Inset>::disconnectInset()
-{
-       ih_.disconnect();
-}
-
-
 #endif // CONTROLCONNECTIONS_H