]> git.lyx.org Git - features.git/commitdiff
Reorganised, cleaned-up and improved documentation of controllers.
authorAngus Leeming <leeming@lyx.org>
Thu, 22 Mar 2001 11:24:36 +0000 (11:24 +0000)
committerAngus Leeming <leeming@lyx.org>
Thu, 22 Mar 2001 11:24:36 +0000 (11:24 +0000)
Implemented controller-view split for Copyright and Credits popups.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1803 a592a061-630c-0410-9148-cb99ea01b6c8

41 files changed:
src/frontends/controllers/ButtonController.h
src/frontends/controllers/ButtonPolicies.h
src/frontends/controllers/ChangeLog
src/frontends/controllers/ControlBase.C
src/frontends/controllers/ControlBase.h
src/frontends/controllers/ControlBibitem.h
src/frontends/controllers/ControlBibtex.h
src/frontends/controllers/ControlCharacter.C
src/frontends/controllers/ControlCharacter.h
src/frontends/controllers/ControlCitation.C
src/frontends/controllers/ControlCitation.h
src/frontends/controllers/ControlCommand.C
src/frontends/controllers/ControlCommand.h
src/frontends/controllers/ControlConnections.C
src/frontends/controllers/ControlConnections.h
src/frontends/controllers/ControlCopyright.C [new file with mode: 0644]
src/frontends/controllers/ControlCopyright.h [new file with mode: 0644]
src/frontends/controllers/ControlCredits.C [new file with mode: 0644]
src/frontends/controllers/ControlCredits.h [new file with mode: 0644]
src/frontends/controllers/ControlDialogs.h [new file with mode: 0644]
src/frontends/controllers/ControlLog.C
src/frontends/controllers/ControlLog.h
src/frontends/controllers/ControlVCLog.C
src/frontends/controllers/ControlVCLog.h
src/frontends/controllers/GUI.h [new file with mode: 0644]
src/frontends/controllers/Makefile.am
src/frontends/xforms/ChangeLog
src/frontends/xforms/Dialogs.C
src/frontends/xforms/FormCharacter.C
src/frontends/xforms/FormCharacter.h
src/frontends/xforms/FormCopyright.C
src/frontends/xforms/FormCopyright.h
src/frontends/xforms/FormCredits.C
src/frontends/xforms/FormCredits.h
src/frontends/xforms/form_copyright.C
src/frontends/xforms/form_copyright.h
src/frontends/xforms/form_credits.C
src/frontends/xforms/form_credits.h
src/frontends/xforms/forms/form_copyright.fd
src/frontends/xforms/forms/form_credits.fd
src/frontends/xforms/xforms_helpers.C

index c3fec57b00cdf7c79c960fb7792f3f44930a18be..891889e3a1cef8a82c34b9f50bac22c1ed1a0622 100644 (file)
@@ -1,5 +1,7 @@
-// -*- C++ -*-
-/* This file is part of
+/*
+ * \file ButtonController.h
+ *
+ * This file is part of
  * ====================================================== 
  *
  *           LyX, The Document Processor
@@ -8,8 +10,7 @@
  *
  * ======================================================
  *
- * \file ButtonController.h
- * \author Allan Rae
+ * \author Allan Rae, rae@lyx.org
  */
 
 #ifndef BUTTONCONTROLLER_H
index 8f386ca4222a79a75b7248ce3d8a360f3858d44f..bf8a758374ff4235bc7e10d65e9f11797ad9cc16 100644 (file)
@@ -1,8 +1,10 @@
-// -*- C++ -*-
-/* ButtonPolicies.h
+/*
+ * \file ButtonPolicies.h
+ * \author Allan Rae, rae@lyx.org
+ *
  * Provides a state machine implementation of the various button policies
  * used by the dialogs.
- * Author: Allan Rae <rae@lyx.org>
+ *
  * This file is part of
  * ======================================================
  *
index 91015ea4e0afcf041d595530ba3d44f528745324..10458537b9899a21016293720aef2751b007ffaa 100644 (file)
@@ -1,3 +1,50 @@
+2001-03-22  Angus Leeming  <a.leeming@ic.ac.uk>
+
+       * lots of header files: improved explanatory notes.
+
+       * ControlBase.[Ch]: removed LyXView & lv_ and methods using it.
+       ControlBase is now a class that only controls the interaction of the
+       View with the ButtonController.
+
+       * ControlConnections.[Ch]: added LyXView & lv_ and associated methods
+       to ControlConnectBase. The class controls the connection/disconnection
+       of signals from the LyX kernel and makes available the kernel (through
+       lv_) to daughter controller classes.
+       Moved out class ControlConnectInset to a new file ControlDialogs.h.
+
+       * ControlDialogs.h: new file. Contains the definition of two template
+       controller classes, ControlDialog and ControlInset (was
+       ControlConnectInset). ControlInset is a parent class for controllers
+       of inset-popups. ControlDialogs is the rather uninspired name for
+       the base class of all non-inset popups. (Eg, Document and Paragraph.)
+       ControlDialogs is reaching a state of maturity as several popups now use
+       it and its functionality becomes clear. ControlInset is still in a state
+       of flux. It is likely that functionality will be moved out of
+       ControlCommands and into it.
+
+       * GUI.h: new file. Moved all the template GUIXXX classes out of the
+       individual Controller header files and into one place. These classes
+       serve only as convenient wrappers to simplify code in the respective
+       frontends' Dialogs::c-tor. Now all derived from a templatised parent.
+
+       * ControlCharacter.[Ch] (show, update, hide):
+       * ControlLog.[Ch] (show, update, hide):
+       * ControlVCLog.[Ch] (show, update, hide): moved back into
+       the ControlDialogs base class.
+       (setParams, clearParams): new methods containing controller-specific
+       code to set/reset the parameters manipulated by the view.
+
+       * ControlCommand.[Ch] (clearParams): a new virtual method, by default
+       empty.
+       (hide): calls clearParams.
+
+       * ControlCitation.[Ch] (hide): renamed as clearParams, a method called
+       by ControlCommand::hide().
+
+       * ControlCopyright.[Ch]:
+       * ControlCredits.[Ch]: new files; controllers for the copyright and
+       credits popups, respectively.
+
 2001-03-21  Lars Gullik Bjønnes  <larsbj@trylle.birdstep.com>
 
        * ControlCharacter.C: fix typo
index 8d3ea3584687aca60c598ce1e23a0f5da31c54ec..f1d03f02dfde733c7e8cefd9b4f4215b7e0dbbd8 100644 (file)
 
 #include <config.h>
 
-#include "buffer.h"
 #include "ButtonController.h"
 #include "ControlBase.h"
-#include "LyXView.h"
-#include "support/LAssert.h"
 
 void ControlBase::ApplyButton()
 {
@@ -51,9 +48,3 @@ void ControlBase::RestoreButton()
        update();
        bc().undoAll();
 }
-
-
-bool ControlBase::isReadonly() const
-{
-       return lv_.buffer()->isReadonly();
-}
index d3c73ef7dc967463435447d437e468810cdec81f..84e4a1bfb1bb9ec4f538e77687cca3b3430c3305 100644 (file)
@@ -1,4 +1,3 @@
-// -*- C++ -*-
 /* This file is part of
  * ====================================================== 
  *
  * \file ControlBase.h
  * \author Angus Leeming <a.leeming@ic.ac.uk>
  *
- * The Controller connects the GUI-dependent popup to any appropriate
+ * ControlBase serves only to control the activation of the Ok, Apply, Cancel
+ * and Restore buttons on the View popup.
+ *
+ * More generally, the class is part of a hierarchy of controller classes
+ * that together connect the GUI-dependent popup to any appropriate
  * signals and dispatches any changes to the kernel.
- * It has no knowledge of the actual instantiation of the
+ *
+ * These controllers have no knowledge of the actual instantiation of the
  * GUI-dependent View and ButtonController, which should therefore
  * be created elsewhere.
+ *
  * Once created, the Controller will take care of their initialisation,
  * management and, ultimately, destruction.
  */
