]> git.lyx.org Git - lyx.git/commitdiff
* Baruch's GuiBC template.
authorAngus Leeming <leeming@lyx.org>
Fri, 30 Mar 2001 09:51:46 +0000 (09:51 +0000)
committerAngus Leeming <leeming@lyx.org>
Fri, 30 Mar 2001 09:51:46 +0000 (09:51 +0000)
* Some file (and class) name changes:
ButtonController.[Ch] to ButtonControllerBase.[Ch]
BCTemplates.h to ButtonController.h
ControlBase.[Ch] to ControlButton.[Ch]
* Moved file browsing into the controllers for the Graphics, Include and
Print popups.
* Fixed search bug in Citation popup. Added case sensitive button.
* Implemented controller-view split for External Material popup. Think that
it's now correct, but could you check again, Dekel?

Angus

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

65 files changed:
src/frontends/controllers/ButtonController.C [deleted file]
src/frontends/controllers/ButtonController.h
src/frontends/controllers/ButtonControllerBase.C [new file with mode: 0644]
src/frontends/controllers/ButtonControllerBase.h [new file with mode: 0644]
src/frontends/controllers/ChangeLog
src/frontends/controllers/ControlBase.C [deleted file]
src/frontends/controllers/ControlBase.h [deleted file]
src/frontends/controllers/ControlButton.C [new file with mode: 0644]
src/frontends/controllers/ControlButton.h [new file with mode: 0644]
src/frontends/controllers/ControlConnections.h
src/frontends/controllers/ControlExternal.C [new file with mode: 0644]
src/frontends/controllers/ControlExternal.h [new file with mode: 0644]
src/frontends/controllers/ControlGraphics.C
src/frontends/controllers/ControlGraphics.h
src/frontends/controllers/ControlInclude.C
src/frontends/controllers/ControlInclude.h
src/frontends/controllers/ControlInset.h
src/frontends/controllers/ControlPrint.C
src/frontends/controllers/ControlPrint.h
src/frontends/controllers/GUI.h
src/frontends/controllers/Makefile.am
src/frontends/controllers/ViewBase.h
src/frontends/controllers/biblio.C
src/frontends/controllers/helper_funcs.C
src/frontends/controllers/helper_funcs.h
src/frontends/gnome/ChangeLog
src/frontends/gnome/GnomeBase.C
src/frontends/gnome/GnomeBase.h
src/frontends/gnome/gnomeBC.C
src/frontends/gnome/gnomeBC.h
src/frontends/kde/ChangeLog
src/frontends/kde/kdeBC.C
src/frontends/kde/kdeBC.h
src/frontends/qt2/ChangeLog
src/frontends/qt2/Qt2Base.C
src/frontends/qt2/Qt2Base.h
src/frontends/xforms/ChangeLog
src/frontends/xforms/Dialogs.C
src/frontends/xforms/FormBase.C
src/frontends/xforms/FormBase.h
src/frontends/xforms/FormBrowser.C
src/frontends/xforms/FormBrowser.h
src/frontends/xforms/FormCitation.C
src/frontends/xforms/FormExternal.C
src/frontends/xforms/FormExternal.h
src/frontends/xforms/FormGraphics.C
src/frontends/xforms/FormGraphics.h
src/frontends/xforms/FormInclude.C
src/frontends/xforms/FormInclude.h
src/frontends/xforms/FormPreferences.C
src/frontends/xforms/FormPrint.C
src/frontends/xforms/FormPrint.h
src/frontends/xforms/form_citation.C
src/frontends/xforms/form_citation.h
src/frontends/xforms/form_external.C
src/frontends/xforms/form_external.h
src/frontends/xforms/forms/form_citation.fd
src/frontends/xforms/forms/form_external.fd
src/frontends/xforms/xformsBC.C
src/frontends/xforms/xformsBC.h
src/frontends/xforms/xforms_helpers.C
src/frontends/xforms/xforms_helpers.h
src/insets/ChangeLog
src/insets/insetexternal.C
src/insets/insetexternal.h

diff --git a/src/frontends/controllers/ButtonController.C b/src/frontends/controllers/ButtonController.C
deleted file mode 100644 (file)
index 5653a4a..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-// -*- C++ -*-
-/* This file is part of
- * ====================================================== 
- *
- *           LyX, The Document Processor
- *
- *           Copyright 2000-2001 The LyX Team.
- *
- * ======================================================
- *
- * \file ButtonController.C
- * \author Allan Rae
- */
-
-#ifdef __GNUG__
-#pragma implementation
-#endif
-
-#include <config.h>
-#include "ButtonController.h"
-#include "support/LAssert.h"
-
-
-ButtonControllerBase::ButtonControllerBase(string const & cancel,
-                                          string const & close)
-       : cancel_label(cancel), close_label(close)
-{}
-
-
-void ButtonControllerBase::ok()
-{
-       input(ButtonPolicy::SMI_OKAY);
-}
-
-
-void ButtonControllerBase::input(ButtonPolicy::SMInput in)
-{
-       if (ButtonPolicy::SMI_NOOP == in) return;
-       bp().input(in);
-       refresh();
-}
-
-
-void ButtonControllerBase::apply()
-{
-       input(ButtonPolicy::SMI_APPLY);
-}
-
-
-void ButtonControllerBase::cancel()
-{
-       input(ButtonPolicy::SMI_CANCEL);
-}
-
-
-void ButtonControllerBase::undoAll()
-{
-       input(ButtonPolicy::SMI_UNDO_ALL);
-}
-
-
-void ButtonControllerBase::hide()
-{
-       input(ButtonPolicy::SMI_HIDE);
-}
-
-
-void ButtonControllerBase::valid(bool v)
-{
-       if (v) {
-               input(ButtonPolicy::SMI_VALID);
-       } else {
-               input(ButtonPolicy::SMI_INVALID);
-       }
-}
-
-
-void ButtonControllerBase::invalid()
-{
-       input(ButtonPolicy::SMI_INVALID);
-}
-
-
-bool ButtonControllerBase::readOnly(bool ro)
-{
-       if (ro) {
-               input(ButtonPolicy::SMI_READ_ONLY);
-       } else {
-               input(ButtonPolicy::SMI_READ_WRITE);
-       }
-       return ro;
-}
-
-
-void ButtonControllerBase::readWrite()
-{
-       readOnly(false);
-}
index 891889e3a1cef8a82c34b9f50bac22c1ed1a0622..ed18f63cbf9f3ea13f87147dfe3c3173e198b0c6 100644 (file)
@@ -1,7 +1,4 @@
-/*
- * \file ButtonController.h
- *
- * This file is part of
+/* This file is part of
  * ====================================================== 
  *
  *           LyX, The Document Processor
  *
  * ======================================================
  *
+ * \file ButtonController.h
  * \author Allan Rae, rae@lyx.org
+ * \author Angus Leeming, a.leeming@ic.ac.uk
+ * \author Baruch Even, baruch.even@writeme.com
  */
 
 #ifndef BUTTONCONTROLLER_H
 #define BUTTONCONTROLLER_H
 
-#ifdef __GNUG__
-#pragma interface
-#endif
-
-#include "ButtonPolicies.h"
-#include "LString.h"
-#include "gettext.h"
+#include <list>
 
-/** Abstract base class for a ButtonController
-
- * Controls the activation of the OK, Apply and Cancel buttons.
- * Actually supports 4 buttons in all and it's up to the user to decide on
- * the activation policy and which buttons correspond to which output of the
- * state machine.
- * Author: Allan Rae <rae@lyx.org>.
- * This abstract base class stripped of xforms-specific code by
- * Angus Leeming <a.leeming@ic.ac.uk>
- */
-class ButtonControllerBase : public boost::noncopyable
+template <class Button, class Widget>
+class GuiBC : public ButtonControllerBase
 {
 public:
-       /** Constructor.
-           The cancel/close label entries are _not_ managed within the class
-           thereby allowing you to reassign at will and to use static labels.
-           It also means if you really don't want to have the Cancel button
-           label be different when there is nothing changed in the dialog then
-           you can just assign "Cancel" to both labels.  Or even reuse this
-           class for something completely different.
-        */
-       ButtonControllerBase(string const & cancel, string const & close);
-       ///
-       virtual ~ButtonControllerBase() {}
-       ///
-       virtual void refresh() = 0;
        ///
-       virtual ButtonPolicy & bp() = 0;
-       ///
-       virtual void input(ButtonPolicy::SMInput);
-       ///
-       void ok();
-       ///
-       void apply();
-       ///
-       void cancel();
-       ///
-       void undoAll();
-       ///
-       void hide();
-       /// Passthrough function -- returns its input value
-       bool readOnly(bool = true);
+       GuiBC(string const & cancel, string const & close);
+
+       /// 
+       void setOK(Button * obj) { okay_ = obj; }
+       /// 
+       void setApply(Button * obj) { apply_ = obj; }
+       /// 
+       void setCancel(Button * obj) { cancel_ = obj; }
        ///
-       void readWrite();
+       void setUndoAll(Button * obj) { undo_all_ = obj; }
        ///
-       void valid(bool = true);
+       void addReadOnly(Widget * obj) { read_only_.push_back(obj); }
        ///
-       void invalid();
+       void eraseReadOnly() { read_only_.clear(); }
 
-protected:
-       ///
-       string cancel_label;
-       ///
-       string close_label;     
+       /// Refresh the widgets status.
+       void refresh();
+
+private:
+       /// Enable/Disable a widget
+       virtual void setWidgetEnabled(Widget * obj, bool enable) = 0;
+       /// Enable/Disable a button
+       virtual void setButtonEnabled(Button * obj, bool enable) = 0;
+       /// Set the Label on the button
+       virtual void setButtonLabel(Button * obj, string const & label) = 0;
+
+       Button * okay_;
+       Button * apply_;
+       Button * undo_all_;
+       Button * cancel_;
+       
+       typedef std::list<Widget *> Widgets;
+       Widgets read_only_;
 };
 
 
