+++ /dev/null
-// -*- 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);
-}
-/*
- * \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
{
--- /dev/null
+// -*- 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);
+}
--- /dev/null
+/* 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
+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
+++ /dev/null
-// -*- 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();
-}
+++ /dev/null
-/* 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
--- /dev/null
+// -*- 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();
+}
--- /dev/null
+/* 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
#pragma interface
#endif
-#include "ControlBase.h"
+#include "ControlButton.h"
class Dialogs;
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:
///
--- /dev/null
+/* 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;
+}
--- /dev/null
+/* 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
#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)
{
}
-LyXView * ControlGraphics::lv() const
-{
- return &lv_;
-}
-
-
InsetGraphicsParams const ControlGraphics::getParams(string const &)
{
return InsetGraphicsParams();
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()));
+}
///
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.
* \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)
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()));
+}
: 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.
- /// Instantiation of ControlBase virtual methods.
+ /// Instantiation of ControlButton virtual methods.
/// Get changed parameters and Dispatch them to the kernel.
virtual void apply();
*/
#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)
}
-LyXView * ControlPrint::lv() const
-{
- return &lv_;
-}
-
-
PrinterParams & ControlPrint::params() const
{
Assert(params_);
}
+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()));
+}
///
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;
};
+/** 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;
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 \
ControlDialogs.h \
ControlError.h \
ControlError.C \
+ ControlExternal.h \
+ ControlExternal.C \
ControlGraphics.h \
ControlGraphics.C \
ControlInclude.C \
#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() {}
protected:
/// The view is, after all, controlled!
- ControlBase & controller_;
+ ControlButton & controller_;
};
class ViewBC : public ViewBase {
public:
///
- ViewBC(ControlBase & c) : ViewBase(c) {}
+ ViewBC(ControlButton & c) : ViewBase(c) {}
protected:
///
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,
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;
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;
}
}
#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)
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;
+}
+
+
#ifndef HELPERFUNCS_H
#define HELPERFUNCS_H
+#include <utility> // pair
+
#ifdef __GNUG__
#pragma interface
#endif
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> >
*/
+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):
#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)
{}
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();
#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);
}
#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
+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
#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());
}
#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
+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:
#include <stdio.h>
-Qt2Base::Qt2Base(ControlBase & c, string const & t)
+Qt2Base::Qt2Base(ControlButton & c, string const & t)
: ViewBC<qt2BC>(c), title_(t)
{}
Q_OBJECT
public:
///
- Qt2Base(ControlBase &, string const &);
+ Qt2Base(ControlButton &, string const &);
///
virtual ~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.
template <class Dialog>
-Qt2DB<Dialog>::Qt2DB(ControlBase & c, string const & t)
+Qt2DB<Dialog>::Qt2DB(ControlButton & c, string const & t)
: Qt2Base(c, t)
{}
{
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)
{}
+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
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.
#include "ControlCopyright.h"
#include "ControlCredits.h"
#include "ControlError.h"
+#include "ControlExternal.h"
#include "ControlGraphics.h"
#include "ControlInclude.h"
#include "ControlIndex.h"
#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"
#include "FormCopyright.h"
#include "FormCredits.h"
#include "FormError.h"
+#include "FormExternal.h"
#include "FormGraphics.h"
#include "FormInclude.h"
#include "FormIndex.h"
#include "FormVCLog.h"
#include "FormDocument.h"
-#include "FormExternal.h"
#include "FormMathsPanel.h"
#include "FormParagraph.h"
#include "FormPreferences.h"
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));
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));
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)
{}
{
public:
///
- FormBase(ControlBase &, string const &);
+ FormBase(ControlButton &, string const &);
///
virtual ~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.
template <class Dialog>
-FormDB<Dialog>::FormDB(ControlBase & c, string const & t)
+FormDB<Dialog>::FormDB(ControlButton & c, string const & t)
: FormBase(c, t)
{}
{
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)
{}
#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)
{}
class FormBrowser : public FormDB<FD_form_browser> {
public:
///
- FormBrowser(ControlBase &, string const &);
+ FormBrowser(ControlButton &, string const &);
private:
/// Build the dialog.
-// -*- C++ -*-
/* This file is part of
* ======================================================
*
*
* ======================================================
*
- * \author Angus Leeming <a.leeming@ic.ac.uk>
+ * \file FormCitation.C
+ * \author Angus Leeming, a.leeming@ic.ac.uk
*/
#include <config.h>
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"));
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 ||
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;
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) {
-/**
- * \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;
}
{
// 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);
}
-/**
- * \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
#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;
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"
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);
- }
-}
/// 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();
* \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;
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),"")) {
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;
-}
/// 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();
};
#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"
}
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
// }
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);
- }
-}
/// 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();
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)));
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;
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)));
}
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)));
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)));
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)));
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);
#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);
Name: form_citation
Width: 430
Height: 830
-Number of Objects: 20
+Number of Objects: 21
--------------------
class: FL_BOX
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
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
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
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
resize: FL_RESIZE_ALL
gravity: FL_NorthWest FL_NorthEast
name: choice_template
-callback: ExternalTemplateCB
+callback: C_FormBaseInputCB
argument: 0
--------------------
resize: FL_RESIZE_ALL
gravity: FL_SouthEast FL_SouthEast
name: button_filenamebrowse
-callback: ExternalBrowseCB
+callback: C_FormBaseInputCB
argument: 0
--------------------
resize: FL_RESIZE_ALL
gravity: FL_NorthEast FL_NorthEast
name: button_edit
-callback: ExternalEditCB
+callback: C_FormBaseInputCB
argument: 0
--------------------
resize: FL_RESIZE_ALL
gravity: FL_NorthEast FL_NorthEast
name: button_view
-callback: ExternalViewCB
+callback: C_FormBaseInputCB
argument: 0
--------------------
resize: FL_RESIZE_ALL
gravity: FL_NorthEast FL_NorthEast
name: button_update
-callback: ExternalUpdateCB
+callback: C_FormBaseInputCB
argument: 0
--------------------
-/**
- * \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());
}
-// -*- 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
#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;
}
-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().
#pragma interface
#endif
-#include <utility> // pair
-//#include <config.h>
-#include "LString.h"
#include "Color.h"
// Set an FL_OBJECT to activated or deactivated
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;
+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
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>
}
-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;
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);
+}
+
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) {}
// 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;
void viewExternal() const;
/// return a copy of our current params
- InsetExternalParams params() const;
+ Params params() const;
/// hide connection
SigC::Signal0<void> hideDialog;
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