@@ -30,8 +35,6 @@
 #include "DialogBase.h" // This can go eventually
 #include "ButtonController.h"
 
-class Dialogs;
-class LyXView;
 class ViewBase;
 
 /** Abstract base class for Controllers with a ButtonController.
@@ -40,7 +43,7 @@ class ControlBase : public DialogBase
 {
 public: // methods
        ///
-       ControlBase(LyXView & lv) : lv_(lv) {}
+       ControlBase() {}
        ///
        virtual ~ControlBase() {};
 
@@ -54,9 +57,6 @@ public: // methods
        ///
        void RestoreButton();
 
-       /// The View may need to know if the buffer is read-only.
-       bool isReadonly() const;
-
        /** Allow the view to access the ButtonController. This method must be
            instantiated in a daughter class that creates the actual instance
            of the ButtonController. */
@@ -74,9 +74,6 @@ protected:
            instantiated in a daughter class that creates the actual instance
            of the View. */
        virtual ViewBase & view() = 0;
-       
-       /// Get at the kernel Dispatch methods we need to apply() parameters.
-       LyXView & lv_;
 };
 
 #include "ViewBase.h"
index f2c5176ac129a450ca7d0415057694a742f89c2f..27263b24259a9ac8b3abc013575a76eeafcaa9ac 100644 (file)
@@ -35,30 +35,4 @@ protected:
        virtual void apply();
 };
 
-/** This class instantiates and makes available the GUI-specific
-    ButtonController and View.
- */
-template <class GUIview, class GUIbc>
-class GUIBibitem : public ControlBibitem {
-public:
-       ///
-       GUIBibitem(LyXView &, Dialogs &);
-       ///
-       virtual ButtonControllerBase & bc() { return bc_; }
-       ///
-       virtual ViewBase & view() { return view_; }
-
-private:
-       ///
-       ButtonController<OkCancelReadOnlyPolicy, GUIbc> bc_;
-       ///
-       GUIview view_;
-};
-
-template <class GUIview, class GUIbc>
-GUIBibitem<GUIview, GUIbc>::GUIBibitem(LyXView & lv, Dialogs & d)
-       : ControlBibitem(lv, d),
-         view_(*this)
-{}
-
 #endif // CONTROLBIBITEM_H
index 42789a18c9f806137f7c2f959c4e390b2334d978..2be3c6c241f4401ecea4798dfe5b3bd4f4ffb260 100644 (file)
@@ -35,30 +35,4 @@ protected:
        virtual void apply();
 };
 
-/** This class instantiates and makes available the GUI-specific
-    ButtonController and View.
- */
-template <class GUIview, class GUIbc>
-class GUIBibtex : public ControlBibtex {
-public:
-       ///
-       GUIBibtex(LyXView &, Dialogs &);
-       ///
-       virtual ButtonControllerBase & bc() { return bc_; }
-       ///
-       virtual ViewBase & view() { return view_; }
-
-private:
-       ///
-       ButtonController<OkCancelReadOnlyPolicy, GUIbc> bc_;
-       ///
-       GUIview view_;
-};
-
-template <class GUIview, class GUIbc>
-GUIBibtex<GUIview, GUIbc>::GUIBibtex(LyXView & lv, Dialogs & d)
-       : ControlBibtex(lv, d),
-         view_(*this)
-{}
-
 #endif // CONTROLBIBTEX_H
index 13b0f116f4bdfe403ede2a5d104e235e25c2cd5c..0c5d73d7dda0b8c20efb2d30a3d7998826687a75 100644 (file)
@@ -28,46 +28,27 @@ using SigC::slot;
 using std::vector;
 
 ControlCharacter::ControlCharacter(LyXView & lv, Dialogs & d)
-       : ControlConnectBD(lv, d), font_(0), toggleall_(false)
+       : ControlDialog<ControlConnectBD>(lv, d),
+         font_(0), toggleall_(false)
 {
        d.showLayoutCharacter.connect(slot(this, &ControlCharacter::show));
        d.setUserFreeFont.connect(slot(this, &ControlCharacter::apply));
 }
 
 
-void ControlCharacter::show()
+void ControlCharacter::setParams()
 {
-       if (!lv_.view()->available()) return;
-
        if (font_) delete font_;
        font_ = new LyXFont(LyXFont::ALL_IGNORE);
-
-       bc().readOnly(isReadonly());
-       view().show();
 }
 
 
-void ControlCharacter::update()
-{
-       if (!lv_.view()->available()) return;
-
-       if (font_) delete font_;
-       font_ = new LyXFont(LyXFont::ALL_IGNORE);
-
-       bc().readOnly(isReadonly());
-       view().update();
-}
-
-
-void ControlCharacter::hide()
+void ControlCharacter::clearParams()
 {
        if (font_) {
                delete font_;
                font_ = 0;
        }
-
-       disconnect();
-       view().hide();
 }
 
 
index 92a671fbf3e8bce2fc53ca72f7cee691e70575a0..4eb44ca0b681d40d7aad34a71c204cbc526cb3d1 100644 (file)
 #pragma interface
 #endif
 
-#include "ControlConnections.h"
+#include "ControlDialogs.h"
 #include "lyxfont.h"
 #include "LColor.h"
 
 /** A controller for Character dialogs.
  */
-class ControlCharacter : public ControlConnectBD
+class ControlCharacter : public ControlDialog<ControlConnectBD>
 {
 public:
        ///
@@ -74,12 +74,10 @@ public:
 protected:
        /// Get changed parameters and Dispatch them to the kernel.
        virtual void apply();
-       /// Show the dialog.
-       virtual void show();
-       /// Update the dialog.
-       virtual void update();
-       /// Hide the dialog.
-       virtual void hide();
+       /// set the params before show or update.
+       virtual void setParams();
+       /// clean-up on hide.
+       virtual void clearParams();
 
 private:
        LyXFont * font_;
@@ -101,30 +99,4 @@ std::vector<ControlCharacter::ColorPair>  const getColorData();
 ///
 std::vector<string> const getLanguageData();
 
-/** This class instantiates and makes available the GUI-specific
-    ButtonController and View.
- */
-template <class GUIview, class GUIbc>
-class GUICharacter : public ControlCharacter {
-public:
-       ///
-       GUICharacter(LyXView &, Dialogs &);
-       ///
-       virtual ButtonControllerBase & bc() { return bc_; }
-       ///
-       virtual ViewBase & view() { return view_; }
-
-private:
-       ///
-       ButtonController<NoRepeatedApplyReadOnlyPolicy, GUIbc> bc_;
-       ///
-       GUIview view_;
-};
-
-template <class GUIview, class GUIbc>
-GUICharacter<GUIview, GUIbc>::GUICharacter(LyXView & lv, Dialogs & d)
-       : ControlCharacter(lv, d),
-         view_(*this)
-{}
-
 #endif // CONTROLCHARACTER_H
index 05a409e4c95a83a6f300d99c22fa6f2add8cb137..7a882f7f1766febb9ed9b224c798eecff752c45c 100644 (file)
@@ -45,10 +45,9 @@ ControlCitation::ControlCitation(LyXView & lv, Dialogs & d)
 }
 
 
-void ControlCitation::hide()
+void ControlCitation::clearParams()
 {
        bibkeysInfo_.clear();
-       ControlCommand::hide(); 
 }
 
 
index fc6b2c56a9ef3c31cf51a0d97380b464ee173a3d..166264ec5ed297fefd4fe3d7fa0212ef6ed3b705 100644 (file)
@@ -56,38 +56,11 @@ public:
        string const getBibkeyInfo(string const &);
 private:
        /// Clean up, then hide dialog.
-       virtual void hide();
+       virtual void clearParams();
        /// The info associated with each key
        InfoMap bibkeysInfo_;
 };
 