+template <class Button, class Widget>
+GuiBC<Button, Widget>::GuiBC(string const & cancel, string const & close)
+       : ButtonControllerBase(cancel, close)
+       , okay_(0), apply_(0), cancel_(0), undo_all_(0)
+{}
+
+
+template <class Button, class Widget>
+void GuiBC<Button, Widget>::refresh()
+{
+       if (okay_) {
+               bool const enabled = bp().buttonStatus(ButtonPolicy::OKAY);
+               setButtonEnabled(okay_, enabled);
+       }
+       if (apply_) {
+               bool const enabled = bp().buttonStatus(ButtonPolicy::APPLY);
+               setButtonEnabled(apply_, enabled);
+       }
+       if (undo_all_) {
+               bool const enabled = bp().buttonStatus(ButtonPolicy::UNDO_ALL);
+               setButtonEnabled(undo_all_, enabled);
+       }
+       if (cancel_) {
+               bool const enabled = bp().buttonStatus(ButtonPolicy::CANCEL);
+               if (enabled)
+                       setButtonLabel(cancel_, cancel_label_);
+               else
+                       setButtonLabel(cancel_, close_label_);
+       }
+
+       // Enable/Disable read-only handled widgets.
+       if (!read_only_.empty()) {
+               bool const enable = !bp().isReadOnly();
+
+               Widgets::const_iterator end = read_only_.end();
+               Widgets::const_iterator iter = read_only_.begin();
+               for (; iter != end; ++iter) {
+                       setWidgetEnabled(*iter, enable);
+               }
+       }
+
+}
+
+
 template <class BP, class GUIBC>
 class ButtonController: public GUIBC
 {
diff --git a/src/frontends/controllers/ButtonControllerBase.C b/src/frontends/controllers/ButtonControllerBase.C
new file mode 100644 (file)
index 0000000..f446d78
--- /dev/null
@@ -0,0 +1,98 @@
+// -*- C++ -*-
+/* This file is part of
+ * ====================================================== 
+ *
+ *           LyX, The Document Processor
+ *
+ *           Copyright 2000-2001 The LyX Team.
+ *
+ * ======================================================
+ *
+ * \file ButtonControllerBase.C
+ * \author Allan Rae
+ */
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+#include <config.h>
+#include "ButtonControllerBase.h"
+#include "support/LAssert.h"
+
+
+ButtonControllerBase::ButtonControllerBase(string const & cancel,
+                                          string const & close)
+       : cancel_label_(cancel), close_label_(close)
+{}
+
+
+void ButtonControllerBase::ok()
+{
+       input(ButtonPolicy::SMI_OKAY);
+}
+
+
+void ButtonControllerBase::input(ButtonPolicy::SMInput in)
+{
+       if (ButtonPolicy::SMI_NOOP == in) return;
+       bp().input(in);
+       refresh();
+}
+
+
+void ButtonControllerBase::apply()
+{
+       input(ButtonPolicy::SMI_APPLY);
+}
+
+
+void ButtonControllerBase::cancel()
+{
+       input(ButtonPolicy::SMI_CANCEL);
+}
+
+
+void ButtonControllerBase::undoAll()
+{
+       input(ButtonPolicy::SMI_UNDO_ALL);
+}
+
+
+void ButtonControllerBase::hide()
+{
+       input(ButtonPolicy::SMI_HIDE);
+}
+
+
+void ButtonControllerBase::valid(bool v)
+{
+       if (v) {
+               input(ButtonPolicy::SMI_VALID);
+       } else {
+               input(ButtonPolicy::SMI_INVALID);
+       }
+}
+
+
+void ButtonControllerBase::invalid()
+{
+       input(ButtonPolicy::SMI_INVALID);
+}
+
+
+bool ButtonControllerBase::readOnly(bool ro)
+{
+       if (ro) {
+               input(ButtonPolicy::SMI_READ_ONLY);
+       } else {
+               input(ButtonPolicy::SMI_READ_WRITE);
+       }
+       return ro;
+}
+
+
+void ButtonControllerBase::readWrite()
+{
+       readOnly(false);
+}
diff --git a/src/frontends/controllers/ButtonControllerBase.h b/src/frontends/controllers/ButtonControllerBase.h
new file mode 100644 (file)
index 0000000..e395047
--- /dev/null
@@ -0,0 +1,81 @@
+/* This file is part of
+ * ====================================================== 
+ *
+ *           LyX, The Document Processor
+ *
+ *           Copyright 2000-2001 The LyX Team.
+ *
+ * ======================================================
+ *
+ * \file ButtonControllerBase.h
+ * \author Allan Rae, rae@lyx.org
+ */
+
+#ifndef BUTTONCONTROLLERBASE_H
+#define BUTTONCONTROLLERBASE_H
+
+#ifdef __GNUG__
+#pragma interface
+#endif
+
+#include "ButtonPolicies.h"
+#include "LString.h"
+
+/** Abstract base class for a ButtonController
+
+ * Controls the activation of the OK, Apply and Cancel buttons.
+ * Actually supports 4 buttons in all and it's up to the user to decide on
+ * the activation policy and which buttons correspond to which output of the
+ * state machine.
+ * Author: Allan Rae <rae@lyx.org>.
+ * This abstract base class stripped of xforms-specific code by
+ * Angus Leeming <a.leeming@ic.ac.uk>
+ */
+class ButtonControllerBase : public boost::noncopyable
+{
+public:
+       /** Constructor.
+           The cancel/close label entries are _not_ managed within the class
+           thereby allowing you to reassign at will and to use static labels.
+           It also means if you really don't want to have the Cancel button
+           label be different when there is nothing changed in the dialog then
+           you can just assign "Cancel" to both labels.  Or even reuse this
+           class for something completely different.
+        */
+       ButtonControllerBase(string const & cancel, string const & close);
+       ///
+       virtual ~ButtonControllerBase() {}
+       ///
+       virtual ButtonPolicy & bp() = 0;
+       ///
+       virtual void input(ButtonPolicy::SMInput);
+       ///
+       void ok();
+       ///
+       void apply();
+       ///
+       void cancel();
+       ///
+       void undoAll();
+       ///
+       void hide();
+       ///
+       virtual void refresh() = 0;
+
+       /// Passthrough function -- returns its input value
+       bool readOnly(bool = true);
+       ///
+       void readWrite();
+       ///
+       void valid(bool = true);
+       ///
+       void invalid();
+
+protected:
+       ///
+       string cancel_label_;
+       ///
+       string close_label_;    
+};
+
+#endif // BUTTONCONTROLLERBASE_H
index 3fbf3fc3156038faf4c145020ed9c33c89c431b1..110e0821e55311ecd8ed2abe416d7186df16a62d 100644 (file)
@@ -1,3 +1,44 @@
+2001-03-30  Angus Leeming  <a.leeming@ic.ac.uk>
+
+       * ButtonController.[Ch]: renamed as ButtonControllerBase.[Ch]
+
+       * BCTemplates.h: renamed as ButtonController.h
+
+       * ControlBase.[Ch]: renamed as ControlButton.[Ch]. Class named to match.
+
+       * ViewBase.h:
+       * ControlConnections.h: associated change in #include and class names.
+       
+       * ControlExternal.[Ch]: new files; a controller for the External
+       Material popup.
+
+       * GUI.h:
+       * Makefile.am: associated changes with all of the above.
+
+       * ControlGraphics.[Ch]:
+       * ControlInclude.[Ch]:
+       * ControlPrint.[Ch]:
+       (lv): removed.
+       (Browse): new method. Returns the results of a FileDialog browse.
+
+       * helper_funcs.[Ch] (browseFile): moved from xforms_helpers.[Ch].
+       (getVectorFromString): fixed bug.
+
+       * biblio.C (simpleSearch): cleaned up.
+
+2001-03-29  Angus Leeming  <a.leeming@ic.ac.uk>
+
+       * A slight reworking of Baruch Even's ButtonController patch.
+
+       * BCTemplates.h: new file; all the templates for the ButtonController.
+       Including Baruch's new GuiBC class, with setCancelCloseButton() changed
+       to the more generic setButtonLabel().
+
+       * ButtonController.[Ch]: renamed cancel_label and close_label as
+       cancel_label_ and close_label_.
+
+       * Makefile.am: added BCTemplates.h
+
 2001-03-29  Juergen Vigna  <jug@sad.it>
 
        * ControlMinipage.C: removed widthp_ and all it's functions and changed
diff --git a/src/frontends/controllers/ControlBase.C b/src/frontends/controllers/ControlBase.C
deleted file mode 100644 (file)
index f1d03f0..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-// -*- C++ -*-
-/* This file is part of
- * ====================================================== 
- *
- *           LyX, The Document Processor
- *
- *           Copyright 2001 The LyX Team.
- *
- * ======================================================
- *
- * \file ControlBase.C
- * \author Angus Leeming <a.leeming@ic.ac.uk>
- */
-
-#ifdef __GNUG__
-#pragma implementation
-#endif
-
-#include <config.h>
-
-#include "ButtonController.h"
-#include "ControlBase.h"
-
-void ControlBase::ApplyButton()
-{
-       apply();
-       bc().apply();
-}
-
-
-void ControlBase::OKButton()
-{
-       apply();
-       hide();
-       bc().ok();
-}
-
-
-void ControlBase::CancelButton()
-{
-       hide();
-       bc().cancel();
-}
-
-
-void ControlBase::RestoreButton()
-{
-       update();
-       bc().undoAll();
-}
diff --git a/src/frontends/controllers/ControlBase.h b/src/frontends/controllers/ControlBase.h
deleted file mode 100644 (file)
index 84e4a1b..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-/* This file is part of
- * ====================================================== 
- *
- *           LyX, The Document Processor
- *
- *           Copyright 2001 The LyX Team.
- *
- * ======================================================
- *
- * \file ControlBase.h
- * \author Angus Leeming <a.leeming@ic.ac.uk>
- *
- * 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.
- *
- * 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.
- */
-
-#ifndef CONTROLBASE_H
-#define CONTROLBASE_H
-
-#ifdef __GNUG__
-#pragma interface
-#endif
-
-#include "DialogBase.h" // This can go eventually
-#include "ButtonController.h"
-
-class ViewBase;
-
-/** Abstract base class for Controllers with a ButtonController.
- */
-class ControlBase : public DialogBase
-{
-public: // methods
-       ///
-       ControlBase() {}
-       ///
-       virtual ~ControlBase() {};
-
-       /// These functions are called when the controlling buttons are pressed.
-       ///
-       void ApplyButton();
-       ///
-       void OKButton();
-       ///
-       void CancelButton();
-       ///
-       void RestoreButton();
-
-       /** Allow the view to access the ButtonController. This method must be
-           instantiated in a daughter class that creates the actual instance
-           of the ButtonController. */
-       virtual ButtonControllerBase & bc() = 0;
-
-protected:
-       /// Get changed parameters and Dispatch them to the kernel.
-       virtual void apply() = 0;
-       /// Disconnect signals and hide View.
-       virtual void hide() = 0;
-       /// Update dialog before showing it.
-       virtual void update() = 0;
-
-       /** Allow the Controller to access the View. This method must be
-           instantiated in a daughter class that creates the actual instance
-           of the View. */
-       virtual ViewBase & view() = 0;
-};
-
-#include "ViewBase.h"
-
-#endif // CONTROLBASE_H
diff --git a/src/frontends/controllers/ControlButton.C b/src/frontends/controllers/ControlButton.C
new file mode 100644 (file)
index 0000000..731c452
--- /dev/null
@@ -0,0 +1,49 @@
+// -*- C++ -*-
+/* This file is part of
+ * ====================================================== 
+ *
+ *           LyX, The Document Processor
+ *
+ *           Copyright 2001 The LyX Team.
+ *
+ * ======================================================
+ *
+ * \file ControlButton.C
+ * \author Angus Leeming <a.leeming@ic.ac.uk>
+ */
+
+#include <config.h>
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+#include "ControlButton.h"
+
+void ControlButton::ApplyButton()
+{
+       apply();
+       bc().apply();
+}
+
+
+void ControlButton::OKButton()
+{
+       apply();
+       hide();
+       bc().ok();
+}
+
+
+void ControlButton::CancelButton()
+{
+       hide();
+       bc().cancel();
+}
+
+
+void ControlButton::RestoreButton()
+{
+       update();
+       bc().undoAll();
+}
diff --git a/src/frontends/controllers/ControlButton.h b/src/frontends/controllers/ControlButton.h
new file mode 100644 (file)
index 0000000..6c29e60
--- /dev/null
@@ -0,0 +1,81 @@
+/* This file is part of
+ * ====================================================== 
+ *
+ *           LyX, The Document Processor
+ *
+ *           Copyright 2001 The LyX Team.
+ *
+ * ======================================================
+ *
+ * \file ControlButton.h
+ * \author Angus Leeming <a.leeming@ic.ac.uk>
+ *
+ * ControlButton 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.
+ *
+ * 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.
+ */
+
+#ifndef CONTROLBUTTON_H
+#define CONTROLBUTTON_H
+
+#ifdef __GNUG__
+#pragma interface
+#endif
+
+#include "DialogBase.h" // This can go eventually
+#include "ButtonControllerBase.h"
+
+class ViewBase;
+
+/** Abstract base class for Controllers with a ButtonController.
+ */
+class ControlButton : public DialogBase
+{
+public: // methods
+       ///
+       ControlButton() {}
+       ///
+       virtual ~ControlButton() {};
+
+       /// These functions are called when the controlling buttons are pressed.
+       ///
+       void ApplyButton();
+       ///
+       void OKButton();
+       ///
+       void CancelButton();
+       ///
+       void RestoreButton();
+
+       /** Allow the view to access the ButtonController. This method must be
+           instantiated in a daughter class that creates the actual instance
+           of the ButtonController. */
+       virtual ButtonControllerBase & bc() = 0;
+
+protected:
+       /// Get changed parameters and Dispatch them to the kernel.
+       virtual void apply() = 0;
+       /// Disconnect signals and hide View.
+       virtual void hide() = 0;
+       /// Update dialog before showing it.
+       virtual void update() = 0;
+
+       /** Allow the Controller to access the View. This method must be
+           instantiated in a daughter class that creates the actual instance
+           of the View. */
+       virtual ViewBase & view() = 0;
+};
+
+#include "ViewBase.h"
+
+#endif // CONTROLBUTTON_H
index f3401af66c1d21e47d07ae2892536c482c13fa52..fc1061200d658d2f24fccc3a2867698b3c2eed62 100644 (file)
@@ -34,7 +34,7 @@
 #pragma interface
 #endif
 
-#include "ControlBase.h"
+#include "ControlButton.h"
 
 class Dialogs;
 class LyXView;
@@ -43,7 +43,7 @@ class LyXView;
     kernel. It is meant to be used solely as the parent class to
     ControlConnectBI and ControlConnectBD.
 */
-class ControlConnectBase : public ControlBase
+class ControlConnectBase : public ControlButton
 {
 public:
        ///
diff --git a/src/frontends/controllers/ControlExternal.C b/src/frontends/controllers/ControlExternal.C
new file mode 100644 (file)
index 0000000..2b6e832
--- /dev/null
@@ -0,0 +1,175 @@
+/* This file is part of
+ * ====================================================== 
+ *
+ *           LyX, The Document Processor
+ *
+ *           Copyright 2001 The LyX Team.
+ *
+ * ======================================================
+ *
+ * \file ControlExternal.C
+ * \author Asger Alstrup
+ * \author John Levon
+ * \author Angus Leeming, a.leeming@ic.ac.uk
+ */
+
+#include <config.h>
+
+#include <utility>
+#include <vector>
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+#include "ControlExternal.h"
+#include "buffer.h"
+#include "Dialogs.h"
+#include "Liason.h"
+#include "LyXView.h"
+#include "support/filetools.h"
+#include "frontends/FileDialog.h"
+#include "lyx_gui_misc.h" // WriteAlert
+
+using std::make_pair;
+using std::vector;
+
+ControlExternal::ControlExternal(LyXView & lv, Dialogs & d)
+       : ControlInset<InsetExternal, InsetExternal::Params>(lv, d)
+{
+       d_.showExternal.connect(SigC::slot(this, &ControlExternal::showInset));
+}
+
+
+InsetExternal::Params const ControlExternal::getParams(string const &)
+{
+       return InsetExternal::Params();
+}
+
+InsetExternal::Params const 
+ControlExternal::getParams(InsetExternal const & inset)
+{
+       return inset.params();
+}
+
+
+void ControlExternal::editExternal()
+{
+       inset()->setFromParams(params());
+       inset()->editExternal();
+}
+
+void ControlExternal::viewExternal()
+{
+       inset()->setFromParams(params());
+       inset()->viewExternal();
+}
+
+void ControlExternal::updateExternal()
+{
+       inset()->setFromParams(params());
+       inset()->updateExternal();
+}
+
+vector<string> const ControlExternal::getTemplates() const
+{
+       vector<string> result;
+
+       ExternalTemplateManager::Templates::const_iterator i1, i2;
+       i1 = ExternalTemplateManager::get().getTemplates().begin();
+       i2 = ExternalTemplateManager::get().getTemplates().end();
+
+       for (; i1 != i2; ++i1) {
+               result.push_back(i1->second.lyxName);
+       }
+       return result;
+}
+
+
+int ControlExternal::getTemplateNumber(string const & name) const
+{
+       int i = 0;
+
+       ExternalTemplateManager::Templates::const_iterator i1, i2;
+       i1 = ExternalTemplateManager::get().getTemplates().begin();
+       i2 = ExternalTemplateManager::get().getTemplates().end();
+       for (; i1 != i2; ++i1) {
+               if (i1->second.lyxName == name)
+                       return i;
+               ++i;
+       }
+
+       // we can get here if a LyX document has a template not installed
+       // on this machine.
+       return -1;
+}
+
+
+ExternalTemplate ControlExternal::getTemplate(int i) const
+{
+       ExternalTemplateManager::Templates::const_iterator i1;
+       i1 = ExternalTemplateManager::get().getTemplates().begin();
+       for (int n = 1; n < i; ++n)
+               ++i1;
+
+       return (*i1).second;
+}
+
+
+string const ControlExternal::Browse(string const & input) const
+{
+       string buf  = MakeAbsPath(lv_.buffer()->fileName());
+       string buf2 = OnlyPath(buf);
+
+       if (!input.empty()) {
+               buf = MakeAbsPath(input, buf2);
+               buf = OnlyPath(buf);
+       } else {
+               buf = OnlyPath(lv_.buffer()->fileName());
+       }
+    
+       FileDialog fileDlg(&lv_,
+                          _("Select external file"),
+                          LFUN_SELECT_FILE_SYNC,
+                          make_pair(string(_("Document")), string(buf)));
+       
+       /// Determine the template file extension
+       ExternalTemplate const & et = params().templ;
+
+       string regexp = et.fileRegExp;
+       if (regexp.empty())
+               regexp = "*";
+
+       // FIXME: a temporary hack until the FileDialog interface is updated
+       regexp += "|";
+
+       static int once = 0;
+       string current_path;
+
+       while (1) {
+               string const path = (once) ? current_path : buf;
+               FileDialog::Result result = fileDlg.Select(path, regexp, input);
+
+               if (result.second.empty())
+                       return string();
+
+               string p = result.second;
+
+               buf = MakeRelPath(input, buf2);
+               current_path = OnlyPath(input);
+               once = 1;
+               
+               if (contains(input, "#") ||
+                   contains(input, "~") ||
+                   contains(input, "$") ||
+                   contains(input, "%")) {
+                       WriteAlert(_("Filename can't contain any "
+                                    "of these characters:"),
+                                  // xgettext:no-c-format
+                                  _("'#', '~', '$' or '%'."));
+               } else
+                       break;
+       }
+
+       return buf;
+}
diff --git a/src/frontends/controllers/ControlExternal.h b/src/frontends/controllers/ControlExternal.h
new file mode 100644 (file)
index 0000000..b8d48f9
--- /dev/null
@@ -0,0 +1,61 @@
+/* This file is part of
+ * ====================================================== 
+ *
+ *           LyX, The Document Processor
+ *
+ *           Copyright 2001 The LyX Team.
+ *
+ * ======================================================
+ *
+ * \file ControlExternal.h
+ * \author Asger Alstrup
+ * \author John Levon
+ * \author Angus Leeming, a.leeming@ic.ac.uk
+ */
+
+#ifndef CONTROLEXTERNAL_H
+#define CONTROLEXTERNAL_H
+
+#ifdef __GNUG__
+#pragma interface
+#endif
+
+#include "ControlInset.h"
+#include "insets/insetexternal.h"
+
+/** A controller for External dialogs.
+ */ 
+class ControlExternal
+       : public ControlInset<InsetExternal, InsetExternal::Params>
+{
+public:
+       ///
+       ControlExternal(LyXView &, Dialogs &);
+
+       ///
+       void editExternal();
+       ///
+       void viewExternal();
+       ///
+       void updateExternal();
+       ///
+       std::vector<string> const getTemplates() const;
+       ///
+       int getTemplateNumber(string const &) const;
+       ///
+       ExternalTemplate getTemplate(int) const;
+       ///
+       string const Browse(string const &) const;
+
+private:
+       /// not needed.
+       virtual void applyParamsToInset() {}
+       /// 
+       virtual void applyParamsNoInset() {}
+       /// get the parameters from the string passed to createInset.
+       virtual InsetExternal::Params const getParams(string const &);
+       /// get the parameters from the inset passed to showInset.
+       virtual InsetExternal::Params const getParams(InsetExternal const &);
+};
+
+#endif // CONTROLEXTERNAL_H
index 41a60e9a81a8601c8ac603419a591288ec8eaaab..777a5fb1e92ef96467f9d39e4006e9915f20de1b 100644 (file)
 
 #include "insets/insetgraphics.h"
 
+#include "support/FileInfo.h"  // for FileInfo
+#include "helper_funcs.h"      // for browseFile
+#include "support/filetools.h" // for AddName
+
+using std::pair;
+using std::make_pair;
+
 ControlGraphics::ControlGraphics(LyXView & lv, Dialogs & d)
        : ControlInset<InsetGraphics, InsetGraphicsParams>(lv, d)
 {
@@ -32,12 +39,6 @@ ControlGraphics::ControlGraphics(LyXView & lv, Dialogs & d)
 }
 
 
-LyXView * ControlGraphics::lv() const
-{
-        return &lv_;
-}
-
-
 InsetGraphicsParams const ControlGraphics::getParams(string const &)
 {
        return InsetGraphicsParams();
@@ -64,3 +65,27 @@ void ControlGraphics::applyParamsToInset()
 
 void ControlGraphics::applyParamsNoInset()
 {}
+
+
+// We need these in the file browser.
+extern string system_lyxdir;
+extern string user_lyxdir;
+
+string const ControlGraphics::Browse(string const & in_name)
+{
+       string const title = N_("Graphics");
+       // FIXME: currently we need the second '|' to prevent mis-interpretation 
+       string const pattern = "*.(ps|png)|";
+
+       // Does user clipart directory exist?
+       string clipdir = AddName (user_lyxdir, "clipart");
+       FileInfo fileInfo(clipdir);
+       if (!(fileInfo.isOK() && fileInfo.isDir()))
+               // No - bail out to system clipart directory
+               clipdir = AddName (system_lyxdir, "clipart");
+       pair<string, string> dir1(N_("Clipart"), clipdir);
+       
+       // Show the file browser dialog
+       return browseFile(&lv_, in_name, title, pattern, dir1,
+                         make_pair(string(), string()));
+}
index fac2f28f1a2de15dd808dff8e328a35814f6ae37..1be2845c335b3fd9f197b5e4df298f85bc692f8a 100644 (file)
@@ -32,8 +32,8 @@ public:
        ///
        ControlGraphics(LyXView &, Dialogs &);
 
-       /// The file dialog popup requires a LyXView * ???
-       LyXView * lv() const;
+       /// Browse for a file
+       string const Browse(string const &);
 
 private:
        /// Dispatch the changed parameters to the kernel.
index 04416f2f669388d08486a3f1c4b98c2e4470a5a3..0fd1db44f7a5cd42bb8ab9279de4d2f505fbb4bc 100644 (file)
@@ -8,17 +8,24 @@
  * \author Angus Leeming, a.leeming@.ac.uk
  */
 
+#include <config.h>
+#include <utility>
+
 #ifdef __GNUG__
 #pragma implementation
 #endif
 
-#include <config.h>
 #include "ControlInclude.h"
 #include "buffer.h"
 #include "Dialogs.h"
 #include "lyxfunc.h"
 #include "LyXView.h"
 
+#include "helper_funcs.h"
+#include "lyxrc.h"
+
+using std::pair;
+using std::make_pair;
 using SigC::slot;
 
 ControlInclude::ControlInclude(LyXView & lv, Dialogs & d)
@@ -27,14 +34,37 @@ ControlInclude::ControlInclude(LyXView & lv, Dialogs & d)
        d_.showInclude.connect(slot(this, &ControlInclude::showInset));
 }
 
-LyXView * ControlInclude::lv() const
-{
-       return &lv_;
-}
-
 
 void ControlInclude::applyParamsToInset()
 {
        inset()->set(params());
        lv_.view()->updateInset(inset(), true);
 }
+
+
+string const ControlInclude::Browse(string const & in_name, Type in_type)
+{
+       string const title = N_("Select document to include");
+
+       string pattern;
+                  
+       // input TeX, verbatim, or LyX file ?
+       switch (in_type) {
+       case INPUT:
+           pattern = _("*.tex| LaTeX Documents (*.tex)");
+           break;
+
+       case VERBATIM:
+           pattern = _("*| All files ");
+           break;
+
+       case INCLUDE:
+           pattern = _("*.lyx| LyX Documents (*.lyx)");
+           break;
+       }
+       
+       pair<string, string> dir1(N_("Documents"), string(lyxrc.document_path));
+
+       return browseFile(&lv_, in_name, title, pattern, dir1,
+                         make_pair(string(), string()));
+}
index 137db0bb7a2dd0e1cae30b0eb8e200423bb6f3da..beb257650b8185ab9868da66d6bf9999a78121f2 100644 (file)
@@ -24,11 +24,20 @@ class ControlInclude
        : public ControlInset<InsetInclude, InsetInclude::Params>
 {
 public:
+       ///
+       enum Type {
+               ///
+               INPUT,
+               ///
+               VERBATIM,
+               ///
+               INCLUDE
+       };
        ///
        ControlInclude(LyXView &, Dialogs &);
 
-       /// The file dialog popup requires a LyXView * ???
-       LyXView * lv() const;
+       /// Browse for a file
+       string const Browse(string const &, Type);
 
 private:
        /// Dispatch the changed parameters to the kernel.
index d7798e4d48e0c765b4d86a74919936fa255aa421..d91b7d2c6808685ea86b8b36b363c3a43ae3fbc0 100644 (file)
@@ -65,7 +65,7 @@ private:
 
 
        
-       /// Instantiation of ControlBase virtual methods.
+       /// Instantiation of ControlButton virtual methods.
 
        /// Get changed parameters and Dispatch them to the kernel.
        virtual void apply();
index 183b8e0b2beb20fa41efbf4c71caa40232cd7941..d33b2f95d924dcad1eac545fe666f94512da994a 100644 (file)
@@ -12,6 +12,7 @@
  */
 
 #include <config.h>
+#include <utility>
 
 #ifdef __GNUG__
 #pragma implementation
 #include "lyxrc.h"
 #include "PrinterParams.h"
 #include "Liason.h"
-
+#include "helper_funcs.h" // browseFile
 #include "lyx_gui_misc.h" // WriteAlert
 
 using Liason::printBuffer;
 using Liason::getPrinterParams;
+using std::make_pair;
 
 ControlPrint::ControlPrint(LyXView & lv, Dialogs & d)
        : ControlDialog<ControlConnectBD>(lv, d)
@@ -52,12 +54,6 @@ void ControlPrint::apply()
 }
 
 
-LyXView * ControlPrint::lv() const
-{
-       return &lv_;
-}
-
-
 PrinterParams & ControlPrint::params() const
 {
        Assert(params_);
@@ -83,3 +79,13 @@ void ControlPrint::clearParams()
 }
 
 
+string const ControlPrint::Browse(string const & in_name)
+{
+       string const title = N_("Print to file");
+       string const pattern = "*.ps";
+
+       // Show the file browser dialog
+       return browseFile(&lv_, in_name, title, pattern,
+                          make_pair(string(), string()),
+                          make_pair(string(), string()));
+}
index 51597e959103b335bb5bf44cd37d291d308bdc4a..a29536e11515e38834d7dd7b69e54bf907f1b47d 100644 (file)
@@ -29,8 +29,8 @@ public:
        /// 
        ControlPrint(LyXView &, Dialogs &);
 
-       /// The file dialog popup requires a LyXView * ???
-       LyXView * lv() const;
+       /// Browse for a file
+       string const Browse(string const &);
        ///
        PrinterParams & params() const;
 
index c4557e80f39e6c0e5459dc195436c64018caf626..cc66e2dc58d7f249eaeb3bfbb37edcbd6b29ec69 100644 (file)
@@ -154,6 +154,20 @@ public:
 };
 
 
+/** Specialization for External dialog
+ */
+class ControlExternal;
+
+template <class GUIview, class GUIbc>
+class GUIExternal :
+       public GUI<ControlExternal, GUIview, OkCancelReadOnlyPolicy, GUIbc> {
+public:
+       ///
+       GUIExternal(LyXView & lv, Dialogs & d)
+               : GUI<ControlExternal, GUIview, OkCancelReadOnlyPolicy, GUIbc>(lv, d) {}
+};
+
+
 /** Specialization for Graphics dialog
  */
 class ControlGraphics;
index 31fcca7986f0ea5ffed54b4f6803ef9fa3fad2b7..69636dd8d59adf8ddb0ad95e710efd9e4818319e 100644 (file)
@@ -14,16 +14,17 @@ libcontrollers_la_SOURCES=\
        biblio.h \
        character.C \
        character.h \
-       ButtonController.C \
        ButtonController.h \
+       ButtonControllerBase.C \
+       ButtonControllerBase.h \
        ButtonPolicies.C \
        ButtonPolicies.h \
-       ControlBase.C \
-       ControlBase.h \
        ControlBibitem.C \
        ControlBibitem.h \
        ControlBibtex.C \
        ControlBibtex.h \
+       ControlButton.C \
+       ControlButton.h \
        ControlCharacter.C \
        ControlCharacter.h \
        ControlCitation.C \
@@ -39,6 +40,8 @@ libcontrollers_la_SOURCES=\
        ControlDialogs.h \
        ControlError.h \
        ControlError.C \
+       ControlExternal.h \
+       ControlExternal.C \
        ControlGraphics.h \
        ControlGraphics.C \
        ControlInclude.C \
index 37a4ca9cefe51e75ac8a7a2419dfd42b66f4f362..78a4f0e82c0c9f12a592af7fa588fd1945d0db55 100644 (file)
 #define VIEWBASE_H
 
 #include <boost/utility.hpp>
-#include "ControlBase.h"
+#include "ControlButton.h"
 #include "ControlSplash.h"
 
 class ViewBase {
 public:
        /// 
-       ViewBase(ControlBase & c) : controller_(c) {}
+       ViewBase(ControlButton & c) : controller_(c) {}
        /// 
        virtual ~ViewBase() {}
 
@@ -50,7 +50,7 @@ public:
 
 protected:
        /// The view is, after all, controlled!
-       ControlBase & controller_;
+       ControlButton & controller_;
 };
 
 
@@ -84,7 +84,7 @@ template <class GUIbc>
 class ViewBC : public ViewBase {
 public:
        ///
-       ViewBC(ControlBase & c) : ViewBase(c) {}
+       ViewBC(ControlButton & c) : ViewBase(c) {}
 
 protected:
        ///
index d878b4d3624609f3d2f154eca95ad6641b914ed3..0dee0b0850cea27fc3b5c1a516cdc87cdd993510 100644 (file)
@@ -129,7 +129,7 @@ searchKeys(InfoMap const & theMap,
        
        string search_expr = frontStrip(strip(expr));
        if (search_expr.empty())
-               return start;
+               return keys.end();
 
        if (type == SIMPLE)
                return simpleSearch(theMap, keys, search_expr, start, dir,
@@ -147,7 +147,11 @@ simpleSearch(InfoMap const & theMap,
             Direction dir,
             bool caseSensitive)
 {
-       vector<string> searchwords = getVectorFromString(expr, " ");
+       string tmp = expr;
+       if (!caseSensitive)
+               tmp = lowercase(tmp);
+
+       vector<string> searchwords = getVectorFromString(tmp, " ");
 
        // Loop over all keys from start...
        for (vector<string>::const_iterator it = start;
@@ -166,24 +170,11 @@ simpleSearch(InfoMap const & theMap,
                bool found = true;
 
                // Loop over all search words...
-               if (caseSensitive) {
-                       for (vector<string>::const_iterator sit=
-                                    searchwords.begin();
-                            sit<searchwords.end(); ++sit) {
-                               if (data.find(*sit) == string::npos) {
-                                       found = false;
-                                       break;
-                               }
-                       }
-               } else {
-                       for (vector<string>::const_iterator sit=
-                                    searchwords.begin();
-                            sit<searchwords.end(); ++sit) {
-                               if (data.find(lowercase(*sit)) ==
-                                   string::npos) {
-                                       found = false;
-                                       break;
-                               }
+               for (vector<string>::const_iterator sit = searchwords.begin();
+                    sit != searchwords.end(); ++sit) {
+                       if (data.find(*sit) == string::npos) {
+                               found = false;
+                               break;
                        }
                }
                
index 96b40435b6c62f7f1ffa0669806e9663276ae2b5..209452f5702724bad23763c5a147f1a9361c539c 100644 (file)
 #include "LString.h"
 #include "helper_funcs.h"
 
+#include "frontends/FileDialog.h"
+#include "support/filetools.h" // OnlyPath, OnlyFilename
+#include "gettext.h" // _()
+#include "lyx_gui_misc.h" // WriteAlert
+
+using std::pair;
 using std::vector;
+using std::make_pair;
+
 
 string const getStringFromVector(vector<string> const & vec,
                                 string const & delim)
@@ -50,6 +58,42 @@ vector<string> const getVectorFromString(string const & str,
                keys = keys.substr(start);
        }
 
+       if (vec.empty()) // unable to separate
+               vec.push_back(str);
+
        return vec;
 }
 
+string const browseFile(LyXView * lv, string const & filename,
+                       string const & title,
+                       string const & pattern, 
+                       pair<string,string> const & dir1,
+                       pair<string,string> const & dir2)
+{
+       string lastPath = ".";
+       if (!filename.empty()) lastPath = OnlyPath(filename);
+
+       FileDialog fileDlg(lv, title, LFUN_SELECT_FILE_SYNC, dir1, dir2);
+
+       FileDialog::Result result;
+       while (1) {
+               result = fileDlg.Select(lastPath, pattern, OnlyFilename(filename));
+
+               if (result.second.empty()) 
+                       return result.second;
+
+               lastPath = OnlyPath(result.second);
+
+               if (result.second.find_first_of("#~$% ") == string::npos)
+                       break; 
+               WriteAlert(_("Filename can't contain any "
+                       "of these characters:"),
+                       _("space, '#', '~', '$' or '%'."));
+       }
+
+       return result.second;
+}
+
+
index 4e6be14a621b88f8672e881c3d1fb9b7f63c244e..afc15e4b1affed49a9735ed81b738daa8e629743 100644 (file)
@@ -15,6 +15,8 @@
 #ifndef HELPERFUNCS_H
 #define HELPERFUNCS_H
 
+#include <utility> // pair
+
 #ifdef __GNUG__
 #pragma interface
 #endif
@@ -29,6 +31,20 @@ getStringFromVector(std::vector<string> const & vec, string const & delim=",");
 std::vector<string> const
 getVectorFromString(string const & str, string const & delim=",");
 
+class LyXView;
+/** Launch a file dialog and return the chosen file.
+    filename: a suggested filename.
+    title: the title of the dialog.
+    pattern: *.ps etc.
+    dir1 = (name, dir), dir2 = (name, dir): extra buttons on the dialog.
+*/
+string const browseFile(LyXView *lv, string const & filename,
+                       string const & title,
+                       string const & pattern, 
+                       std::pair<string,string> const & dir1,
+                       std::pair<string,string> const & dir2);
+
 /** Functions to extract vectors of the first and second elems from a
     vector<pair<A,B> >
 */
index 678690a01d42625c1f9d74b7946223fee2e11fed..ca4ff4d86c88f3a28198de70d2d3bb1a385d1126 100644 (file)
@@ -1,3 +1,17 @@
+2001-03-30  Angus Leeming  <a.leeming@ic.ac.uk>
+
+       * GnomeBase.[Ch]: changed ControlBase to ControlButton.
+
+2001-03-29  Angus Leeming  <a.leeming@ic.ac.uk>
+
+       * gnomeBC.[Ch]: Patched in a slight reworking of Baruch Even's patch.
+       Code moved into the generic template base class. Replaced
+       setCancelCloseButton() with setButtonLabel().
+
+2001-03-29  Baruch Even  <baruch@lyx.org>
+
+       * gnomeBC.[Ch]: Changed to use the new GuiBC template.
+
 2001-03-29  Baruch Even  <baruch@lyx.org>
 
        * FormUrl.C (d-tor):
index de37831333c39bbb53520b88628940d04bb0e865..36c93f92286566420487a8ec5709e641d9cc8be3 100644 (file)
@@ -19,7 +19,7 @@
 #include "support/filetools.h"
 #include <glib.h>
 
-GnomeBase::GnomeBase(ControlBase & c, string const & glade_file, string const & name)
+GnomeBase::GnomeBase(ControlButton & c, string const & glade_file, string const & name)
        : ViewBC<gnomeBC>(c), file_(glade_file), widget_name_(name), xml_(0)
 {}
        
index d982e8b505ead3a012bd942ba18ac0f2ed6f2a6f..5f8cbb9b366016f2b30e7ac830b436d9b9c4b2c9 100644 (file)
@@ -38,7 +38,7 @@ class Dialog;
 class GnomeBase : public ViewBC<gnomeBC>, public SigC::Object {
 public:
        /// 
-       GnomeBase(ControlBase & c, string const & glade_file, string const & name);
+       GnomeBase(ControlButton & c, string const & glade_file, string const & name);
        ///
        virtual ~GnomeBase();
 
index 76b88e93840be8da786d9193af51fe3a2efa9fea..d47decabcbbb8fd7509317da07c3436c4c611347 100644 (file)
@@ -9,46 +9,25 @@
 #include "gtk--/button.h"
 
 gnomeBC::gnomeBC(string const & cancel, string const & close)
-       : ButtonControllerBase(cancel, close),
-         okay_(0), apply_(0), cancel_(0), undo_all_(0)
+       : GuiBC<Gtk::Button, Gtk::Widget>(cancel, close)
 {}
 
 
-void gnomeBC::setSensitive(Gtk::Button * btn, ButtonPolicy::Button id)
+void gnomeBC::setWidgetEnabled(Gtk::Widget * obj, bool enabled)
 {
-       if (btn) {
-               bool const enabled = bp().buttonStatus(id);
-               btn->set_sensitive(enabled);
-       }
+       if (obj)
+               obj->set_sensitive(enabled);
 }
 
 
-void gnomeBC::refresh()
+void gnomeBC::setButtonEnabled(Gtk::Button * btn, bool enabled) 
 {
-       setSensitive(okay_, ButtonPolicy::OKAY);
-       setSensitive(apply_, ButtonPolicy::APPLY);
-       setSensitive(undo_all_, ButtonPolicy::UNDO_ALL);
-
-#warning Handle the cancel button correctly! (be 20010327)
-#if 0
-       if (cancel_) {
-               bool const enabled = bp().buttonStatus(ButtonPolicy::CANCEL);
-//             if (enabled)
-//                     Change label to cancel_label_
-//             else
-//                     Change label to close_label_
-//Need to adapt it somehow since we use stock Gnome buttons.
-       }
-#endif
-       
-       if (!read_only_.empty()) {
-               bool enable = true;
-               if (bp().isReadOnly()) enable = false;
-               
-               WidgetList::const_iterator end = read_only_.end();
-               for (WidgetList::const_iterator iter = read_only_.begin();
-                    iter != end; ++iter) {
-                       (*iter)->set_sensitive(enable);
-               }
-       }
+       setWidgetEnabled(btn, enabled);
+}
+
+
+void gnomeBC::setButtonLabel(Gtk::Button * obj, string const & label)
+{
+#warning Implement me! (be 20010329)
+       obj->set_text(label);
 }
index 8f0524e4406938b314b671a67baffc44a56e6ad8..15b1157b037f276f998a5dce353138287f707ca9 100644 (file)
 #ifndef GNOMEBC_H
 #define GNOMEBC_H
 
-#include "ButtonController.h"
 #include <list>
 
 #ifdef __GNUG__
 #pragma interface
 #endif
 
+#include "ButtonControllerBase.h"
+#include "ButtonController.h"
+
 namespace Gtk {
 class Button;
 class Widget;
 }
 
-class gnomeBC : public ButtonControllerBase
+class gnomeBC : public GuiBC<Gtk::Button, Gtk::Widget>
 {
 public:
        ///
        gnomeBC(string const & cancel, string const & close);
 
-       /* Initialise Button Functions */
-       /// Call refresh() when finished setting the buttons.
-       void setOK(Gtk::Button * obj) {
-               okay_ = obj;
-       }
-       ///
-       void setApply(Gtk::Button * obj) {
-               apply_ = obj;
-       }
-       ///
-       void setCancel(Gtk::Button * obj) {
-               cancel_ = obj;
-       }
-       ///
-       void setUndoAll(Gtk::Button * obj) {
-               undo_all_ = obj;
-       }
-       ///
-       void addReadOnly(Gtk::Widget * obj) {
-               read_only_.push_front(obj);
-       }
-       ///
-       void eraseReadOnly() {
-               read_only_.clear();
-       }
-
-       /* Action Functions */
-       /// force a refresh of the buttons
-       virtual void refresh();
-
 private:
        /// Updates the button sensitivity (enabled/disabled)
-       void setSensitive(Gtk::Button * btn, ButtonPolicy::Button id);
-       ///
-       Gtk::Button * okay_;
-       ///
-       Gtk::Button * apply_;
-       ///
-       Gtk::Button * cancel_;
-       ///
-       Gtk::Button * undo_all_;
-       /// List of items to be deactivated when in one of the read-only states
-       typedef std::list<Gtk::Widget *> WidgetList;
-       WidgetList read_only_;
+       void setButtonEnabled(Gtk::Button * btn, bool enabled);
+
+       /// Updates the widget sensitivity (enabled/disabled)
+       void setWidgetEnabled(Gtk::Widget * obj, bool enabled);
+
+       /// Set the label on the button
+       void setButtonLabel(Gtk::Button * btn, string const & label)
 };
 
 #endif // GNOMEBC_H
index befcf445c2de061897d27fdac8bae6ff5e4e721d..0f76827b14a52377dd87a71ca9041b6a7dad421c 100644 (file)
@@ -1,3 +1,7 @@
+2001-03-29  Baruch Even  <baruch@lyx.org>
+
+       * kdeBC.[Ch]: Changed to use the new GuiBC template.
+
 2001-03-15  Lars Gullik Bjønnes  <larsbj@trylle.birdstep.com>
 
        * several files: remove CXX_WORKING_NAMESPACES
index 87ec207db514d5d1171498bcecc9aae8fd1befac..84647ae11066afc8091429774c41ac62e88f8c78 100644 (file)
@@ -8,48 +8,23 @@
 #include <qpushbutton.h>
 
 kdeBC::kdeBC(string const & cancel, string const & close)
-       : ButtonControllerBase(cancel, close),
-         okay_(0), apply_(0), cancel_(0), undo_all_(0), read_only_()
+       : GuiBC<QPushButton, QWidget>(cancel, close)
 {}
 
 
-void kdeBC::refresh()
+void setButtonEnabled(QPushButton * btn, bool enabled)
 {
-       if (okay_) {
-               if (bp().buttonStatus(ButtonPolicy::OKAY)) {
-                       okay_->setEnabled(true);
-               } else {
-                       okay_->setEnabled(false);
-               }
-       }
-       if (apply_) {
-               if (bp().buttonStatus(ButtonPolicy::APPLY)) {
-                       apply_->setEnabled(true);
-               } else {
-                       apply_->setEnabled(false);
-               }
-       }
-       if (undo_all_) {
-               if (bp().buttonStatus(ButtonPolicy::UNDO_ALL)) {
-                       undo_all_->setEnabled(true);
-               } else {
-                       undo_all_->setEnabled(false);
-               }
-       }
-       if (cancel_) {
-               if (bp().buttonStatus(ButtonPolicy::CANCEL)) {
-                       cancel_->setText(cancel_label.c_str());
-               } else {
-                       cancel_->setText(close_label.c_str());
-               }
-       }
-       if (!read_only_.empty()) {
-               bool enable = true;
-               if (bp().isReadOnly()) enable = false;
-                       
-               for (std::list<QWidget *>::iterator iter = read_only_.begin();
-                    iter != read_only_.end(); ++iter) {
-                       (*iter)->setEnabled(enable);
-               }
-       }
+       btn->setEnabled(true);
+}
+
+
+void setWidgetEnabled(QWidget * obj, bool enabled)
+{
+       obj->setEnabled(true);
+}
+
+
+void setButtonLabel(QPushButton * btn, string const & label)
+{
+       btn->setText(label.c_str());
 }
index 03d1631b70df691013d7c2a35472a127d1b3fef7..2833dd7738034fc193b5673bb7b85d47a32fdc02 100644 (file)
 #ifndef KDEBC_H
 #define KDEBC_H
 
-#include "ButtonController.h"
 #include <list>
 
 #ifdef __GNUG__
 #pragma interface
 #endif
 
+#include "ButtonControllerBase.h"
+#include "ButtonController.h"
+
 class QWidget;
 class QPushButton;
 
-class kdeBC : public ButtonControllerBase
+class kdeBC : public GuiBC<QPushButton, Qwidget>
 {
 public:
        ///
        kdeBC(string const & cancel, string const & close);
 
-       /* Initialise Button Functions */
-       /// Call refresh() when finished setting the buttons.
-       void setOK(QPushButton * obj) {
-               okay_ = obj;
-       }
-       ///
-       void setApply(QPushButton * obj) {
-               apply_ = obj;
-       }
-       ///
-       void setCancel(QPushButton * obj) {
-               cancel_ = obj;
-       }
-       ///
-       void setUndoAll(QPushButton * obj) {
-               undo_all_ = obj;
-       }
-       ///
-       void addReadOnly(QWidget * obj) {
-               read_only_.push_front(obj);
-       }
-       ///
-       void eraseReadOnly() {
-               read_only_.erase(read_only_.begin(), read_only_.end());
-       }
+private:
+       /// Updates the button sensitivity (enabled/disabled)
+       void setButtonEnabled(QPushButton * btn, bool enabled);
 
-       /* Action Functions */
-       /// force a refresh of the buttons
-       virtual void refresh();
+       /// Updates the widget sensitivity (enabled/disabled)
+       void setWidgetEnabled(QWidget * obj, bool enabled);
 
-private:
-       ///
-       QPushButton * okay_;
-       ///
-       QPushButton * apply_;
-       ///
-       QPushButton * cancel_;
-       ///
-       QPushButton * undo_all_;
-       /// List of items to be deactivated when in one of the read-only states
-       std::list<QWidget *> read_only_;
+       /// Set the label on the button
+       void setButtonLabel(QPushButton * btn, string const & label);
 };
 
 #endif // KDEBC_H
index 7d75cf993e7577bd61c897796863a0669522369a..5adbb8fd016783c1fcbca8bcb2146088715d7930 100644 (file)
@@ -1,3 +1,7 @@
+2001-03-30  Angus Leeming  <a.leeming@ic.ac.uk>
+
+       * Qt2Base.[Ch]: changed ControlBase to ControlButton.
+
 2001-03-19  Edwin Leuven  <leuven@fee.uva.nl>
 
        * qt2 compiles again:
index 9b53697936357e49da0f78d9c427483003374a63..b9ef03c270499622b912b7dde536e2a63d062fc2 100644 (file)
@@ -28,7 +28,7 @@
 #include <stdio.h>
 
 
-Qt2Base::Qt2Base(ControlBase & c, string const & t)
+Qt2Base::Qt2Base(ControlButton & c, string const & t)
        : ViewBC<qt2BC>(c), title_(t)
 {}
 
index e3087690b9dd884568e9a98186ecddb7446ba99e..5cbf618dc2e8f40242f9ffcc77002c3a7cf753f9 100644 (file)
@@ -38,7 +38,7 @@ class Qt2Base : public QObject, public ViewBC<qt2BC>
     Q_OBJECT
 public:
        ///
-       Qt2Base(ControlBase &, string const &);
+       Qt2Base(ControlButton &, string const &);
        ///
        virtual ~Qt2Base() {}
 
@@ -84,7 +84,7 @@ class Qt2DB: public Qt2Base
 {
 protected:
        ///
-       Qt2DB(ControlBase &, string const &);
+       Qt2DB(ControlButton &, string const &);
        /// Pointer to the actual instantiation of the Qt dialog
        virtual QDialog* form() const;
        /// Real GUI implementation.
@@ -93,7 +93,7 @@ protected:
 
 
 template <class Dialog>
-Qt2DB<Dialog>::Qt2DB(ControlBase & c, string const & t)
+Qt2DB<Dialog>::Qt2DB(ControlButton & c, string const & t)
        : Qt2Base(c, t)
 {}
 
@@ -110,14 +110,14 @@ class Qt2CB: public Base
 {
 protected:
        ///
-       Qt2CB(ControlBase &, string const &);
+       Qt2CB(ControlButton &, string const &);
        /// The parent controller
        Controller & controller() const;
 };
 
 
 template <class Controller, class Base>
-Qt2CB<Controller, Base>::Qt2CB(ControlBase & c, string const & t)
+Qt2CB<Controller, Base>::Qt2CB(ControlButton & c, string const & t)
        : Base(c, t)
 {}
 
index c108e5c24ce271269be45b0f378bd916a811bfaf..aa687420d3f6c750c1e11984a42b37970b0c2d5d 100644 (file)
@@ -1,3 +1,31 @@
+2001-03-30  Angus Leeming  <a.leeming@ic.ac.uk>
+
+       * FormBase.[Ch]:
+       * FormBrowser.[Ch]: changes associated with renaming ControlBase as
+       ControlButton.
+
+       * FormExternal.[Ch]:
+       * forms/form_external.fd: implemented controller-view split.
+
+       * Dialogs.C: associated changes.
+
+       * FormGraphics.[Ch]:
+       * FormInclude.[Ch]:
+       * FormPrint.[Ch]:
+       moved the browsing functionality into the controller.
+
+       * xforms_helpers.[Ch]: moved browseFile to
+       ../controllers/helper_funcs.[Ch]
+
+       * FormCitation.C
+       * forms/form_citation.fd: added case sensitive search button.
+
+2001-03-29  Angus Leeming  <a.leeming@ic.ac.uk>
+
+       * xformsBC.[Ch]: Patched in a slight reworking of Baruch Even's patch.
+       Code moved into the generic template base class. Replaced
+       setCancelCloseButton() with setButtonLabel().
+
 2001-03-29  Juergen Vigna  <jug@sad.it>
 
        * FormMinipage.C: removed widthp_ and all it's functions and changed
@@ -5,9 +33,9 @@
 
 2001-03-28  Angus Leeming  <a.leeming@ic.ac.uk>
 
-       * FormGraphics.C:
+       * FormGraphics.[Ch]:
        * forms/form_graphics.fd:
-       * FormIndex.C:
+       * FormIndex.[Ch]:
        * forms/form_index.fd: implemented controller-view split.
 
        * Dialogs.C: associated changes.
index d307f1c84ed80e6160faac0399ff28471a6f0e7f..2783a4cc2a927545a9a9a10fd8ffaf47a3605d37 100644 (file)
@@ -26,6 +26,7 @@
 #include "ControlCopyright.h"
 #include "ControlCredits.h"
 #include "ControlError.h"
+#include "ControlExternal.h" 
 #include "ControlGraphics.h"
 #include "ControlInclude.h"
 #include "ControlIndex.h"
@@ -51,6 +52,7 @@
 #include "form_copyright.h"
 #include "form_credits.h"
 #include "form_error.h"
+#include "form_external.h" 
 #include "form_graphics.h"
 #include "form_include.h"
 #include "form_index.h"
@@ -70,6 +72,7 @@
 #include "FormCopyright.h"
 #include "FormCredits.h"
 #include "FormError.h"
+#include "FormExternal.h" 
 #include "FormGraphics.h"
 #include "FormInclude.h"
 #include "FormIndex.h"
@@ -85,7 +88,6 @@
 #include "FormVCLog.h"
 
 #include "FormDocument.h"
-#include "FormExternal.h" 
 #include "FormMathsPanel.h"
 #include "FormParagraph.h"
 #include "FormPreferences.h"
@@ -107,6 +109,7 @@ Dialogs::Dialogs(LyXView * lv)
        add(new GUICopyright<FormCopyright, xformsBC>(*lv, *this));
        add(new GUICredits<FormCredits, xformsBC>(*lv, *this));
        add(new GUIError<FormError, xformsBC>(*lv, *this));
+       add(new GUIExternal<FormExternal, xformsBC>(*lv, *this));
        add(new GUIGraphics<FormGraphics, xformsBC>(*lv, *this));
        add(new GUIInclude<FormInclude, xformsBC>(*lv, *this));
        add(new GUIIndex<FormIndex, xformsBC>(*lv, *this));
@@ -121,7 +124,6 @@ Dialogs::Dialogs(LyXView * lv)
        add(new GUIVCLog<FormVCLog, xformsBC>(*lv, *this));
 
        add(new FormDocument(lv, this));
-       add(new FormExternal(lv, this));
        add(new FormMathsPanel(lv, this));
        add(new FormParagraph(lv, this));
        add(new FormPreferences(lv, this));
index d1cd266962af69fe6f15d9833d52aca719cae89a..8ba2319ff623a06870422be56ac789712229454a 100644 (file)
@@ -25,7 +25,7 @@
 extern "C" int C_FormBaseWMHideCB(FL_FORM * form, void *);
 
 
-FormBase::FormBase(ControlBase & c, string const & t)
+FormBase::FormBase(ControlButton & c, string const & t)
        : ViewBC<xformsBC>(c), minw_(0), minh_(0), title_(t)
 {}
 
index fe7761e2fe79d1a7317ebbfe31fefb673703049e..e2911c42ff19811afa9c3b8892e06c92ab774c55 100644 (file)
@@ -33,7 +33,7 @@ class FormBase : public ViewBC<xformsBC>
 {
 public:
        ///
-       FormBase(ControlBase &, string const &);
+       FormBase(ControlButton &, string const &);
        ///
        virtual ~FormBase() {}
 
@@ -76,7 +76,7 @@ class FormDB: public FormBase
 {
 protected:
        ///
-       FormDB(ControlBase &, string const &);
+       FormDB(ControlButton &, string const &);
        /// Pointer to the actual instantiation of xform's form
        virtual FL_FORM * form() const;
        /// Real GUI implementation.
@@ -85,7 +85,7 @@ protected:
 
 
 template <class Dialog>
-FormDB<Dialog>::FormDB(ControlBase & c, string const & t)
+FormDB<Dialog>::FormDB(ControlButton & c, string const & t)
        : FormBase(c, t)
 {}
 
@@ -103,14 +103,14 @@ class FormCB: public Base
 {
 protected:
        ///
-       FormCB(ControlBase &, string const &);
+       FormCB(ControlButton &, string const &);
        /// The parent controller
        Controller & controller() const;
 };
 
 
 template <class Controller, class Base>
-FormCB<Controller, Base>::FormCB(ControlBase & c, string const & t)
+FormCB<Controller, Base>::FormCB(ControlButton & c, string const & t)
        : Base(c, t)
 {}
 
index 2b2aae8f81d84ffc9ab55ecd1a1c7ff10614206d..64d8610ff54aa07c904b5fb8c8c7e9323e87cff6 100644 (file)
@@ -12,7 +12,7 @@
 #include "form_browser.h"
 #include "xformsBC.h"
 
-FormBrowser::FormBrowser(ControlBase & c, string const & t)
+FormBrowser::FormBrowser(ControlButton & c, string const & t)
        : FormDB<FD_form_browser>(c, t)
 {}
        
index 6e601ef2b80670cfc54fdf58e3926b19826b8e98..ed54aec32334d91508518037e34b367c45d54f8e 100644 (file)
@@ -25,7 +25,7 @@ struct FD_form_browser;
 class FormBrowser : public FormDB<FD_form_browser> {
 public:
        ///
-       FormBrowser(ControlBase &, string const &);
+       FormBrowser(ControlButton &, string const &);
 
 private:
        /// Build the dialog.
index f698d53a537289ecc6a52a95ccc1b7a8902de5ab..fe8fa9eacfdc7be9625c8f47e0beb3146c7d18cd 100644 (file)
@@ -1,4 +1,3 @@
-// -*- C++ -*-
 /* This file is part of
  * ====================================================== 
  *
@@ -8,7 +7,8 @@
  *
  * ======================================================
  *
- * \author Angus Leeming <a.leeming@ic.ac.uk>
+ * \file FormCitation.C
+ * \author Angus Leeming, a.leeming@ic.ac.uk
  */
 
 #include <config.h>
@@ -68,6 +68,7 @@ void FormCitation::build()
        fl_set_input_return(dialog_->input_after,  FL_RETURN_CHANGED);
        fl_set_input_return(dialog_->input_before, FL_RETURN_CHANGED);
 
+       fl_set_button(dialog_->button_search_case, 0);
        fl_set_button(dialog_->button_search_type, 0);
        fl_set_object_label(dialog_->button_search_type, _("Simple"));
 
@@ -228,12 +229,20 @@ ButtonPolicy::SMInput FormCitation::input(FL_OBJECT * ob, long)
                activate = ButtonPolicy::SMI_VALID;
 
        } else if (ob == dialog_->button_search_type) {
+               fl_freeze_form(form());
+               // Fudge to overcome xforms drawing bug
+               fl_hide_object(dialog_->button_search_type);
+               
                if (fl_get_button(dialog_->button_search_type))
                        fl_set_object_label(dialog_->button_search_type,
                                            _("Regex"));
                else
                        fl_set_object_label(dialog_->button_search_type,
                                            _("Simple"));
+
+               fl_show_object(dialog_->button_search_type);
+               fl_unfreeze_form(form());
+
                return ButtonPolicy::SMI_NOOP;
                
        } else if (ob == dialog_->button_previous ||
@@ -260,9 +269,12 @@ ButtonPolicy::SMInput FormCitation::input(FL_OBJECT * ob, long)
                else
                        start -= 1;
 
+               bool const caseSensitive =
+                       fl_get_button(dialog_->button_search_case);
+
                vector<string>::const_iterator const cit =
                        biblio::searchKeys(theMap, bibkeys, str,
-                                          start, type, dir);
+                                          start, type, dir, caseSensitive);
 
                if (cit == bibkeys.end())
                        return ButtonPolicy::SMI_NOOP;
@@ -437,6 +449,10 @@ void FormCitation::setSize(int hbrsr, bool bibPresent) const
        y = dialog_->button_previous->y;
        fl_set_object_position(dialog_->button_search_type, x, y);
 
+       x = dialog_->button_search_case->x;
+       y = dialog_->button_next->y;
+       fl_set_object_position(dialog_->button_search_case, x, y);
+
        y = dialog_->frame_search->y + hframe + dh1;
        
        if (natbib) {
index 95748aa7362d6388631646052d2ba8505e7b7431..596ddaa1a6394ed16a73d3b737ed022a68df3291 100644 (file)
-/**
- * \file FormExternal.C
- * Copyright 2001 the LyX Team
- * Read the file COPYING
+/* This file is part of
+ * ====================================================== 
+ *
+ *           LyX, The Document Processor
+ *
+ *           Copyright 2000-2001 The LyX Team.
  *
- * \author unknown
+ * ======================================================
+ *
+ * \file FormExternal.C
+ * \author Asger Alstrup
  * \author John Levon
+ * \author Angus Leeming, a.leeming@ic.ac.uk
  */
 
 #include <config.h>
-#include <utility>
-
-#include FORMS_H_LOCATION
 
 #ifdef __GNUG__
 #pragma implementation
 #endif
 
-#include "debug.h"
-#include "gettext.h"
-#include "support/LAssert.h"
-#include "lyx_gui_misc.h"
-#include "Dialogs.h"
-#include "LyXView.h"
-#include "buffer.h"
+#include "xformsBC.h"
+#include "ControlExternal.h"
 #include "FormExternal.h"
 #include "form_external.h"
-#include "frontends/FileDialog.h"
-#include "LString.h"
-#include "support/filetools.h"
-
-using std::pair;
-using std::make_pair;
-using std::endl;
-using SigC::slot;
-
-FormExternal::FormExternal(LyXView * lv, Dialogs * d)
-       : FormBaseBD(lv, d, _("Edit external file")),
-       inset_(0), ih_(0)
-{
-       d->showExternal.connect(slot(this, &FormExternal::showInset));
-}
+#include "gettext.h"
+#include "xforms_helpers.h"
+#include "helper_funcs.h"
 
+typedef FormCB<ControlExternal, FormDB<FD_form_external> > base_class;
 
-extern "C" void ExternalTemplateCB(FL_OBJECT * ob, long data)
-{
-       FormExternal::templateCB(ob, data);
-}
+FormExternal::FormExternal(ControlExternal & c)
+       : base_class(c, _("Edit external file"))
+{}
 
 
-extern "C" void ExternalBrowseCB(FL_OBJECT * ob, long data)
+void FormExternal::apply()
 {
-       FormExternal::browseCB(ob, data);
-}
-
+       controller().params().filename =
+               fl_get_input(dialog_->input_filename);
+       controller().params().parameters =
+               fl_get_input(dialog_->input_parameters);
 
-extern "C" void ExternalEditCB(FL_OBJECT * ob, long data)
-{
-       FormExternal::editCB(ob, data);
+       int const choice = fl_get_choice(dialog_->choice_template);
+       controller().params().templ = controller().getTemplate(choice);
 }
 
 
-extern "C" void ExternalViewCB(FL_OBJECT * ob, long data)
+void FormExternal::build()
 {
-       FormExternal::viewCB(ob, data);
-}
-
+       dialog_.reset(build_external());
 
-extern "C" void ExternalUpdateCB(FL_OBJECT * ob, long data)
-{
-       FormExternal::updateCB(ob, data);
-}
+       string const choice =
+           " " + getStringFromVector(controller().getTemplates(), " | ") + " ";
+       fl_addto_choice(dialog_->choice_template, choice.c_str());
 
+       bc().setOK(dialog_->button_ok);
+       bc().setCancel(dialog_->button_cancel);
+       bc().refresh();
 
-FL_FORM * FormExternal::form() const
-{
-       if (dialog_.get())
-               return dialog_->form;
-       return 0;
+       bc().addReadOnly(dialog_->input_filename);
+       bc().addReadOnly(dialog_->button_filenamebrowse);
+       bc().addReadOnly(dialog_->input_parameters);
 }
 
 
-void FormExternal::connect()
+void FormExternal::update()
 {
-       u_ = d_->updateBufferDependent.
-                connect(slot(this, &FormExternal::updateSlot));
-       h_ = d_->hideBufferDependent.
-                connect(slot(this, &FormExternal::hide));
-       FormBaseDeprecated::connect();
-}
-
+       InsetExternal::Params const & params = controller().params();
 
-void FormExternal::disconnect()
-{
-       inset_ = 0;
-       ih_.disconnect();
-       FormBaseBD::disconnect();
-}
+       fl_set_input(dialog_->input_filename, params.filename.c_str());
+       fl_set_input(dialog_->input_parameters, params.parameters.c_str());
 
+       int const ID = controller().getTemplateNumber(params.templ.lyxName);
+       if (ID >= 0) {
+               setEnabled(dialog_->choice_template, true);
+               fl_set_choice(dialog_->choice_template, ID+1);
+       } else
+               setEnabled(dialog_->choice_template, false);
 
-void FormExternal::updateSlot(bool switched)
-{
-       if (switched)
-               hide();
-       else
-               update();
+       updateComboChange();
 }
 
 
-void FormExternal::showInset(InsetExternal * inset)
+ButtonPolicy::SMInput FormExternal::input(FL_OBJECT * ob, long)
 {
-       Assert(inset);
+       if (ob == dialog_->choice_template) {
 
-       // If connected to another inset, disconnect from it.
-       if (inset_)
-               ih_.disconnect();
+               // set to the chosen template
+               int const choice = fl_get_choice(dialog_->choice_template);
+               controller().params().templ = controller().getTemplate(choice);
 
-       inset_ = inset;
-       params_ = inset_->params();
+               updateComboChange();
 
-       ih_ = inset->hideDialog.connect(slot(this, &FormExternal::hide));
-       show();
-}
+       } else if (ob == dialog_->button_filenamebrowse) {
 
+               string const in_name  = fl_get_input(dialog_->input_filename);
+               string const out_name = controller().Browse(in_name);
+               fl_set_input(dialog_->input_filename, out_name.c_str());
 
-void FormExternal::build()
-{
-       dialog_.reset(build_external());
+       } else if (ob == dialog_->button_edit) {
 
-       fl_addto_choice(dialog_->choice_template,
-                       getTemplatesComboString().c_str());
+               apply();
+               controller().editExternal();
 
-       bc_.setOK(dialog_->button_ok);
-       bc_.setCancel(dialog_->button_cancel);
-       bc_.refresh();
+       } else if (ob == dialog_->button_view) {
 
-       bc_.addReadOnly(dialog_->input_filename);
-       bc_.addReadOnly(dialog_->button_filenamebrowse);
-       bc_.addReadOnly(dialog_->input_parameters);
-}
+               apply();
+               controller().viewExternal();
 
+       } else if (ob == dialog_->button_update) {
 
-string const FormExternal::getTemplatesComboString() const
-{
-       string result;
-       bool first = true;
-       ExternalTemplateManager::Templates::const_iterator i1, i2;
-       i1 = ExternalTemplateManager::get().getTemplates().begin();
-       i2 = ExternalTemplateManager::get().getTemplates().end();
-       for (; i1 != i2; ++i1) {
-               if (!first)
-                       result += "|";
-               else
-                       first = false;
-
-               result += (*i1).second.lyxName;
+               apply();
+               controller().updateExternal();
        }
-       return result;
-}
-
 
-int FormExternal::getTemplateComboNumber(string const & name) const
-{
-       int i = 1;
-       ExternalTemplateManager::Templates::const_iterator i1, i2;
-       i1 = ExternalTemplateManager::get().getTemplates().begin();
-       i2 = ExternalTemplateManager::get().getTemplates().end();
-       for (; i1 != i2; ++i1) {
-               if (i1->second.lyxName == name)
-                       return i;
-               ++i;
-       }
-       // we can get here if a LyX document has a template not installed
-       // on this machine.
-       return 0;
-}
-
-
-ExternalTemplate FormExternal::getTemplate(int i) const
-{
-       ExternalTemplateManager::Templates::const_iterator i1;
-       i1 = ExternalTemplateManager::get().getTemplates().begin();
-       for (int n = 1; n < i; ++n)
-               ++i1;
-
-       return (*i1).second;
-}
-
-
-void FormExternal::update()
-{
-       fl_set_input(dialog_->input_filename, params_.filename.c_str());
-       fl_set_input(dialog_->input_parameters, params_.parameters.c_str());
-
-       fl_set_choice(dialog_->choice_template, getTemplateComboNumber(params_.templ.lyxName));
-
-       updateComboChange();
-
-       bc_.valid();
+       return ButtonPolicy::SMI_VALID;
 }
 
 
@@ -204,134 +122,10 @@ void FormExternal::updateComboChange()
 {
        // Update the help text
        fl_clear_browser(dialog_->browser_helptext);
-       fl_addto_browser(dialog_->browser_helptext, params_.templ.helpText.c_str());
+       fl_addto_browser(dialog_->browser_helptext,
+                        controller().params().templ.helpText.c_str());
        fl_set_browser_topline(dialog_->browser_helptext, 0);
 
-       if (params_.templ.automaticProduction) {
-               fl_deactivate_object(dialog_->button_update);
-               fl_set_object_lcol(dialog_->button_update, FL_INACTIVE);
-       } else {
-               fl_activate_object(dialog_->button_update);
-               fl_set_object_lcol(dialog_->button_update, FL_BLACK);
-       }
-}
-
-
-bool FormExternal::input(FL_OBJECT *, long)
-{
-       // FIXME: anything to do here ?
-       return true;
-}
-
-
-void FormExternal::apply()
-{
-       Assert(inset_);
-
-       if (lv_->buffer()->isReadonly())
-               return;
-
-       params_.filename = fl_get_input(dialog_->input_filename);
-       params_.parameters = fl_get_input(dialog_->input_parameters);
-       params_.templ = getTemplate(fl_get_choice(dialog_->choice_template));
-
-       inset_->setFromParams(params_);
-       lv_->view()->updateInset(inset_, true);
-}
-
-
-void FormExternal::templateCB(FL_OBJECT * ob, long)
-{
-       FormExternal * form = static_cast<FormExternal*>(ob->form->u_vdata);
-
-       // set to the chosen template
-       form->params_.templ = form->getTemplate(fl_get_choice(form->dialog_->choice_template));
-
-       form->updateComboChange();
-}
-
-
-void FormExternal::browseCB(FL_OBJECT * ob, long)
-{
-       FormExternal * form = static_cast<FormExternal*>(ob->form->u_vdata);
-
-       static string current_path;
-       static int once = 0;
-       
-       string p = fl_get_input(form->dialog_->input_filename);
-       string buf = MakeAbsPath(form->lv_->buffer()->fileName());
-       string buf2 = OnlyPath(buf);
-
-       if (!p.empty()) {
-               buf = MakeAbsPath(p, buf2);
-               buf = OnlyPath(buf);
-       } else {
-               buf = OnlyPath(form->lv_->buffer()->fileName());
-       }
-    
-       FileDialog fileDlg(form->lv_, _("Select external file"),
-               LFUN_SELECT_FILE_SYNC,
-               make_pair(string(_("Document")), string(buf)));
-       
-       /// Determine the template file extension
-       ExternalTemplate const & et = form->params_.templ;
-
-       string regexp = et.fileRegExp;
-       if (regexp.empty())
-               regexp = "*";
-
-       // FIXME: a temporary hack until the FileDialog interface is updated
-       regexp += "|";
-
-       while (1) {
-               string const path = (once) ? current_path : buf;
-               FileDialog::Result result = fileDlg.Select(path, regexp, fl_get_input(form->dialog_->input_filename));
-
-               if (result.second.empty())
-                       return;
-
-               string p = result.second;
-
-               buf = MakeRelPath(p, buf2);
-               current_path = OnlyPath(p);
-               once = 1;
-               
-               if (contains(p, "#") || contains(p, "~") || contains(p, "$")
-                   || contains(p, "%")) {
-                       WriteAlert(_("Filename can't contain any "
-                                    "of these characters:"),
-                                  // xgettext:no-c-format
-                                  _("'#', '~', '$' or '%'."));
-               } else
-                       break;
-       }
-
-       fl_set_input(form->dialog_->input_filename, buf.c_str());
-}
-
-
-void FormExternal::editCB(FL_OBJECT * ob, long)
-{
-       FormExternal * form = static_cast<FormExternal*>(ob->form->u_vdata);
-
-       form->apply();
-       form->inset_->editExternal();
-}
-
-
-void FormExternal::viewCB(FL_OBJECT * ob, long)
-{
-       FormExternal * form = static_cast<FormExternal*>(ob->form->u_vdata);
-       
-       form->apply();
-       form->inset_->viewExternal();
-}
-
-
-void FormExternal::updateCB(FL_OBJECT * ob, long)
-{
-       FormExternal * form = static_cast<FormExternal*>(ob->form->u_vdata);
-       
-       form->apply();
-       form->inset_->updateExternal();
+       bool const enabled = (!controller().params().templ.automaticProduction);
+       setEnabled(dialog_->button_update, enabled);
 }
index 16e97d66ae01744e44de82c2952848b3e81de160..34de5021fb04b161cf09c2f3a6a571de55bff858 100644 (file)
-/**
- * \file FormExternal.h
- * Copyright 2001 the LyX Team
- * Read the file COPYING
+/* This file is part of
+ * ====================================================== 
+ *
+ *           LyX, The Document Processor
+ *
+ *           Copyright 2000-2001 The LyX Team.
  *
- * \author unknown
+ * ======================================================
+ *
+ * \file FormExternal.h
+ * \author Asger Alstrup
  * \author John Levon
+ * \author Angus Leeming, a.leeming@ic.ac.uk
  */
 
 #ifndef FORMEXTERNAL_H
 #define FORMEXTERNAL_H
 
-#include <boost/smart_ptr.hpp>
-
 #ifdef __GNUG__
 #pragma interface
 #endif
 
-#include "FormBaseDeprecated.h"
+#include "FormBase.h"
 #include "insets/insetexternal.h"
 
+class ControlExternal;
 struct FD_form_external;
 
 /// The class for editing External insets via a dialog
-class FormExternal : public FormBaseBD {
+class FormExternal : public FormCB<ControlExternal, FormDB<FD_form_external> > {
 public:
        ///
-       FormExternal(LyXView *, Dialogs *);
-
-       /// Connect signals. Also perform any necessary initialisation.
-       virtual void connect();
-
-       /// Disconnect signals. Also perform any necessary housekeeping.
-       virtual void disconnect();
-
-       /// Slot launching dialog to an existing inset
-       void showInset(InsetExternal *);
-
-       /// bool indicates if a buffer switch took place
-       virtual void updateSlot(bool);
-
-       /// Callback function for the template drop-down
-       static void templateCB(FL_OBJECT *, long);
-
-       /// Callback function for the browse button
-       static void browseCB(FL_OBJECT *, long);
-
-       /// Callback function for the edit button
-       static void editCB(FL_OBJECT *, long);
-
-       /// Callback function for the view button
-       static void viewCB(FL_OBJECT *, long);
-
-       /// Callback function for the update production button
-       static void updateCB(FL_OBJECT *, long);
-
-       /// Pointer to the actual instantiation of the xform's form
-       virtual FL_FORM * form() const;
+       FormExternal(ControlExternal &);
 
 private:
-       /// calculate the string to set the combo box
-       string const getTemplatesComboString() const;
-
-       /// get the position in the combo for a given name
-       int getTemplateComboNumber(string const & name) const;
-
-       /// get a template given its combo position
-       ExternalTemplate getTemplate(int i) const;
+       /// apply changes
+       void apply();
 
-       /// change widgets on change of chosen template
-       void updateComboChange();
        /// build the dialog
        void build();
 
-       /// the inset we're modifying
-       InsetExternal * inset_;
-
-       /// the parameters
-       InsetExternal::InsetExternalParams params_;
-
        /// update the dialog
        void update();
 
-       /// apply changes
-       void apply();
-
-       bool input(FL_OBJECT * obj, long data);
+       /// Filter the inputs on callback from xforms
+       ButtonPolicy::SMInput input(FL_OBJECT *, long);
 
-       /// inset::hide connection.
-       SigC::Connection ih_;
+       ///
+       void updateComboChange();
 
-       /// build the dialog
+       /// Fdesign generated method
        FD_form_external * build_external();
-
-       /// Pointer to the actual instantiation of the ButtonController.
-       virtual xformsBC & bc();
-
-       /// the dialog implementation
-       boost::scoped_ptr<FD_form_external> dialog_;
-
-       /// The ButtonController
-       ButtonController<OkCancelReadOnlyPolicy, xformsBC> bc_;
 };
 
-
-inline
-xformsBC & FormExternal::bc()
-{
-       return bc_;
-}
-
 #endif // FORMEXTERNAL_H
index c20fdd3623281a6c223460ee1f13ef1f87cd58e6..36b1ab081f2596ac5b05919ca159c9abc3885c38 100644 (file)
 #include "FormGraphics.h"
 #include "form_graphics.h"
 
-//#include "lyx_gui_misc.h"
 #include "input_validators.h"
 #include "debug.h" // for lyxerr
 #include "support/lstrings.h"  // for strToDbl & tostr
 #include "support/FileInfo.h"  // for FileInfo
-#include "xforms_helpers.h"     // for browseFile
-#include "support/filetools.h" // for AddName
 #include "insets/insetgraphicsParams.h"
 
 using std::endl;
-using std::make_pair;
 
 typedef FormCB<ControlGraphics, FormDB<FD_form_graphics> > base_class;
 
@@ -229,8 +225,18 @@ ButtonPolicy::SMInput FormGraphics::input(FL_OBJECT *, long data)
                activate = checkInput();
                break;
        case BROWSE:
-               browse();
+       {
+               // Get the filename from the dialog
+               string const in_name = fl_get_input(dialog_->input_filename);
+               string const out_name = controller().Browse(in_name);
+
+               if (out_name != in_name && !out_name.empty()) {
+                       fl_set_input(dialog_->input_filename, out_name.c_str());
+                       input(0, 0);
+               }
                break;
+       }
+
        case ADVANCEDINPUT:
                lyxerr << "Advanced Options button depressed, "
                       << "show advanced options dialog"
@@ -289,37 +295,3 @@ ButtonPolicy::SMInput FormGraphics::checkInput()
 
        return activate;
 }
-
-
-// We need these in the file browser.
-extern string system_lyxdir;
-extern string user_lyxdir;
-
-void FormGraphics::browse()
-{
-       // Get the filename from the dialog
-       string const filename = fl_get_input(dialog_->input_filename);
-
-       string const title = N_("Graphics");
-       // FIXME: currently we need the second '|' to prevent mis-interpretation 
-       string const pattern = "*.(ps|png)|";
-
-       // Does user clipart directory exist?
-       string clipdir = AddName (user_lyxdir, "clipart");
-       FileInfo fileInfo(clipdir);
-       if (!(fileInfo.isOK() && fileInfo.isDir()))
-               // No - bail out to system clipart directory
-               clipdir = AddName (system_lyxdir, "clipart");
-       pair<string, string> dir1(N_("Clipart"), clipdir);
-       
-       // Show the file browser dialog
-       string const new_filename =
-               browseFile(controller().lv(), filename, title, pattern, dir1,
-                          make_pair(string(), string()));
-
-       // Save the filename to the dialog
-       if (new_filename != filename && !new_filename.empty()) {
-               fl_set_input(dialog_->input_filename, new_filename.c_str());
-               input(0, 0);
-       }
-}
index af7378a4d798789c4fb7ee2407f13cb65bfd1ce5..a43e48996d208e8331836a7d05a347b34821466f 100644 (file)
@@ -75,8 +75,6 @@ private:
 
        /// Verify that the input is correct. If not disable ok/apply buttons.
        ButtonPolicy::SMInput checkInput();
-       /// Open the file browse dialog to select an image file.
-       void browse();
 
        /// Fdesign generated method
        FD_form_graphics * build_graphics();
index 66efb6d0879a9aef9c7c67447056192673c9a41b..78f80f27381f7a4cd184062cc0cd94e6522b049e 100644 (file)
@@ -8,31 +8,20 @@
  * \author Angus Leeming, a.leeming@.ac.uk
  */
 
+#include <config.h>
 #include <algorithm>
-#include <utility>
 
 #ifdef __GNUG__
 #pragma implementation
 #endif
 
-#include <config.h>
 #include "xformsBC.h"
 #include "ControlInclude.h"
 #include "FormInclude.h"
 #include "form_include.h"
 #include "insets/insetinclude.h"
-
-#include "frontends/FileDialog.h"
-#include "LyXView.h"
-#include "buffer.h"
-
 #include "xforms_helpers.h" // setEnabled
-#include "support/filetools.h"
-#include "support/lstrings.h"
-#include "lyxrc.h"
-
-using std::make_pair;
-using std::pair;
+#include "support/lstrings.h" // compare
 
 typedef FormCB<ControlInclude, FormDB<FD_form_include> > base_class;
 
@@ -118,8 +107,23 @@ void FormInclude::apply()
 
 ButtonPolicy::SMInput FormInclude::input(FL_OBJECT * ob, long)
 {
-       if (ob == dialog_->button_browse)
-               return inputBrowse();
+       if (ob == dialog_->button_browse) {
+               ControlInclude::Type type;
+               if (fl_get_button(dialog_->check_useinput))
+                       type = ControlInclude::INPUT;
+               else if (fl_get_button(dialog_->check_verbatim))
+                       type = ControlInclude::VERBATIM;
+               else
+                       type = ControlInclude::INCLUDE;
+
+               string const in_name  = fl_get_input(dialog_->input_filename);
+               fl_freeze_form(form()); 
+               string const out_name = controller().Browse(in_name, type);
+               fl_set_input(dialog_->input_filename, out_name.c_str());
+               fl_unfreeze_form(form()); 
+
+               return ButtonPolicy::SMI_VALID;
+       }
 
        if (ob == dialog_->button_load) {
                if (compare(fl_get_input(dialog_->input_filename),"")) {
@@ -139,44 +143,3 @@ ButtonPolicy::SMInput FormInclude::input(FL_OBJECT * ob, long)
        
        return ButtonPolicy::SMI_VALID;
 }
-       
-
-ButtonPolicy::SMInput FormInclude::inputBrowse()
-{
-       // Should browsing too be disabled in RO-mode?
-       FileDialog fileDlg(controller().lv(),
-                          _("Select document to include"),
-                          LFUN_SELECT_FILE_SYNC,
-                          make_pair(string(_("Documents")),
-                                    string(lyxrc.document_path)));
-
-       string ext;
-                  
-       // input TeX, verbatim, or LyX file ?
-       if (fl_get_button(dialog_->check_useinput))
-               ext = _("*.tex| LaTeX Documents (*.tex)");
-       else if (fl_get_button(dialog_->check_verbatim))
-               ext = _("*| All files ");
-       else
-               ext = _("*.lyx| LyX Documents (*.lyx)");
-       
-       string const mpath =
-               OnlyPath(controller().params().masterFilename_);
-
-       FileDialog::Result const result =
-               fileDlg.Select(mpath, ext,
-                              fl_get_input(dialog_->input_filename));
-       
-       // check selected filename
-       if (result.second.empty())
-               return ButtonPolicy::SMI_NOOP;
-       
-       string const filename2 = MakeRelPath(result.second, mpath);
-
-       if (prefixIs(filename2, ".."))
-               fl_set_input(dialog_->input_filename, result.second.c_str());
-       else
-               fl_set_input(dialog_->input_filename, filename2.c_str());
-
-       return ButtonPolicy::SMI_VALID;
-}
index 8904d86258c634b0f82531e86980d6e0c2ea3ff5..65e4077a1fbbca1dfdd9e31341d8193414d0f60b 100644 (file)
@@ -37,9 +37,6 @@ private:
        /// Filter the inputs on callback from xforms
        virtual ButtonPolicy::SMInput input(FL_OBJECT *, long);
 
-       ///
-       ButtonPolicy::SMInput inputBrowse();
-
        /// Fdesign generated method
        FD_form_include * build_include();
 };
index 31f398fd0d0c7c16c8d4a292d0997c4d119bb819..447a5a7142cc2dc00ad894704a4b818303ec2eeb 100644 (file)
@@ -42,6 +42,7 @@
 #include "lyxlex.h"
 #include "input_validators.h"
 #include "xforms_helpers.h"
+#include "helper_funcs.h"
 #include "converter.h"
 #include "support/lyxfunctional.h"
 #include "support/lyxmanip.h"
index d25cf9d5a17bf7fa4a73594528f73296ee597721..fd5f7c776e58086751a7d431dbd6472cefd1eb81 100644 (file)
@@ -210,7 +210,15 @@ ButtonPolicy::SMInput FormPrint::input(FL_OBJECT * ob, long)
        }
 
        if (ob == dialog_->button_browse) {
-               browse();
+               // Get the filename from the dialog
+               string const in_name = fl_get_input(dialog_->input_file);
+               string const out_name = controller().Browse(in_name);
+
+               // Save the filename to the dialog
+               if (out_name != in_name && !out_name.empty()) {
+                       fl_set_input(dialog_->input_file, out_name.c_str());
+                       input(0, 0);
+               }
        }
                
        // it is probably legal to have no printer name since the system will
@@ -221,25 +229,3 @@ ButtonPolicy::SMInput FormPrint::input(FL_OBJECT * ob, long)
 //     }
        return activate;
 }
-
-
-void FormPrint::browse()
-{
-       // Get the filename from the dialog
-       string const filename = fl_get_input(dialog_->input_file);
-
-       string const title = N_("Print to file");
-       string const pattern = "*.ps";
-
-       // Show the file browser dialog
-       string const new_filename =
-               browseFile(controller().lv(), filename, title, pattern,
-                          make_pair(string(), string()),
-                          make_pair(string(), string()));
-
-       // Save the filename to the dialog
-       if (new_filename != filename && !new_filename.empty()) {
-               fl_set_input(dialog_->input_file, new_filename.c_str());
-               input(0, 0);
-       }
-}
index b101eab159c1884161887cd4731602ee9a256b33..b76783af68f6142a512f0de87d4630691f168efa 100644 (file)
@@ -48,9 +48,6 @@ private:
        /// Filter the inputs on callback from xforms
        virtual ButtonPolicy::SMInput input(FL_OBJECT *, long);
 
-       /// Open the file browse dialog.
-       void browse();
-
        /// Fdesign generated method
        FD_form_print * build_print();
 
index d41283bc9b098acaed75f5725ed7f7f1201d0dd1..b28173ebb7a99cb48a68dd7655400a12025f9bef 100644 (file)
@@ -73,9 +73,11 @@ FD_form_citation * FormCitation::build_citation()
     fl_set_object_lalign(obj, FL_ALIGN_TOP);
     fl_set_object_gravity(obj, FL_SouthWest, FL_SouthEast);
     fl_set_object_resize(obj, FL_RESIZE_NONE);
-  fdui->button_search_type = obj = fl_add_button(FL_PUSH_BUTTON, 25, 525, 90, 30, _("Simple"));
+  fdui->button_search_type = obj = fl_add_checkbutton(FL_PUSH_BUTTON, 25, 525, 30, 30, _("Simple"));
     fl_set_object_gravity(obj, FL_SouthWest, FL_SouthWest);
     fl_set_object_callback(obj, C_FormBaseInputCB, 0);
+  fdui->button_search_case = obj = fl_add_checkbutton(FL_PUSH_BUTTON, 25, 560, 30, 30, _("Case sensitive"));
+    fl_set_object_gravity(obj, FL_SouthWest, FL_SouthWest);
   {
     char const * const dummy = N_("Previous|#P");
     fdui->button_previous = obj = fl_add_button(FL_NORMAL_BUTTON, 315, 525, 90, 30, idex(_(dummy)));
index 931fa26dc5b278a37553236ca5e5ad7961d5eb6c..c168b103519ec68eef33b348712d44244b623846 100644 (file)
@@ -28,6 +28,7 @@ struct FD_form_citation {
        FL_OBJECT *frame_search;
        FL_OBJECT *input_search;
        FL_OBJECT *button_search_type;
+       FL_OBJECT *button_search_case;
        FL_OBJECT *button_previous;
        FL_OBJECT *button_next;
        FL_OBJECT *choice_style;
index f5d4aed97e874ce01fed73405acbc5b6a1bba7b8..62b949b4d1f8998ceff86d3d54fa4d3c5dce38ca 100644 (file)
@@ -33,7 +33,7 @@ FD_form_external * FormExternal::build_external()
     fl_set_object_boxtype(obj, FL_FRAME_BOX);
     fl_set_object_lsize(obj, FL_NORMAL_SIZE);
     fl_set_object_gravity(obj, FL_NorthWest, FL_NorthEast);
-    fl_set_object_callback(obj, ExternalTemplateCB, 0);
+    fl_set_object_callback(obj, C_FormBaseInputCB, 0);
   {
     char const * const dummy = N_("File|#F");
     fdui->input_filename = obj = fl_add_input(FL_NORMAL_INPUT, 130, 190, 190, 30, idex(_(dummy)));
@@ -49,7 +49,7 @@ FD_form_external * FormExternal::build_external()
   }
     fl_set_object_lsize(obj, FL_NORMAL_SIZE);
     fl_set_object_gravity(obj, FL_SouthEast, FL_SouthEast);
-    fl_set_object_callback(obj, ExternalBrowseCB, 0);
+    fl_set_object_callback(obj, C_FormBaseInputCB, 0);
   {
     char const * const dummy = N_("Parameters|#P");
     fdui->input_parameters = obj = fl_add_input(FL_NORMAL_INPUT, 130, 230, 300, 30, idex(_(dummy)));
@@ -65,7 +65,7 @@ FD_form_external * FormExternal::build_external()
     fl_set_object_color(obj, FL_COL1, FL_BLACK);
     fl_set_object_lsize(obj, FL_NORMAL_SIZE);
     fl_set_object_gravity(obj, FL_NorthEast, FL_NorthEast);
-    fl_set_object_callback(obj, ExternalEditCB, 0);
+    fl_set_object_callback(obj, C_FormBaseInputCB, 0);
   {
     char const * const dummy = N_("View result|#V");
     fdui->button_view = obj = fl_add_button(FL_NORMAL_BUTTON, 435, 90, 110, 30, idex(_(dummy)));
@@ -74,7 +74,7 @@ FD_form_external * FormExternal::build_external()
     fl_set_object_color(obj, FL_COL1, FL_BLACK);
     fl_set_object_lsize(obj, FL_NORMAL_SIZE);
     fl_set_object_gravity(obj, FL_NorthEast, FL_NorthEast);
-    fl_set_object_callback(obj, ExternalViewCB, 0);
+    fl_set_object_callback(obj, C_FormBaseInputCB, 0);
   {
     char const * const dummy = N_("Update result|#U");
     fdui->button_update = obj = fl_add_button(FL_NORMAL_BUTTON, 435, 130, 110, 30, idex(_(dummy)));
@@ -83,7 +83,7 @@ FD_form_external * FormExternal::build_external()
     fl_set_object_color(obj, FL_COL1, FL_BLACK);
     fl_set_object_lsize(obj, FL_NORMAL_SIZE);
     fl_set_object_gravity(obj, FL_NorthEast, FL_NorthEast);
-    fl_set_object_callback(obj, ExternalUpdateCB, 0);
+    fl_set_object_callback(obj, C_FormBaseInputCB, 0);
   fdui->button_ok = obj = fl_add_button(FL_RETURN_BUTTON, 315, 270, 110, 30, _("OK"));
     fl_set_object_color(obj, FL_COL1, FL_BLACK);
     fl_set_object_lsize(obj, FL_NORMAL_SIZE);
index 2802df3a59d267c53fe519c2ef70276e3f9c0639..8cddeb634dc1601b0ca88ecf02d4d5a23572240d 100644 (file)
@@ -5,12 +5,7 @@
 #define FD_form_external_h_
 
 /** Callbacks, globals and object handlers **/
-extern  "C" void ExternalTemplateCB(FL_OBJECT *, long);
 extern  "C" void C_FormBaseInputCB(FL_OBJECT *, long);
-extern  "C" void ExternalBrowseCB(FL_OBJECT *, long);
-extern  "C" void ExternalEditCB(FL_OBJECT *, long);
-extern  "C" void ExternalViewCB(FL_OBJECT *, long);
-extern  "C" void ExternalUpdateCB(FL_OBJECT *, long);
 extern  "C" void C_FormBaseOKCB(FL_OBJECT *, long);
 extern  "C" void C_FormBaseCancelCB(FL_OBJECT *, long);
 
index a373942bf001495631a27cc904cbd007da1699ef..9e4100cdf91798be5c54a0da330551474ce92837 100644 (file)
@@ -10,7 +10,7 @@ Unit of measure: FL_COORD_PIXEL
 Name: form_citation
 Width: 430
 Height: 830
-Number of Objects: 20
+Number of Objects: 21
 
 --------------------
 class: FL_BOX
@@ -193,11 +193,11 @@ callback:
 argument: 
 
 --------------------
-class: FL_BUTTON
+class: FL_CHECKBUTTON
 type: PUSH_BUTTON
-box: 25 525 90 30
-boxtype: FL_UP_BOX
-colors: FL_COL1 FL_COL1
+box: 25 525 30 30
+boxtype: FL_NO_BOX
+colors: FL_COL1 FL_YELLOW
 alignment: FL_ALIGN_CENTER
 style: FL_NORMAL_STYLE
 size: FL_DEFAULT_SIZE
@@ -210,6 +210,24 @@ name: button_search_type
 callback: C_FormBaseInputCB
 argument: 0
 
+--------------------
+class: FL_CHECKBUTTON
+type: PUSH_BUTTON
+box: 25 560 30 30
+boxtype: FL_NO_BOX
+colors: FL_COL1 FL_YELLOW
+alignment: FL_ALIGN_CENTER
+style: FL_NORMAL_STYLE
+size: FL_DEFAULT_SIZE
+lcol: FL_BLACK
+label: Case sensitive
+shortcut: 
+resize: FL_RESIZE_NONE
+gravity: FL_SouthWest FL_SouthWest
+name: button_search_case
+callback: 
+argument: 
+
 --------------------
 class: FL_BUTTON
 type: NORMAL_BUTTON
@@ -222,7 +240,7 @@ size: FL_DEFAULT_SIZE
 lcol: FL_BLACK
 label: Previous|#P
 shortcut: 
-resize: FL_RESIZE_ALL
+resize: FL_RESIZE_NONE
 gravity: FL_SouthEast FL_SouthEast
 name: button_previous
 callback: C_FormBaseInputCB
@@ -240,7 +258,7 @@ size: FL_DEFAULT_SIZE
 lcol: FL_BLACK
 label: Next|#N
 shortcut: 
-resize: FL_RESIZE_ALL
+resize: FL_RESIZE_NONE
 gravity: FL_SouthEast FL_SouthEast
 name: button_next
 callback: C_FormBaseInputCB
index 5cea76356728e0bf1d6f72a09083d249e6792155..228758e0fb50da359e0416d52cd5862f5ecf3210 100644 (file)
@@ -45,7 +45,7 @@ shortcut:
 resize: FL_RESIZE_ALL
 gravity: FL_NorthWest FL_NorthEast
 name: choice_template
-callback: ExternalTemplateCB
+callback: C_FormBaseInputCB
 argument: 0
 
 --------------------
@@ -81,7 +81,7 @@ shortcut:
 resize: FL_RESIZE_ALL
 gravity: FL_SouthEast FL_SouthEast
 name: button_filenamebrowse
-callback: ExternalBrowseCB
+callback: C_FormBaseInputCB
 argument: 0
 
 --------------------
@@ -117,7 +117,7 @@ shortcut:
 resize: FL_RESIZE_ALL
 gravity: FL_NorthEast FL_NorthEast
 name: button_edit
-callback: ExternalEditCB
+callback: C_FormBaseInputCB
 argument: 0
 
 --------------------
@@ -135,7 +135,7 @@ shortcut:
 resize: FL_RESIZE_ALL
 gravity: FL_NorthEast FL_NorthEast
 name: button_view
-callback: ExternalViewCB
+callback: C_FormBaseInputCB
 argument: 0
 
 --------------------
@@ -153,7 +153,7 @@ shortcut:
 resize: FL_RESIZE_ALL
 gravity: FL_NorthEast FL_NorthEast
 name: button_update
-callback: ExternalUpdateCB
+callback: C_FormBaseInputCB
 argument: 0
 
 --------------------
index c904cd167ad6178184e5e3fb4c34d15b4b533378..422aa171035b1779495efbe789d2233e239fd217 100644 (file)
@@ -1,10 +1,16 @@
-/**
- * \file xformsBC.C
- * Copyright 2001 the LyX Team
- * Read the file COPYING
+/* This file is part of
+ * ======================================================
+ *
+ *           LyX, The Document Processor
+ *
+ *           Copyright 2001 The LyX Team.
+ *
+ * ======================================================
  *
- * \author Allan Rae <rae@lyx.org>
- * \author Angus Leeming <a.leeming@ic.ac.uk>
+ * \file xformsBC.C
+ * \author Allan Rae, rae@lyx.org
+ * \author Angus Leeming, a.leeming@ic.ac.uk
+ * \author Baruch Even, baruch.even@writeme.com
  */
 
 #include <config.h>
 #include "xformsBC.h"
 #include "xforms_helpers.h"
 
-
 xformsBC::xformsBC(string const & cancel, string const & close)
-       : ButtonControllerBase(cancel, close),
-         okay_(0), apply_(0), cancel_(0), undo_all_(0), read_only_()
+       : GuiBC<FL_OBJECT, FL_OBJECT>(cancel, close)
 {}
 
 
-void xformsBC::refresh()
+void xformsBC::setButtonEnabled(FL_OBJECT * obj, bool enabled)
+{
+       setEnabled(obj, enabled);
+}
+
+
+void xformsBC::setWidgetEnabled(FL_OBJECT * obj, bool enabled)
+{
+       setEnabled(obj, enabled);
+}
+
+
+void xformsBC::setButtonLabel(FL_OBJECT * obj, string const & label)
 {
-       if (okay_) {
-               if (bp().buttonStatus(ButtonPolicy::OKAY)) {
-                       setEnabled(okay_, true);
-               } else {
-                       setEnabled(okay_, false);
-               }
-       }
-       if (apply_) {
-               if (bp().buttonStatus(ButtonPolicy::APPLY)) {
-                       setEnabled(apply_, true);
-               } else {
-                       setEnabled(apply_, false);
-               }
-       }
-       if (undo_all_) {
-               if (bp().buttonStatus(ButtonPolicy::UNDO_ALL)) {
-                       setEnabled(undo_all_, true);
-               } else {
-                       setEnabled(undo_all_, false);
-               }
-       }
-       if (cancel_) {
-               if (bp().buttonStatus(ButtonPolicy::CANCEL)) {
-                       fl_set_object_label(cancel_, cancel_label.c_str());
-               } else {
-                       fl_set_object_label(cancel_, close_label.c_str());
-               }
-       }
-       if (!read_only_.empty()) {
-               bool enable = true;
-               if (bp().isReadOnly()) enable = false;
-               for (std::list<FL_OBJECT *>::iterator iter = read_only_.begin();
-                    iter != read_only_.end(); ++iter) {
-                       setEnabled(*iter, enable);
-               }
-       }
+       fl_set_object_label(obj, label.c_str());
 }
index 614b3e9fed4aa9172562b640e7a493d0007a0650..d000484bb44ca591acc9489d2698bbd1f108a72e 100644 (file)
@@ -1,19 +1,16 @@
-// -*- 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.
  *
- *           This file Copyright 2000
- *           Allan Rae
  * ======================================================
  *
- * Author: Allan Rae <rae@lyx.org>
- * Non-xforms-specific code stripped-out and placed in a base class by
- * Angus Leeming <a.leeming@ic.ac.uk>
+ * \file xformsBC.h
+ * \author Allan Rae, rae@lyx.org
+ * \author Angus Leeming, a.leeming@ic.ac.uk
+ * \author Baruch Even, baruch.even@writeme.com
  */
 
 #ifndef XFORMSBC_H
 #pragma interface
 #endif
 
+#include "gettext.h"
+#include "ButtonControllerBase.h"
 #include "ButtonController.h"
 
-/** General purpose button controller for up to four buttons.
-    Controls the activation of the OK, Apply and Cancel buttons.
-    Actually supports 4 buttons in all and it's up to the user to decide on
-    the activation policy and which buttons correspond to which output of the
-    state machine.
-*/
-class xformsBC : public ButtonControllerBase
+class xformsBC : public GuiBC<FL_OBJECT, FL_OBJECT>
 {
 public:
        ///
        xformsBC(string const &, string const &);
 
-       /* Initialise Button Functions */
-       /// Call refresh() when finished setting the buttons.
-       void setOK(FL_OBJECT * obj) {
-               okay_ = obj;
-       }
-       ///
-       void setApply(FL_OBJECT * obj) {
-               apply_ = obj;
-       }
-       ///
-       void setCancel(FL_OBJECT * obj) {
-               cancel_ = obj;
-       }
-       ///
-       void setUndoAll(FL_OBJECT * obj) {
-               undo_all_ = obj;
-       }
-       ///
-       void addReadOnly(FL_OBJECT * obj) {
-               read_only_.push_front(obj);
-       }
-       ///
-       void eraseReadOnly() {
-               read_only_.erase(read_only_.begin(), read_only_.end());
-       }
+private:
+       /// Updates the button sensitivity (enabled/disabled)
+       void setButtonEnabled(FL_OBJECT *, bool enabled);
 
-       /* Action Functions */
-       /// force a refresh of the buttons
-       virtual void refresh();
+       /// Updates the widget sensitivity (enabled/disabled)
+       void setWidgetEnabled(FL_OBJECT *, bool enabled);
 
-private:
-       ///
-       FL_OBJECT * okay_;
-       ///
-       FL_OBJECT * apply_;
-       ///
-       FL_OBJECT * cancel_;
-       ///
-       FL_OBJECT * undo_all_;
-       /// List of items to be deactivated when in one of the read-only states
-       std::list<FL_OBJECT *> read_only_;
+       /// Set the label on the button
+       void setButtonLabel(FL_OBJECT *, string const & label);
 };
 
 #endif // XFORMSBC_H
index f8601b75179bfb0089d6099935dc20bf4cc0a1e7..87459b34f7314f2b4fb8e04a6f37474479a2d1e3 100644 (file)
  
 #include "xforms_helpers.h"
 #include "lyxlex.h"
-#include "frontends/FileDialog.h"
 #include "support/FileInfo.h"
 #include "support/filetools.h"
-#include "lyx_gui_misc.h" // WriteAlert
 #include "gettext.h"
 
 using std::ofstream;
@@ -99,39 +97,6 @@ string formatted(string const & sin, int w, int size, int style)
 }
 
 
-string const browseFile(LyXView * lv, string const & filename,
-                       string const & title,
-                       string const & pattern, 
-                       pair<string,string> const & dir1,
-                       pair<string,string> const & dir2)
-{
-       string lastPath = ".";
-       if (!filename.empty()) lastPath = OnlyPath(filename);
-
-       FileDialog fileDlg(lv, title, LFUN_SELECT_FILE_SYNC, dir1, dir2);
-
-       FileDialog::Result result;
-       while (1) {
-               result = fileDlg.Select(lastPath, pattern, OnlyFilename(filename));
-
-               if (result.second.empty()) 
-                       return result.second;
-
-               lastPath = OnlyPath(result.second);
-
-               if (result.second.find_first_of("#~$% ") == string::npos)
-                       break; 
-               WriteAlert(_("Filename can't contain any "
-                       "of these characters:"),
-                       _("space, '#', '~', '$' or '%'."));
-       }
-
-       return result.second;
-}
-
-
 namespace {
 
 // sorted by hand to prevent LyXLex from complaining on read().
index d7d2bd2240445948586e1eec90064e62824d1109..a8c17312704fef1b35c2f57a5c3a9e2fc071a171 100644 (file)
@@ -5,9 +5,6 @@
 #pragma interface
 #endif
 
-#include <utility> // pair
-//#include <config.h>
-#include "LString.h"
 #include "Color.h"
 
 // Set an FL_OBJECT to activated or deactivated
@@ -17,20 +14,6 @@ void setEnabled(FL_OBJECT *, bool enable);
 string formatted(string const &label, int w,
                 int=FL_NORMAL_SIZE, int=FL_NORMAL_STYLE);
 
-class LyXView;
-/** Launch a file dialog and return the chosen file.
-    filename: a suggested filename.
-    title: the title of the dialog.
-    pattern: *.ps etc.
-    dir1 = (name, dir), dir2 = (name, dir): extra buttons on the dialog.
-*/
-string const browseFile(LyXView *lv, string const & filename,
-                       string const & title,
-                       string const & pattern, 
-                       std::pair<string,string> const & dir1,
-                       std::pair<string,string> const & dir2);
-
 /// struct holding xform-specific colors
 struct XformsColor : public NamedColor {
        int colorID;
index 4b7f9b4009247b5d5dd4d1a0d424ef7b09e843de..de982e204268236f9cfa4e21d1bb4e5b6fb44b21 100644 (file)
@@ -1,3 +1,9 @@
+2001-03-29  Angus Leeming  <a.leeming@ic.ac.uk>
+
+       * insetexternal.[Ch]: renamed InsetExternal::InsetExternalParams as
+       InsetExternal::Params.
+       Added operator==() and operator!=() for the Params struct.
+
 2001-03-29  Juergen Vigna  <jug@sad.it>
 
        * lyxinset.h: changed parameter of getMaxWidth from Painter & to
@@ -8,7 +14,7 @@
 
 2001-03-28  Angus Leeming  <a.leeming@ic.ac.uk>
 
-       * insets/figinset.[Ch]: changed headers lyx.h, form1.h -> figure_form.h.
+       * figinset.[Ch]: changed headers lyx.h, form1.h -> figure_form.h.
 
 2001-03-27  Angus Leeming  <a.leeming@ic.ac.uk>
 
index 92fcf4e99970b564744d128fb5a1fd5aeee409dc..513eeeb65a1a59e9fbd2efd887e838ffd2388cc5 100644 (file)
@@ -48,13 +48,13 @@ InsetExternal::~InsetExternal()
 }
 
 
-InsetExternal::InsetExternalParams InsetExternal::params() const
+InsetExternal::Params InsetExternal::params() const
 {
        return params_;
 }
  
  
-void InsetExternal::setFromParams(InsetExternalParams const & p)
+void InsetExternal::setFromParams(Params const & p)
 {
        params_.filename = p.filename;
        params_.parameters = p.parameters;
@@ -290,3 +290,20 @@ void InsetExternal::editExternal() const
                        et.editCommand),
                        view->buffer());
 }
+
+
+bool operator==(InsetExternal::Params const & left,
+               InsetExternal::Params const & right)
+{
+       return ((left.filename   == right.filename) &&
+               (left.parameters == right.parameters) &&
+               (left.templ.lyxName == right.templ.lyxName));
+}
+
+
+bool operator!=(InsetExternal::Params const & left,
+               InsetExternal::Params const & right)
+{
+       return  !(left == right);
+}
+
index fdc870e6aaa4967d2a1150cb5b078e6e8d5860fa..486c3244af855cfb9557e44da8fe39a9c9ad452b 100644 (file)
@@ -25,8 +25,8 @@
 class InsetExternal : public InsetButton {
 public:
        /// hold parameters settable from the GUI
-       struct InsetExternalParams {
-               InsetExternalParams(string const & f = string(), 
+       struct Params {
+               Params(string const & f = string(), 
                                        string const & p = string(), 
                                        ExternalTemplate const & t = ExternalTemplate())
                        : filename(f), parameters(p), templ(t) {}
@@ -82,7 +82,7 @@ public:
        // The following public members are used from the frontends code
 
        /// set the parameters from a Params structure
-       virtual void setFromParams(InsetExternalParams const &);
+       virtual void setFromParams(Params const &);
 
        /// update the file represented by the template
        void updateExternal() const;
@@ -94,7 +94,7 @@ public:
        void viewExternal() const;
 
        /// return a copy of our current params
-       InsetExternalParams params() const;
+       Params params() const;
 
        /// hide connection
        SigC::Signal0<void> hideDialog;
@@ -114,10 +114,15 @@ private:
        BufferView * view;
 
        /// the current params
-       InsetExternalParams params_;
+       Params params_;
 
        /// A temp filename
        string tempname;
 };
 
+///
+bool operator==(InsetExternal::Params const &, InsetExternal::Params const &);
+///
+bool operator!=(InsetExternal::Params const &, InsetExternal::Params const &);
+
 #endif