-
-/** This class instantiates and makes available the GUI-specific
-    ButtonController and View.
- */
-template <class GUIview, class GUIbc>
-class GUICitation : public ControlCitation {
-public:
-       ///
-       GUICitation(LyXView &, Dialogs &);
-       ///
-       virtual ButtonControllerBase & bc() { return bc_; }
-       ///
-       virtual ViewBase & view() { return view_; }
-
-private:
-       ///
-       ButtonController<NoRepeatedApplyReadOnlyPolicy, GUIbc> bc_;
-       ///
-       GUIview view_;
-};
-
-template <class GUIview, class GUIbc>
-GUICitation<GUIview, GUIbc>::GUICitation(LyXView & lv, Dialogs & d)
-       : ControlCitation(lv, d),
-         view_(*this)
-{}
-
 /** Helper functions, of possible use to all frontends
  */
 
index b728bed8de69b1895120a809b69519bee7cf66f7..1ed0c12fa68ef2a1f86685f76b2909825664df7d 100644 (file)
@@ -26,7 +26,7 @@
 #include "support/LAssert.h"
 
 ControlCommand::ControlCommand(LyXView & lv, Dialogs & d, kb_action ac)
-       : ControlConnectInset<InsetCommand>(lv, d),
+       : ControlInset<InsetCommand>(lv, d),
          params_(0), action_(ac)
 {}
 
@@ -84,6 +84,8 @@ void ControlCommand::hide()
                params_ = 0;
        }
 
+       clearParams();
+
        disconnect();
        view().hide();
 }
index b5373a49fb35092ec4ffdbe59b8813c0bbb9ec73..996a84d3264ffbac59c0c807d4bba9f9e7bf92c5 100644 (file)
  * \file ControlCommand.h
  * \author Angus Leeming <a.leeming@ic.ac.uk>
  *
- * Defines a Controller class for dialogs that create or modify
+ * ControlCommand is a controller class for dialogs that create or modify
  * an inset derived from InsetCommand.
- * Also defines the abstract base class from which the GUI-dependent Views
- * of this dialog should be derived.
+ *
+ * The class is likely to be changed as other Inset controllers are created
+ * and it becomes clear just what functionality can be moved back into
+ * ControlInset.
+ * 
  */
 
 #ifndef CONTROLCOMMAND_H
 #pragma interface
 #endif
 
-#include "ControlConnections.h"
+#include "ControlDialogs.h"
 #include "insets/insetcommand.h"
 #include "commandtags.h" // kb_action
 
 /** The Inset dialog controller. Connects/disconnects signals, launches 
     GUI-dependent View and returns the output from this View to the kernel.
  */
-class ControlCommand : public ControlConnectInset<InsetCommand>
+class ControlCommand : public ControlInset<InsetCommand>
 {
 public:
        ///
@@ -58,6 +61,10 @@ protected:
        /// Update dialog before showing it.
        virtual void update();
 
+       /// clean-up on hide.
+       virtual void clearParams() {}
+       
+
 private:
        /** A local copy of the inset's params.
            Memory is allocated only whilst the dialog is visible.
index a98c1d4df45d8028b28671cf25f07da1a2016d7b..050a00d9c85f85b24519c7afdca47ac4afc618ca 100644 (file)
 
 #include "ControlConnections.h"
 #include "Dialogs.h"
-#include "insets/lyxinset.h"
+#include "LyXView.h"
+#include "buffer.h"
 
 using SigC::slot;
 
 ControlConnectBase::ControlConnectBase(LyXView & lv, Dialogs & d)
-       : ControlBase(lv),
-         d_(d), h_(0), r_(0)
+       : lv_(lv), d_(d), h_(0), r_(0)
 {}
 
 
@@ -49,6 +49,15 @@ void ControlConnectBase::redraw()
 }
 
 
+bool ControlConnectBase::isReadonly() const
+{
+       if (!lv_.buffer())
+               return true;
+
+       return lv_.buffer()->isReadonly();
+}
+
+
 ControlConnectBI::ControlConnectBI(LyXView & lv, Dialogs & d)
         : ControlConnectBase(lv, d)
 {}
index 63a3b5883b78761bd3e162472ccd84b0ae39d164..7a295c9610a1d7d64cfde7217f86db75a3c290af 100644 (file)
@@ -1,4 +1,3 @@
-// -*- C++ -*-
 /* This file is part of
  * ====================================================== 
  *
@@ -10,6 +9,22 @@
  *
  * \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 popups interacting with the kernel through
+ * signals/slots will all be derived from ControlConnectBI or ControlConnectBD.
+ *
+ * A popup is classed as "Buffer Dependent" if its contents change with the
+ * buffer (document). An example would be the Citation popup. Such a popup
+ * would be derived, therefore, from ControlConnectBD.
+ *
+ * Conversely, a popup is "Buffer Independent" if its contents do not change
+ * when the buffer changes. An example would be the Copyright popup. Such a
+ * popup, is therefore derived from ControlConnectBI.
+ *
  */
 
 #ifndef CONTROLCONNECTIONS_H
@@ -21,6 +36,9 @@
 
 #include "ControlBase.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.
@@ -30,8 +48,13 @@ class ControlConnectBase : public ControlBase
 public:
        ///
        ControlConnectBase(LyXView &, Dialogs &);
+       /// The View may need to know if the buffer is read-only.
+       bool isReadonly() 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 +65,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 +89,8 @@ public:
         ControlConnectBI(LyXView &, Dialogs &);
 
 protected:
+       ///
+       virtual bool isBufferDependent() const { return false; }
        /// Connect signals
        virtual void connect();
 };
@@ -79,6 +106,8 @@ public:
        ControlConnectBD(LyXView &, Dialogs &);
 
 protected:
+       ///
+       virtual bool isBufferDependent() const { return true; }
        /** Slot connected to update signal.
            Bool indicates if a buffer switch took place.
            Default behaviour is to ignore this and simply update().
@@ -94,87 +123,4 @@ private:
        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(
-                       SigC::slot(this, &ControlConnectInset::hide));
-       }
-       connect();
-}
-
-
-template <class Inset>
-void ControlConnectInset<Inset>::disconnectInset()
-{
-       ih_.disconnect();
-}
-
-
 #endif // CONTROLCONNECTIONS_H
diff --git a/src/frontends/controllers/ControlCopyright.C b/src/frontends/controllers/ControlCopyright.C
new file mode 100644 (file)
index 0000000..0e78135
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * \file ControlCopyright.C
+ * Copyright 2000-2001 The LyX Team.
+ * See the file COPYING.
+ *
+ * \author Allan Rae
+ * \author Angus Leeming, a.leeming@.ac.uk
+ */
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+#include <config.h>
+
+#include "ControlCopyright.h"
+#include "Dialogs.h"
+#include "LyXView.h"
+#include "BufferView.h"
+
+using SigC::slot;
+
+ControlCopyright::ControlCopyright(LyXView & lv, Dialogs & d)
+       : ControlDialog<ControlConnectBI>(lv, d)
+{
+       d_.showCopyright.connect(slot(this, &ControlCopyright::show));
+}
+
+
+string const ControlCopyright::getCopyright() const
+{
+       return _("LyX is Copyright (C) 1995 by Matthias Ettrich,\n1995-2001 LyX Team");
+}
+
+string const ControlCopyright::getLicence() const
+{
+       return _("This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.");
+}
+
+string const ControlCopyright::getDisclaimer() const
+{
+       return _("LyX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\nSee the GNU General Public License for more details.\nYou should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.");
+}
diff --git a/src/frontends/controllers/ControlCopyright.h b/src/frontends/controllers/ControlCopyright.h
new file mode 100644 (file)
index 0000000..ef26fcb
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * \file ControlCopyright.C
+ * Copyright 2000-2001 The LyX Team.
+ * See the file COPYING.
+ *
+ * \author Allan Rae
+ * \author Angus Leeming, a.leeming@.ac.uk
+ */
+
+#ifndef CONTROLCOPYRIGHT_H
+#define CONTROLCOPYRIGHT_H
+
+#ifdef __GNUG__
+#pragma interface
+#endif
+
+#include "ControlDialogs.h"
+
+/** A controller for Copyright dialogs.
+ */
+class ControlCopyright : public ControlDialog<ControlConnectBI> {
+public:
+       ///
+       ControlCopyright(LyXView &, Dialogs &);
+
+       ///
+       string const getCopyright() const;
+       ///
+       string const getLicence() const;
+       ///
+       string const getDisclaimer() const;
+
+private:
+       /// not needed.
+       virtual void apply() {}
+};
+
+/** This class instantiates and makes available the GUI-specific
+    ButtonController and View.
+ */
+template <class GUIview, class GUIbc>
+class GUICopyright : public ControlCopyright {
+public:
+       ///
+       GUICopyright(LyXView &, Dialogs &);
+       ///
+       virtual ButtonControllerBase & bc() { return bc_; }
+       ///
+       virtual ViewBase & view() { return view_; }
+
+private:
+       ///
+       ButtonController<OkCancelPolicy, GUIbc> bc_;
+       ///
+       GUIview view_;
+};
+
+template <class GUIview, class GUIbc>
+GUICopyright<GUIview, GUIbc>::GUICopyright(LyXView & lv, Dialogs & d)
+       : ControlCopyright(lv, d),
+         view_(*this)
+{}
+#endif // CONTROLCOPYRIGHT_H
+
diff --git a/src/frontends/controllers/ControlCredits.C b/src/frontends/controllers/ControlCredits.C
new file mode 100644 (file)
index 0000000..22db81a
--- /dev/null
@@ -0,0 +1,72 @@
+/**
+ * \file ControlCredits.C
+ * Copyright 2001 The LyX Team.
+ * See the file COPYING.
+ *
+ * \author Edwin Leuven, leuven@fee.uva.nl
+ * \author Angus Leeming, a.leeming@.ac.uk
+ */
+
+#include <fstream>
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+#include <config.h>
+
+#include "ControlCredits.h"
+#include "Dialogs.h"
+#include "LyXView.h"
+#include "BufferView.h"
+#include "gettext.h"
+#include "support/filetools.h" // FileSearch
+
+using SigC::slot;
+using std::getline;
+using std::ifstream;
+using std::ios_base;
+using std::vector;
+
+ControlCredits::ControlCredits(LyXView & lv, Dialogs & d)
+       : ControlDialog<ControlConnectBI>(lv, d)
+{
+       d_.showCredits.connect(slot(this, &ControlCredits::show));
+}
+
+
+// needed for the browser
+extern string system_lyxdir;
+
+vector<string> const ControlCredits::getCredits() const
+{
+       vector<string> data;
+
+       string const name = FileSearch(system_lyxdir, "CREDITS");
+
+       bool found = (!name.empty());
+
+       if (found) {
+               ifstream in(name.c_str());
+               found = (in.get());
+
+               if (found) {
+                       in.seekg(0, ios_base::beg); // rewind to the beginning
+
+                       for(;;) {
+                               string line;
+                               getline(in, line);
+                               if (!in.good()) break;
+                               data.push_back(line);
+                       }
+               }
+       }
+
+       if (!found) {
+               data.push_back(_("ERROR: LyX wasn't able to read CREDITS file"));
+               data.push_back(_("Please install correctly to estimate the great"));
+               data.push_back(_("amount of work other people have done for the LyX project."));
+       }
+
+       return data;
+}
diff --git a/src/frontends/controllers/ControlCredits.h b/src/frontends/controllers/ControlCredits.h
new file mode 100644 (file)
index 0000000..193d3b0
--- /dev/null
@@ -0,0 +1,37 @@
+/**
+ * \file ControlCredits.h
+ * Copyright 2001 The LyX Team.
+ * See the file COPYING.
+ *
+ * \author Edwin Leuven, leuven@fee.uva.nl
+ * \author Angus Leeming <a.leeming@ic.ac.uk>
+ */
+
+#ifndef CONTROLCREDITS_H
+#define CONTROLCREDITS_H
+
+#include <vector>
+
+#ifdef __GNUG__
+#pragma interface
+#endif
+
+#include "ControlDialogs.h"
+
+/** A controller for the Credits dialogs.
+ */
+class ControlCredits : public ControlDialog<ControlConnectBI> {
+public:
+       ///
+       ControlCredits(LyXView &, Dialogs &);
+
+       ///
+       std::vector<string> const getCredits() const;
+
+private:
+       /// not needed.
+       virtual void apply() {}
+};
+
+#endif // CONTROLCREDITS_H
+
diff --git a/src/frontends/controllers/ControlDialogs.h b/src/frontends/controllers/ControlDialogs.h
new file mode 100644 (file)
index 0000000..4026d20
--- /dev/null
@@ -0,0 +1,193 @@
+/* This file is part of
+ * ====================================================== 
+ *
+ *           LyX, The Document Processor
+ *
+ *           Copyright 2001 The LyX Team.
+ *
+ * ======================================================
+ *
+ * \file ControlDialogs.h
+ * \author Angus Leeming <a.leeming@ic.ac.uk>
+ *
+ * ControlDialogs.h contains the definition of two template controller classes,
+ * ControlDialog and ControlInset, rather clumsy names for classes that
+ * control the showing, updating and hiding of popups.
+ *
+ * ControlInset is to be used as a parent class for popups that display and
+ * can perhaps modify the contents of an individual inset. An example being the
+ * ubiquitous Citation popup.
+ *
+ * ControlDialog is to be used as a parent class for popups that are not
+ * Inset-popups. (An ugly description I know, but I hope the meaning is clear!
+ * Can anyone do any better?) Examples would be the Document and Paragraph
+ * popups.
+ *
+ * At the moment, ControlDialog is reaching a state of maturity as several
+ * controllers are now derived from it and its required functionality
+ * becaomes clear.
+ *
+ * ControlInset is still in a state of flux as currently only InsetCommand-type
+ * insets have a controller.
+ *
+ */
+
+#ifndef CONTROLCONNECTIONS2_H
+#define CONTROLCONNECTIONS2_H
+
+#include "ControlConnections.h"
+#include "LyXView.h"
+
+/** Base class to control connection/disconnection of signals with the LyX
+    kernel for dialogs NOT used with insets.
+    The Base class will be either ControlConnectBI or ControlConnectBD.
+ */
+template <class Base>
+class ControlDialog : public Base
+{
+public:
+       ///
+       ControlDialog(LyXView &, Dialogs &);
+
+protected:
+       /// Show the dialog.
+       virtual void show();
+       /// Hide the dialog.
+       virtual void hide();
+       /// Update the dialog.
+       virtual void update();
+
+       /// set the params before show or update
+       virtual void setParams() {}
+       /// clean-up on hide.
+       virtual void clearParams() {}
+};
+
+
+/** Base class to control connection/disconnection of signals with the LyX
+    kernel for Inset dialogs.
+ */
+class Inset;
+
+template <class Inset>
+class ControlInset : public ControlConnectBD
+{
+public:
+       ///
+       ControlInset(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 Base>
+ControlDialog<Base>::ControlDialog(LyXView & lv, Dialogs & d)
+       : Base(lv, d)
+{}
+
+
+template <class Base>
+void ControlDialog<Base>::show()
+{
+       if (isBufferDependent() && !lv_.view()->available())
+               return;
+
+       setParams();
+
+       bc().readOnly(isReadonly());
+       view().show();
+}
+
+template <class Base>
+void ControlDialog<Base>::update()
+{
+       if (isBufferDependent() && !lv_.view()->available())
+               return;
+
+       setParams();
+       
+       bc().readOnly(isReadonly());
+       view().update();
+}
+
+template <class Base>
+void ControlDialog<Base>::hide()
+{
+       clearParams();
+
+       disconnect();
+       view().hide();
+}
+
+
+template <class Inset>
+ControlInset<Inset>::ControlInset(LyXView & lv, Dialogs & d)
+       : ControlConnectBD(lv, d),
+         inset_(0), ih_(0)
+{}
+
+
+template <class Inset>
+void ControlInset<Inset>::updateSlot(bool switched)
+{
+       if (switched)
+               hide();
+       else
+               update();
+}
+
+
+template <class Inset>
+void ControlInset<Inset>::disconnect()
+{
+       inset_ = 0;
+       ih_.disconnect();
+       ControlConnectBD::disconnect();
+}
+
+
+template <class Inset>
+void ControlInset<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(
+                       SigC::slot(this, &ControlInset::hide));
+       }
+       connect();
+}
+
+
+template <class Inset>
+void ControlInset<Inset>::disconnectInset()
+{
+       ih_.disconnect();
+}
+
+
+#endif // CONTROLCONNECTIONS2_H
index 5e0a7a41e886ca569f24ff3de7538d86644a92ff..40fee20f9b724479665d8e6eb3864021f38bb50c 100644 (file)
 #include "Dialogs.h"
 #include "lyxrc.h"
 
-using std::make_pair;
 using SigC::slot;
 
 ControlLog::ControlLog(LyXView & lv, Dialogs & d)
-       : ControlConnectBD(lv, d)
+       : ControlDialog<ControlConnectBD>(lv, d)
 {
        d_.showLogFile.connect(slot(this, &ControlLog::show));
 }
 
 
-void ControlLog::show()
+void ControlLog::setParams()
 {
-       if (!lv_.view()->available())
-               return;
-
-       logfile_ = lv_.view()->buffer()->getLogName();
-
-       bc().readOnly(isReadonly());
-       view().show();
-}
-
-
-void ControlLog::update()
-{
-       if (!lv_.view()->available())
-               return;
-
        logfile_ = lv_.view()->buffer()->getLogName();
-       
-       bc().readOnly(isReadonly());
-       view().update();
 }
 
 
-void ControlLog::hide()
+void ControlLog::clearParams()
 {
        logfile_.second.erase();
-       disconnect();
-       view().hide();
 }
index 63d66e6540ad1be6fbb2aa8ef554e2e3d3d40ba4..22f02707401935dec2c253523daee683fe393312 100644 (file)
 #pragma interface
 #endif
 
-#include "ControlConnections.h"
+#include "ControlDialogs.h"
 #include "buffer.h" // Buffer::LogType
 
 /**
  * A controller for a read-only text browser.
  */
-class ControlLog : public ControlConnectBD {
+class ControlLog : public ControlDialog<ControlConnectBD> {
 public:
        ///
        ControlLog(LyXView &, Dialogs &);
@@ -39,42 +39,13 @@ public:
 protected:
        ///
        virtual void apply() {}
-       /// Show the dialog.
-       virtual void show();
-       /// Update the dialog.
-       virtual void update();
-       /// Hide the dialog.
-       virtual void hide();
+       /// set the params before show or update
+       virtual void setParams();
+       /// clean-up on hide.
+       virtual void clearParams();
 
 private:
        std::pair<Buffer::LogType, string> logfile_;
 };
 
-
-/** A class to instantiate and make available the GUI-specific
-    ButtonController and View.
- */
-template <class GUIview, class GUIbc>
-class GUILog : public ControlLog {
-public:
-       ///
-       GUILog(LyXView &, Dialogs &);
-       ///
-       virtual ButtonControllerBase & bc() { return bc_; }
-       ///
-       virtual ViewBase & view() { return view_; }
-
-private:
-       ///
-       ButtonController<OkCancelPolicy, GUIbc> bc_;
-       ///
-       GUIview view_;
-};
-
-template <class GUIview, class GUIbc>
-GUILog<GUIview, GUIbc>::GUILog(LyXView & lv, Dialogs & d)
-       : ControlLog(lv, d),
-         view_(*this)
-{}
-
 #endif // CONTROLLOG_H
index f6d357abd0c920f7a7e7fd6e56eb673c6c8f38ba..791f83b1f03b60befe1c0fb2386c71ca2b9dc32f 100644 (file)
 using SigC::slot;
 
 ControlVCLog::ControlVCLog(LyXView & lv, Dialogs & d)
-       : ControlConnectBD(lv, d)
+       : ControlDialog<ControlConnectBD>(lv, d)
 {
        d_.showVCLogFile.connect(slot(this, &ControlVCLog::show));
 }
 
 
-void ControlVCLog::show()
+void ControlVCLog::setParams()
 {
-       if (!lv_.view()->available())
-               return;
-
        logfile_ = lv_.view()->buffer()->lyxvc.getLogFile();
-
-       bc().readOnly(isReadonly());
-       view().show();
-}
-
-
-void ControlVCLog::update()
-{
-       if (!lv_.view()->available())
-               return;
-
-       logfile_ = lv_.view()->buffer()->lyxvc.getLogFile();
-       
-       bc().readOnly(isReadonly());
-       view().update();
-
-       lyx::unlink(logfile_); 
 }
 
 
-void ControlVCLog::hide()
+void ControlVCLog::clearParams()
 {
        logfile_.erase();
-       disconnect();
-       view().hide();
 }
index 6da6c7b96d7b2dd88a88983da7d7c11e1d22aa72..9644225dc5f0207b9be2be8f14ea73b074198aa3 100644 (file)
 #pragma interface
 #endif
 
-#include "ControlConnections.h"
+#include "ControlDialogs.h"
 
 /**
  * A controller for the Version Control log viewer.
  */
-class ControlVCLog : public ControlConnectBD {
+class ControlVCLog : public ControlDialog<ControlConnectBD> {
 public:
        ///
        ControlVCLog(LyXView &, Dialogs &);
@@ -37,42 +37,13 @@ public:
 protected:
        ///
        virtual void apply() {}
-       /// Show the dialog.
-       virtual void show();
-       /// Update the dialog.
-       virtual void update();
-       /// Hide the dialog.
-       virtual void hide();
+       /// set the params before show or update
+       virtual void setParams();
+       /// clean-up on hide.
+       virtual void clearParams();
 
 private:
        string logfile_;
 };
 
-
-/** A class to instantiate and make available the GUI-specific
-    ButtonController and View.
- */
-template <class GUIview, class GUIbc>
-class GUIVCLog : public ControlVCLog {
-public:
-       ///
-       GUIVCLog(LyXView &, Dialogs &);
-       ///
-       virtual ButtonControllerBase & bc() { return bc_; }
-       ///
-       virtual ViewBase & view() { return view_; }
-
-private:
-       ///
-       ButtonController<OkCancelPolicy, GUIbc> bc_;
-       ///
-       GUIview view_;
-};
-
-template <class GUIview, class GUIbc>
-GUIVCLog<GUIview, GUIbc>::GUIVCLog(LyXView & lv, Dialogs & d)
-       : ControlVCLog(lv, d),
-         view_(*this)
-{}
-
 #endif // CONTROLVCLOG_H
diff --git a/src/frontends/controllers/GUI.h b/src/frontends/controllers/GUI.h
new file mode 100644 (file)
index 0000000..8d934df
--- /dev/null
@@ -0,0 +1,139 @@
+/**
+ * \file GUI.h
+ * Copyright 2001 The LyX Team.
+ * See the file COPYING.
+ *
+ * \author Angus Leeming <a.leeming@ic.ac.uk>
+ */
+
+#ifndef GUI_H
+#define GUI_H
+
+/** This class instantiates and makes available the GUI-specific
+    ButtonController and View.
+ */
+template <class Controller, class GUIview, class Policy, class GUIbc>
+class GUI : public Controller {
+public:
+       ///
+       GUI(LyXView & lv, Dialogs & d) : Controller(lv, d), view_(*this) {}
+       ///
+       virtual ButtonControllerBase & bc() { return bc_; }
+       ///
+       virtual ViewBase & view() { return view_; }
+
+private:
+       ///
+       ButtonController<Policy, GUIbc> bc_;
+       ///
+       GUIview view_;
+};
+
+/// Forward declaration of ButtonPolicies
+class OkCancelPolicy;
+class OkCancelReadOnlyPolicy;
+class NoRepeatedApplyReadOnlyPolicy;
+
+
+/** Specialization for Bibitem dialog
+ */
+class ControlBibitem;
+
+template <class GUIview, class GUIbc>
+class GUIBibitem :
+       public GUI<ControlBibitem, GUIview, OkCancelReadOnlyPolicy, GUIbc> {
+public:
+       ///
+       GUIBibitem(LyXView & lv, Dialogs & d)
+               : GUI<ControlBibitem, GUIview, OkCancelReadOnlyPolicy, GUIbc>(lv, d) {}
+};
+
+
+/** Specialization for Bibtex dialog
+ */
+class ControlBibtex;
+
+template <class GUIview, class GUIbc>
+class GUIBibtex :
+       public GUI<ControlBibtex, GUIview, OkCancelReadOnlyPolicy, GUIbc> {
+public:
+       ///
+       GUIBibtex(LyXView & lv, Dialogs & d)
+               : GUI<ControlBibtex, GUIview, OkCancelReadOnlyPolicy, GUIbc>(lv, d) {}
+};
+
+
+/** Specialization for Character dialog
+ */
+class ControlCharacter;
+
+template <class GUIview, class GUIbc>
+class GUICharacter : public GUI<ControlCharacter, GUIview,
+                               NoRepeatedApplyReadOnlyPolicy, GUIbc>
+{
+public:
+       ///
+       GUICharacter(LyXView & lv, Dialogs & d)
+               : GUI<ControlCharacter, GUIview,
+                     NoRepeatedApplyReadOnlyPolicy, GUIbc>(lv, d) {}
+};
+
+
+/** Specialization for Citation dialog
+ */
+class ControlCitation;
+
+template <class GUIview, class GUIbc>
+class GUICitation : public GUI<ControlCitation, GUIview,
+                              NoRepeatedApplyReadOnlyPolicy, GUIbc>
+{
+public:
+       ///
+       GUICitation(LyXView & lv, Dialogs & d)
+               : GUI<ControlCitation, GUIview,
+                     NoRepeatedApplyReadOnlyPolicy, GUIbc>(lv, d) {}
+};
+
+
+/** Specialization for Credits dialog
+ */
+class ControlCredits;
+
+template <class GUIview, class GUIbc>
+class GUICredits :
+       public GUI<ControlCredits, GUIview, OkCancelPolicy, GUIbc> {
+public:
+       ///
+       GUICredits(LyXView & lv, Dialogs & d)
+               : GUI<ControlCredits, GUIview, OkCancelPolicy, GUIbc>(lv, d) {}
+};
+
+
+/** Specialization for Log dialog
+ */
+class ControlLog;
+
+template <class GUIview, class GUIbc>
+class GUILog :
+       public GUI<ControlLog, GUIview, OkCancelPolicy, GUIbc> {
+public:
+       ///
+       GUILog(LyXView & lv, Dialogs & d)
+               : GUI<ControlLog, GUIview, OkCancelPolicy, GUIbc>(lv, d) {}
+};
+
+
+/** Specialization for VCLog dialog
+ */
+class ControlVCLog;
+
+template <class GUIview, class GUIbc>
+class GUIVCLog :
+       public GUI<ControlVCLog, GUIview, OkCancelPolicy, GUIbc> {
+public:
+       ///
+       GUIVCLog(LyXView & lv, Dialogs & d)
+           : GUI<ControlVCLog, GUIview, OkCancelPolicy, GUIbc>(lv, d) {}
+};
+
+#endif // GUI_H
index bda959c5f7940957feffd53aa038b3765f379215..704b535f4a95007cb5d93f3b4cdfdefd9f704193 100644 (file)
@@ -28,10 +28,15 @@ libcontrollers_la_SOURCES=\
        ControlCommand.h \
        ControlConnections.C \
        ControlConnections.h \
+       ControlCopyright.C \
+       ControlCredits.h \
+       ControlCredits.C \
+       ControlCopyright.h \
        ControlLog.C \
        ControlLog.h \
        ControlVCLog.C \
        ControlVCLog.h \
+       GUI.h \
        ViewBase.h \
        helper_funcs.C \
        helper_funcs.h
index f01740649d27b4a123c10477f8c119a7afff15cb..8890cc9f7151b6cd120c3fc0e0e0be4dacfd73b9 100644 (file)
@@ -1,3 +1,17 @@
+2001-03-22  Angus Leeming  <a.leeming@ic.ac.uk>
+
+       * FormCopyright.[Ch]:
+       * forms/form_copyright.fd: implemented controller-view split.
+
+       * FormCredits.[Ch]:
+       * forms/form_credits.fd: implemented controller-view split.
+
+       * Dialogs.C: associated changes.
+
+       * xforms_helpers.C (formatted): improved the function so that it now
+       repects '\n' characters in the input string. Ie, the user can now
+       specify line breaks explicitly.
+
 2001-03-21  Angus Leeming  <a.leeming@ic.ac.uk>
 
        * FormCharacter.[Ch]:
 
        * Dialogs.C: associated changes.
 
-2001-03-19  Angus Leeming  <a.leeming@ic.ac.uk>
-
-       * FormBibtex.[Ch]:
-       * forms/form_bibtex.fd: implemented controller-view split.
-
-       * Dialogs.C: associated changes.
-
 2001-03-19  Angus Leeming  <a.leeming@ic.ac.uk>
 
        * FormBaseDeprecated.[Ch]: rename title as title_.
index 23dd91174f72aa0272e3424b80c2782baad3fecc..a9461eb57311a9b04bcd3d78b87c52bf16d079be 100644 (file)
@@ -4,7 +4,7 @@
  *           LyX, The Document Processor
  *
  *           Copyright 1995 Matthias Ettrich
- *           Copyright 1995-2000 The LyX Team.
+ *           Copyright 1995-2001 The LyX Team.
  *
  * ======================================================
  */
 #include "ControlBibtex.h"
 #include "ControlCharacter.h"
 #include "ControlCitation.h"
+#include "ControlCopyright.h"
+#include "ControlCredits.h"
 #include "ControlLog.h"
 #include "ControlVCLog.h"
 
-#include "combox.h"       // needed for clean destructtion of boost::scoped ptr
+#include "GUI.h"
+
+#include "combox.h"       // needed for clean destruction of boost::scoped_ptr
 #include "form_bibitem.h"
 #include "form_bibtex.h"
 #include "form_browser.h"
 #include "form_character.h"
 #include "form_citation.h"
+#include "form_copyright.h"
+#include "form_credits.h"
 
 #include "FormBibitem.h"
 #include "FormBibtex.h"
 #include "FormCharacter.h"
 #include "FormCitation.h"
+#include "FormCopyright.h"
+#include "FormCredits.h"
 #include "FormLog.h"
 #include "FormVCLog.h"
 
-#include "FormCopyright.h"
-#include "FormCredits.h"
 #include "FormDocument.h"
 #include "FormError.h"
 #include "FormExternal.h" 
@@ -74,11 +80,11 @@ Dialogs::Dialogs(LyXView * lv)
        add(new GUIBibtex<FormBibtex, xformsBC>(*lv, *this));
        add(new GUICharacter<FormCharacter, xformsBC>(*lv, *this));
        add(new GUICitation<FormCitation, xformsBC>(*lv, *this));
+       add(new GUICopyright<FormCopyright, xformsBC>(*lv, *this));
+       add(new GUICredits<FormCredits, xformsBC>(*lv, *this));
        add(new GUILog<FormLog, xformsBC>(*lv, *this));
        add(new GUIVCLog<FormVCLog, xformsBC>(*lv, *this));
 
-       add(new FormCopyright(lv, this));
-       add(new FormCredits(lv, this));
        add(new FormDocument(lv, this));
        add(new FormError(lv, this));
        add(new FormExternal(lv, this));
index 22779640769e0a3e084ca67856e085dda7b2479d..fbd953b6550dcc16ba5aeedb03510f6f8f839999 100644 (file)
@@ -81,12 +81,13 @@ void FormCharacter::build()
        fl_addto_choice(dialog_->choice_color, choice.c_str());
 
        // xforms appears to need this to prevent a crash...
-       // fl_addto_choice(dialog_->choice_language,
-       //              _(" English %l| German | French "));
+       fl_addto_choice(dialog_->choice_language, "prevent crash");
 
        // insert default language box manually
        fl_addto_form(dialog_->form);
                FL_OBJECT * ob = dialog_->choice_language;
+               fl_deactivate_object(dialog_->choice_language);
+
                combo_language2_.reset(new Combox(FL_COMBOX_DROPLIST));
                combo_language2_->add(ob->x, ob->y, ob->w, ob->h, 250);
                combo_language2_->shortcut("#L", 1);
index 03ddeaffbe80f75ce02b173a347cb4b54f6905c2..493b12ff511fdcc3c38f955d96e17af2e5f3bc4a 100644 (file)
@@ -1,4 +1,3 @@
-// -*- C++ -*-
 /** 
  * \file FormCharacter.h
  * Copyright 2001 The LyX Team.
index fb182f7231d4f2166b16340a39d427f7bcd120eb..1a42f0d6f1f1cb7d7eb2a83e05b68beee83f64ee 100644 (file)
@@ -1,57 +1,48 @@
-/* FormCopyright.C
- * FormCopyright Interface Class Implementation
+/*
+ * \file FormCopyright.C
+ * Copyright 2000-2001 The LyX Team.
+ * See the file COPYING.
+ *
+ * \author Allan Rae
+ * \author Angus Leeming, a.leeming@.ac.uk
  */
 
-#include <config.h>
-
-#include FORMS_H_LOCATION
-
 #ifdef __GNUG__
 #pragma implementation
 #endif
 
-#include "Dialogs.h"
-#include "LyXView.h"
-#include "form_copyright.h"
+#include <config.h>
+
+#include "xformsBC.h"
+#include "ControlCopyright.h"
 #include "FormCopyright.h"
+#include "form_copyright.h"
 #include "xforms_helpers.h"
 
-using SigC::slot;
-
-FormCopyright::FormCopyright( LyXView * lv, Dialogs * d        )
-       : FormBaseBI(lv, d, _("Copyright and Warranty"))
-{
-       // 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->showCopyright.connect(slot(this, &FormCopyright::show));
-}
+typedef FormCB<ControlCopyright, FormDB<FD_form_copyright> > base_class;
 
-
-FL_FORM * FormCopyright::form() const
-{
-       if (dialog_.get()) return dialog_->form;
-       return 0;
-}
+FormCopyright::FormCopyright(ControlCopyright & c)
+       : base_class(c, _("Copyright and Warranty"))
+{}
 
 
 void FormCopyright::build()
 {
        dialog_.reset(build_copyright());
 
-       string str = _("LyX is Copyright (C) 1995 by Matthias Ettrich, 1995-2001 LyX Team");
-       str = formatted(str, dialog_->text_copyright->w-10,
-                       FL_NORMAL_SIZE, FL_NORMAL_STYLE);
+       string str = formatted(controller().getCopyright(),
+                              dialog_->text_copyright->w-10);
+
        fl_set_object_label(dialog_->text_copyright, str.c_str());
 
-       str = _("This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.");
-       str = formatted(str, dialog_->text_licence->w-10,
-                       FL_NORMAL_SIZE, FL_NORMAL_STYLE);
+       str = formatted(controller().getLicence(),
+                       dialog_->text_licence->w-10);
+
        fl_set_object_label(dialog_->text_licence, str.c_str());
 
-       str = _("LyX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.");
-       str = formatted(str, dialog_->text_disclaimer->w-10,
-                       FL_NORMAL_SIZE, FL_NORMAL_STYLE);
+       str = formatted(controller().getDisclaimer(),
+                       dialog_->text_disclaimer->w-10);
+
        fl_set_object_label(dialog_->text_disclaimer, str.c_str());
        
         // Manage the cancel/close button
index edd124628ab0999defe09a17ded13ee07d78e99e..a11c95725d03653aa45faaa917443a7323a9bc10 100644 (file)
@@ -1,59 +1,51 @@
-// -*- C++ -*-
-/* FormCopyright.h
- * FormCopyright Interface Class
+/**
+ * \file FormCopyright.h
  * This file is part of
  * ====================================================== 
  *
  *           LyX, The Document Processor
  *
  *           Copyright 1995 Matthias Ettrich
- *           Copyright 1995-2000 The LyX Team.
+ *           Copyright 1995-2001 The LyX Team.
  *
- *           This file Copyright 2000
+ *           This file Copyright 2000-2001
  *           Allan Rae
  * ======================================================
+ *
+ * \author Allan Rae
+ * \author Angus Leeming, a.leeming@.ac.uk
  */
 
 #ifndef FORMCOPYRIGHT_H
 #define FORMCOPYRIGHT_H
 
-#include <boost/smart_ptr.hpp>
-
 #ifdef __GNUG__
 #pragma interface
 #endif
 
-#include "FormBaseDeprecated.h"
+#include "FormBase.h"
 
+class ControlCopyright;
 struct FD_form_copyright;
 
 /** This class provides an XForms implementation of the FormCopyright Dialog.
  */
-class FormCopyright : public FormBaseBI {
+class FormCopyright
+       : public FormCB<ControlCopyright, FormDB<FD_form_copyright> > {
 public:
-       /// #FormCopyright x(LyXFunc ..., Dialogs ...);#
-       FormCopyright(LyXView *, Dialogs *);
+       ///
+       FormCopyright(ControlCopyright &);
+
 private:
-       /// Pointer to the actual instantiation of the ButtonController.
-       virtual xformsBC & bc();
+       /// not needed.
+       virtual void apply() {}
+       /// not needed.
+       virtual void update() {}
        /// Build the dialog
        virtual void build();
-       /// Pointer to the actual instantiation of the xforms form
-       virtual FL_FORM * form() const;
+
        /// Fdesign generated method
        FD_form_copyright * build_copyright();
-
-       /// Real GUI implementation.
-       boost::scoped_ptr<FD_form_copyright> dialog_;
-       /// The ButtonController
-       ButtonController<OkCancelPolicy, xformsBC> bc_;
 };
 
-
-inline
-xformsBC & FormCopyright::bc()
-{
-       return bc_;
-}
-#endif
-
+#endif // FORMCOPYRIGHT_H
index 09251155a76914e9ab2df66fec1aa301a1881b30..0a0aed3c00daa382711d680a144fab6190f0bd49 100644 (file)
@@ -4,69 +4,43 @@
  * See the file COPYING.
  *
  * \author Edwin Leuven, leuven@fee.uva.nl
+ * \author Angus Leeming, a.leeming@.ac.uk
  */
 
-#include <config.h>
-
-#include FORMS_H_LOCATION
-
 #ifdef __GNUG__
 #pragma implementation
 #endif
 
-#include "Dialogs.h"
-#include "LyXView.h"
-#include "form_credits.h"
+#include <config.h>
+
+#include "xformsBC.h"
+#include "ControlCredits.h"
 #include "FormCredits.h"
+#include "form_credits.h"
 #include "xforms_helpers.h"
-#include "support/filetools.h"
 
-using SigC::slot;
+using std::vector;
 
-FormCredits::FormCredits( LyXView * lv, Dialogs * d )
-  : FormBaseBI(lv, d, _("Credits"))
-{
-   // 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->showCredits.connect(slot(this, &FormCredits::show));
-}
+typedef FormCB<ControlCredits, FormDB<FD_form_credits> > base_class;
 
+FormCredits::FormCredits(ControlCredits & c)
+       : base_class(c, _("Credits"))
+{}
 
-FL_FORM * FormCredits::form() const
-{
-   if (dialog_.get()) 
-          return dialog_->form;
-   return 0;
-}
-
-// needed for the browser
-extern string system_lyxdir;
 
 void FormCredits::build()
 {
-   dialog_.reset(build_credits());
+       dialog_.reset(build_credits());
+
+       // Manage the cancel/close button
+       bc().setCancel(dialog_->button_cancel);
+       bc().refresh();
+
+       vector<string> data = controller().getCredits();
 
-   // Manage the cancel/close button
-   bc_.setCancel(dialog_->button_cancel);
-   bc_.refresh();
-               
-   /* read the credits into the browser */ 
-               
-   /* try file LYX_DIR/CREDITS */ 
-   string real_file = AddName (system_lyxdir, "CREDITS");
-   
-   if (!fl_load_browser(dialog_->browser_credits,
-                       real_file.c_str())) {
-      fl_add_browser_line(dialog_->browser_credits,
-                         _("ERROR: LyX wasn't able to read"
-                           " CREDITS file"));
-      fl_add_browser_line(dialog_->browser_credits, "");
-      fl_add_browser_line(dialog_->browser_credits,
-                         _("Please install correctly to estimate"
-                           " the great"));
-      fl_add_browser_line(dialog_->browser_credits,
-                         _("amount of work other people have done"
-                           " for the LyX project."));
-   }
+       /* read the credits into the browser */ 
+       for (vector<string>::const_iterator it = data.begin();
+            it < data.end(); ++it) {
+               fl_add_browser_line(dialog_->browser_credits, it->c_str());
+       }
 }
index 50adc741247344d3bcdfc525380f4f89dd2ea319..712c81502346a05a21e09c8380ddb1affc70b055 100644 (file)
@@ -4,49 +4,39 @@
  * See the file COPYING.
  *
  * \author Edwin Leuven, leuven@fee.uva.nl
+ * \author Angus Leeming, a.leeming@.ac.uk
  */
 
 #ifndef FORMCREDITS_H
 #define FORMCREDITS_H
 
-#include <boost/smart_ptr.hpp>
-
 #ifdef __GNUG__
 #pragma interface
 #endif
 
-#include "FormBaseDeprecated.h"
+#include "FormBase.h"
 
+class ControlCredits;
 struct FD_form_credits;
 
 /** This class provides an XForms implementation of the FormCredits Dialog.
  */
-class FormCredits : public FormBaseBI {
+class FormCredits : public FormCB<ControlCredits, FormDB<FD_form_credits> > {
 public:
-       /// #FormCopyright x(LyXFunc ..., Dialogs ...);#
-       FormCredits(LyXView *, Dialogs *);
+       ///
+       FormCredits(ControlCredits &);
 
 private:
-       /// Pointer to the actual instantiation of the ButtonController.
-       virtual xformsBC & bc();
+       /// not needed.
+       virtual void apply() {}
+       /// not needed.
+       virtual void update() {}
        /// Build the dialog
        virtual void build();
-       /// Pointer to the actual instantiation of the xforms form
-       virtual FL_FORM * form() const;
+
        /// Fdesign generated method
        FD_form_credits * build_credits();
-
-       /// Real GUI implementation.
-       boost::scoped_ptr<FD_form_credits> dialog_;
-       /// The ButtonController
-       ButtonController<OkCancelPolicy, xformsBC> bc_;
 };
 
-
-inline
-xformsBC & FormCredits::bc()
-{
-       return bc_;
-}
 #endif
 
index 371744a8ec3154c61617c320cdcc2e7da3640d61..3d9425c06e5e0a32e9bdcd7278112559c6e18091 100644 (file)
@@ -45,7 +45,7 @@ FD_form_copyright * FormCopyright::build_copyright()
     fl_set_object_lsize(obj, FL_NORMAL_SIZE);
     fl_set_object_gravity(obj, FL_South, FL_South);
     fl_set_object_resize(obj, FL_RESIZE_NONE);
-    fl_set_object_callback(obj, C_FormBaseDeprecatedCancelCB, 0);
+    fl_set_object_callback(obj, C_FormBaseCancelCB, 0);
   fl_end_form();
 
   fdui->form->fdui = fdui;
index f98680d5f9e3a5ae36d0bb33900a7c9042843220..ee94cb3cd667776c31d29e0563987983d40ed50d 100644 (file)
@@ -5,7 +5,7 @@
 #define FD_form_copyright_h_
 
 /** Callbacks, globals and object handlers **/
-extern  "C" void C_FormBaseDeprecatedCancelCB(FL_OBJECT *, long);
+extern  "C" void C_FormBaseCancelCB(FL_OBJECT *, long);
 
 
 /**** Forms and Objects ****/
index d6e86320a10455d5583e8ffa8ad49586d5b41e38..7a36aad2852e412f16b07907e4eff9772b396603 100644 (file)
@@ -29,7 +29,7 @@ FD_form_credits * FormCredits::build_credits()
     fl_set_object_lsize(obj, FL_NORMAL_SIZE);
     fl_set_object_gravity(obj, FL_South, FL_South);
     fl_set_object_resize(obj, FL_RESIZE_NONE);
-    fl_set_object_callback(obj, C_FormBaseDeprecatedCancelCB, 0);
+    fl_set_object_callback(obj, C_FormBaseCancelCB, 0);
   obj = fl_add_text(FL_NORMAL_TEXT, 10, 40, 480, 30, _("Matthias"));
     fl_set_object_lsize(obj, FL_NORMAL_SIZE);
     fl_set_object_lalign(obj, FL_ALIGN_CENTER|FL_ALIGN_INSIDE);
index a77b214469ca6cd1daed01b81ce234c01adffafb..ef9791d423f9aa49420c277fe8e649ac7d8cac5e 100644 (file)
@@ -5,7 +5,7 @@
 #define FD_form_credits_h_
 
 /** Callbacks, globals and object handlers **/
-extern  "C" void C_FormBaseDeprecatedCancelCB(FL_OBJECT *, long);
+extern  "C" void C_FormBaseCancelCB(FL_OBJECT *, long);
 
 
 /**** Forms and Objects ****/
index 1c4297503cac29ee4cffb6ee7d7d50e67c6e26cd..cc16d01bd38d91bb1c1c0113e6ae5af5af9f09fa 100644 (file)
@@ -99,7 +99,7 @@ shortcut:
 resize: FL_RESIZE_NONE
 gravity: FL_South FL_South
 name: button_cancel
-callback: C_FormBaseDeprecatedCancelCB
+callback: C_FormBaseCancelCB
 argument: 0
 
 ==============================
index 6f489eecc3ace1c4275556473c0599246d44d680..56bce85c7d1dcb090187cc565014df8a48e38a4e 100644 (file)
@@ -45,7 +45,7 @@ shortcut: ^M
 resize: FL_RESIZE_NONE
 gravity: FL_South FL_South
 name: button_cancel
-callback: C_FormBaseDeprecatedCancelCB
+callback: C_FormBaseCancelCB
 argument: 0
 
 --------------------
index 77b9b3ee7b27bd6133c29397b4df2b42080902e7..f8601b75179bfb0089d6099935dc20bf4cc0a1e7 100644 (file)
@@ -51,34 +51,50 @@ string formatted(string const & sin, int w, int size, int style)
                if ((*sit) == ' ' || (*sit) == '\n') {
                        sentence.push_back(word);
                        word.erase();
+                       if ((*sit) == '\n') word += '\n';
+                       
                } else {
                        word += (*sit);
                }
        }
+
        // Flush remaining contents of word
        if (!word.empty() ) sentence.push_back(word);
 
-       string line, l1;
+       string line, line_plus_word;
        for (vector<string>::const_iterator vit = sentence.begin();
             vit != sentence.end(); ++vit) {
-               if (!l1.empty() ) l1 += ' ';
-               l1 += (*vit);
-               int length = fl_get_string_width(style, size, l1.c_str(),
-                                                int(l1.length()));
+               string word = *vit;
+
+               char c = word[0];
+               if (c == '\n') {
+                       sout += line + '\n';
+                       word = word.substr(1);
+                       line_plus_word.erase();
+                       line.erase();
+               }
+
+               if (!line_plus_word.empty() ) line_plus_word += ' ';
+               line_plus_word += word;
+
+               int length = fl_get_string_width(style, size,
+                                                line_plus_word.c_str(),
+                                                int(line_plus_word.length()));
                if (length >= w) {
-                       if (!sout.empty() ) sout += '\n';
-                       sout += line;
-                       l1 = (*vit);
+                       sout += line + '\n';
+                       line_plus_word = word;
                }
 
-               line = l1;
+               line = line_plus_word;
        }
        // Flush remaining contents of line
        if (!line.empty()) {
-               if (!sout.empty() ) sout += '\n';
                sout += line;
        }
-       
+
+       if (sout[sout.length()-1] == '\n')
+               sout.erase(sout.length()-1);
+
        return sout;
 }