From 58d99b4a97b85a750704cf84c9639b408117271c Mon Sep 17 00:00:00 2001 From: Angus Leeming Date: Fri, 30 Mar 2001 09:51:46 +0000 Subject: [PATCH] * Baruch's GuiBC template. * 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 --- src/frontends/controllers/ButtonController.h | 138 ++++--- ...tonController.C => ButtonControllerBase.C} | 6 +- .../controllers/ButtonControllerBase.h | 81 ++++ src/frontends/controllers/ChangeLog | 41 ++ .../{ControlBase.C => ControlButton.C} | 17 +- .../{ControlBase.h => ControlButton.h} | 18 +- .../controllers/ControlConnections.h | 4 +- src/frontends/controllers/ControlExternal.C | 175 +++++++++ src/frontends/controllers/ControlExternal.h | 61 +++ src/frontends/controllers/ControlGraphics.C | 37 +- src/frontends/controllers/ControlGraphics.h | 4 +- src/frontends/controllers/ControlInclude.C | 42 ++- src/frontends/controllers/ControlInclude.h | 13 +- src/frontends/controllers/ControlInset.h | 2 +- src/frontends/controllers/ControlPrint.C | 20 +- src/frontends/controllers/ControlPrint.h | 4 +- src/frontends/controllers/GUI.h | 14 + src/frontends/controllers/Makefile.am | 9 +- src/frontends/controllers/ViewBase.h | 8 +- src/frontends/controllers/biblio.C | 31 +- src/frontends/controllers/helper_funcs.C | 44 +++ src/frontends/controllers/helper_funcs.h | 16 + src/frontends/gnome/ChangeLog | 14 + src/frontends/gnome/GnomeBase.C | 2 +- src/frontends/gnome/GnomeBase.h | 2 +- src/frontends/gnome/gnomeBC.C | 47 +-- src/frontends/gnome/gnomeBC.h | 55 +-- src/frontends/kde/ChangeLog | 4 + src/frontends/kde/kdeBC.C | 55 +-- src/frontends/kde/kdeBC.h | 52 +-- src/frontends/qt2/ChangeLog | 4 + src/frontends/qt2/Qt2Base.C | 2 +- src/frontends/qt2/Qt2Base.h | 10 +- src/frontends/xforms/ChangeLog | 32 +- src/frontends/xforms/Dialogs.C | 6 +- src/frontends/xforms/FormBase.C | 2 +- src/frontends/xforms/FormBase.h | 10 +- src/frontends/xforms/FormBrowser.C | 2 +- src/frontends/xforms/FormBrowser.h | 2 +- src/frontends/xforms/FormCitation.C | 22 +- src/frontends/xforms/FormExternal.C | 352 ++++-------------- src/frontends/xforms/FormExternal.h | 102 ++--- src/frontends/xforms/FormGraphics.C | 50 +-- src/frontends/xforms/FormGraphics.h | 2 - src/frontends/xforms/FormInclude.C | 75 +--- src/frontends/xforms/FormInclude.h | 3 - src/frontends/xforms/FormPreferences.C | 1 + src/frontends/xforms/FormPrint.C | 32 +- src/frontends/xforms/FormPrint.h | 3 - src/frontends/xforms/form_citation.C | 4 +- src/frontends/xforms/form_citation.h | 1 + src/frontends/xforms/form_external.C | 10 +- src/frontends/xforms/form_external.h | 5 - src/frontends/xforms/forms/form_citation.fd | 32 +- src/frontends/xforms/forms/form_external.fd | 10 +- src/frontends/xforms/xformsBC.C | 74 ++-- src/frontends/xforms/xformsBC.h | 69 +--- src/frontends/xforms/xforms_helpers.C | 35 -- src/frontends/xforms/xforms_helpers.h | 17 - src/insets/ChangeLog | 8 +- src/insets/insetexternal.C | 21 +- src/insets/insetexternal.h | 15 +- 62 files changed, 1044 insertions(+), 985 deletions(-) rename src/frontends/controllers/{ButtonController.C => ButtonControllerBase.C} (92%) create mode 100644 src/frontends/controllers/ButtonControllerBase.h rename src/frontends/controllers/{ControlBase.C => ControlButton.C} (70%) rename src/frontends/controllers/{ControlBase.h => ControlButton.h} (86%) create mode 100644 src/frontends/controllers/ControlExternal.C create mode 100644 src/frontends/controllers/ControlExternal.h diff --git a/src/frontends/controllers/ButtonController.h b/src/frontends/controllers/ButtonController.h index 891889e3a1..ed18f63cbf 100644 --- a/src/frontends/controllers/ButtonController.h +++ b/src/frontends/controllers/ButtonController.h @@ -1,7 +1,4 @@ -/* - * \file ButtonController.h - * - * This file is part of +/* This file is part of * ====================================================== * * LyX, The Document Processor @@ -10,77 +7,102 @@ * * ====================================================== * + * \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 -/** 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 . - * This abstract base class stripped of xforms-specific code by - * Angus Leeming - */ -class ButtonControllerBase : public boost::noncopyable +template +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 Widgets; + Widgets read_only_; }; +template +GuiBC::GuiBC(string const & cancel, string const & close) + : ButtonControllerBase(cancel, close) + , okay_(0), apply_(0), cancel_(0), undo_all_(0) +{} + + +template +void GuiBC::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 ButtonController: public GUIBC { diff --git a/src/frontends/controllers/ButtonController.C b/src/frontends/controllers/ButtonControllerBase.C similarity index 92% rename from src/frontends/controllers/ButtonController.C rename to src/frontends/controllers/ButtonControllerBase.C index 5653a4a3a6..f446d785c5 100644 --- a/src/frontends/controllers/ButtonController.C +++ b/src/frontends/controllers/ButtonControllerBase.C @@ -8,7 +8,7 @@ * * ====================================================== * - * \file ButtonController.C + * \file ButtonControllerBase.C * \author Allan Rae */ @@ -17,13 +17,13 @@ #endif #include -#include "ButtonController.h" +#include "ButtonControllerBase.h" #include "support/LAssert.h" ButtonControllerBase::ButtonControllerBase(string const & cancel, string const & close) - : cancel_label(cancel), close_label(close) + : cancel_label_(cancel), close_label_(close) {} diff --git a/src/frontends/controllers/ButtonControllerBase.h b/src/frontends/controllers/ButtonControllerBase.h new file mode 100644 index 0000000000..e395047bd2 --- /dev/null +++ b/src/frontends/controllers/ButtonControllerBase.h @@ -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 . + * This abstract base class stripped of xforms-specific code by + * Angus Leeming + */ +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 diff --git a/src/frontends/controllers/ChangeLog b/src/frontends/controllers/ChangeLog index 3fbf3fc315..110e0821e5 100644 --- a/src/frontends/controllers/ChangeLog +++ b/src/frontends/controllers/ChangeLog @@ -1,3 +1,44 @@ +2001-03-30 Angus Leeming + + * 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 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 * ControlMinipage.C: removed widthp_ and all it's functions and changed diff --git a/src/frontends/controllers/ControlBase.C b/src/frontends/controllers/ControlButton.C similarity index 70% rename from src/frontends/controllers/ControlBase.C rename to src/frontends/controllers/ControlButton.C index f1d03f02df..731c452799 100644 --- a/src/frontends/controllers/ControlBase.C +++ b/src/frontends/controllers/ControlButton.C @@ -8,27 +8,26 @@ * * ====================================================== * - * \file ControlBase.C + * \file ControlButton.C * \author Angus Leeming */ +#include + #ifdef __GNUG__ #pragma implementation #endif -#include - -#include "ButtonController.h" -#include "ControlBase.h" +#include "ControlButton.h" -void ControlBase::ApplyButton() +void ControlButton::ApplyButton() { apply(); bc().apply(); } -void ControlBase::OKButton() +void ControlButton::OKButton() { apply(); hide(); @@ -36,14 +35,14 @@ void ControlBase::OKButton() } -void ControlBase::CancelButton() +void ControlButton::CancelButton() { hide(); bc().cancel(); } -void ControlBase::RestoreButton() +void ControlButton::RestoreButton() { update(); bc().undoAll(); diff --git a/src/frontends/controllers/ControlBase.h b/src/frontends/controllers/ControlButton.h similarity index 86% rename from src/frontends/controllers/ControlBase.h rename to src/frontends/controllers/ControlButton.h index 84e4a1bfb1..6c29e602b3 100644 --- a/src/frontends/controllers/ControlBase.h +++ b/src/frontends/controllers/ControlButton.h @@ -7,10 +7,10 @@ * * ====================================================== * - * \file ControlBase.h + * \file ControlButton.h * \author Angus Leeming * - * ControlBase serves only to control the activation of the Ok, Apply, Cancel + * 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 @@ -25,27 +25,27 @@ * management and, ultimately, destruction. */ -#ifndef CONTROLBASE_H -#define CONTROLBASE_H +#ifndef CONTROLBUTTON_H +#define CONTROLBUTTON_H #ifdef __GNUG__ #pragma interface #endif #include "DialogBase.h" // This can go eventually -#include "ButtonController.h" +#include "ButtonControllerBase.h" class ViewBase; /** Abstract base class for Controllers with a ButtonController. */ -class ControlBase : public DialogBase +class ControlButton : public DialogBase { public: // methods /// - ControlBase() {} + ControlButton() {} /// - virtual ~ControlBase() {}; + virtual ~ControlButton() {}; /// These functions are called when the controlling buttons are pressed. /// @@ -78,4 +78,4 @@ protected: #include "ViewBase.h" -#endif // CONTROLBASE_H +#endif // CONTROLBUTTON_H diff --git a/src/frontends/controllers/ControlConnections.h b/src/frontends/controllers/ControlConnections.h index f3401af66c..fc1061200d 100644 --- a/src/frontends/controllers/ControlConnections.h +++ b/src/frontends/controllers/ControlConnections.h @@ -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 index 0000000000..2b6e832b5e --- /dev/null +++ b/src/frontends/controllers/ControlExternal.C @@ -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 + +#include +#include + +#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(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 const ControlExternal::getTemplates() const +{ + vector 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 index 0000000000..b8d48f951c --- /dev/null +++ b/src/frontends/controllers/ControlExternal.h @@ -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 +{ +public: + /// + ControlExternal(LyXView &, Dialogs &); + + /// + void editExternal(); + /// + void viewExternal(); + /// + void updateExternal(); + /// + std::vector 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 diff --git a/src/frontends/controllers/ControlGraphics.C b/src/frontends/controllers/ControlGraphics.C index 41a60e9a81..777a5fb1e9 100644 --- a/src/frontends/controllers/ControlGraphics.C +++ b/src/frontends/controllers/ControlGraphics.C @@ -25,6 +25,13 @@ #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(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 dir1(N_("Clipart"), clipdir); + + // Show the file browser dialog + return browseFile(&lv_, in_name, title, pattern, dir1, + make_pair(string(), string())); +} diff --git a/src/frontends/controllers/ControlGraphics.h b/src/frontends/controllers/ControlGraphics.h index fac2f28f1a..1be2845c33 100644 --- a/src/frontends/controllers/ControlGraphics.h +++ b/src/frontends/controllers/ControlGraphics.h @@ -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. diff --git a/src/frontends/controllers/ControlInclude.C b/src/frontends/controllers/ControlInclude.C index 04416f2f66..0fd1db44f7 100644 --- a/src/frontends/controllers/ControlInclude.C +++ b/src/frontends/controllers/ControlInclude.C @@ -8,17 +8,24 @@ * \author Angus Leeming, a.leeming@.ac.uk */ +#include +#include + #ifdef __GNUG__ #pragma implementation #endif -#include #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 dir1(N_("Documents"), string(lyxrc.document_path)); + + return browseFile(&lv_, in_name, title, pattern, dir1, + make_pair(string(), string())); +} diff --git a/src/frontends/controllers/ControlInclude.h b/src/frontends/controllers/ControlInclude.h index 137db0bb7a..beb257650b 100644 --- a/src/frontends/controllers/ControlInclude.h +++ b/src/frontends/controllers/ControlInclude.h @@ -24,11 +24,20 @@ class ControlInclude : public ControlInset { 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. diff --git a/src/frontends/controllers/ControlInset.h b/src/frontends/controllers/ControlInset.h index d7798e4d48..d91b7d2c68 100644 --- a/src/frontends/controllers/ControlInset.h +++ b/src/frontends/controllers/ControlInset.h @@ -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(); diff --git a/src/frontends/controllers/ControlPrint.C b/src/frontends/controllers/ControlPrint.C index 183b8e0b2b..d33b2f95d9 100644 --- a/src/frontends/controllers/ControlPrint.C +++ b/src/frontends/controllers/ControlPrint.C @@ -12,6 +12,7 @@ */ #include +#include #ifdef __GNUG__ #pragma implementation @@ -24,11 +25,12 @@ #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(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())); +} diff --git a/src/frontends/controllers/ControlPrint.h b/src/frontends/controllers/ControlPrint.h index 51597e9591..a29536e115 100644 --- a/src/frontends/controllers/ControlPrint.h +++ b/src/frontends/controllers/ControlPrint.h @@ -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; diff --git a/src/frontends/controllers/GUI.h b/src/frontends/controllers/GUI.h index c4557e80f3..cc66e2dc58 100644 --- a/src/frontends/controllers/GUI.h +++ b/src/frontends/controllers/GUI.h @@ -154,6 +154,20 @@ public: }; +/** Specialization for External dialog + */ +class ControlExternal; + +template +class GUIExternal : + public GUI { +public: + /// + GUIExternal(LyXView & lv, Dialogs & d) + : GUI(lv, d) {} +}; + + /** Specialization for Graphics dialog */ class ControlGraphics; diff --git a/src/frontends/controllers/Makefile.am b/src/frontends/controllers/Makefile.am index 31fcca7986..69636dd8d5 100644 --- a/src/frontends/controllers/Makefile.am +++ b/src/frontends/controllers/Makefile.am @@ -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 \ diff --git a/src/frontends/controllers/ViewBase.h b/src/frontends/controllers/ViewBase.h index 37a4ca9cef..78a4f0e82c 100644 --- a/src/frontends/controllers/ViewBase.h +++ b/src/frontends/controllers/ViewBase.h @@ -15,13 +15,13 @@ #define VIEWBASE_H #include -#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 ViewBC : public ViewBase { public: /// - ViewBC(ControlBase & c) : ViewBase(c) {} + ViewBC(ControlButton & c) : ViewBase(c) {} protected: /// diff --git a/src/frontends/controllers/biblio.C b/src/frontends/controllers/biblio.C index d878b4d362..0dee0b0850 100644 --- a/src/frontends/controllers/biblio.C +++ b/src/frontends/controllers/biblio.C @@ -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 searchwords = getVectorFromString(expr, " "); + string tmp = expr; + if (!caseSensitive) + tmp = lowercase(tmp); + + vector searchwords = getVectorFromString(tmp, " "); // Loop over all keys from start... for (vector::const_iterator it = start; @@ -166,24 +170,11 @@ simpleSearch(InfoMap const & theMap, bool found = true; // Loop over all search words... - if (caseSensitive) { - for (vector::const_iterator sit= - searchwords.begin(); - sit::const_iterator sit= - searchwords.begin(); - sit::const_iterator sit = searchwords.begin(); + sit != searchwords.end(); ++sit) { + if (data.find(*sit) == string::npos) { + found = false; + break; } } diff --git a/src/frontends/controllers/helper_funcs.C b/src/frontends/controllers/helper_funcs.C index 96b40435b6..209452f570 100644 --- a/src/frontends/controllers/helper_funcs.C +++ b/src/frontends/controllers/helper_funcs.C @@ -21,7 +21,15 @@ #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 const & vec, string const & delim) @@ -50,6 +58,42 @@ vector 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 const & dir1, + pair 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; +} + + diff --git a/src/frontends/controllers/helper_funcs.h b/src/frontends/controllers/helper_funcs.h index 4e6be14a62..afc15e4b1a 100644 --- a/src/frontends/controllers/helper_funcs.h +++ b/src/frontends/controllers/helper_funcs.h @@ -15,6 +15,8 @@ #ifndef HELPERFUNCS_H #define HELPERFUNCS_H +#include // pair + #ifdef __GNUG__ #pragma interface #endif @@ -29,6 +31,20 @@ getStringFromVector(std::vector const & vec, string const & delim=","); std::vector 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 const & dir1, + std::pair const & dir2); + /** Functions to extract vectors of the first and second elems from a vector > */ diff --git a/src/frontends/gnome/ChangeLog b/src/frontends/gnome/ChangeLog index 678690a01d..ca4ff4d86c 100644 --- a/src/frontends/gnome/ChangeLog +++ b/src/frontends/gnome/ChangeLog @@ -1,3 +1,17 @@ +2001-03-30 Angus Leeming + + * GnomeBase.[Ch]: changed ControlBase to ControlButton. + +2001-03-29 Angus Leeming + + * 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 + + * gnomeBC.[Ch]: Changed to use the new GuiBC template. + 2001-03-29 Baruch Even * FormUrl.C (d-tor): diff --git a/src/frontends/gnome/GnomeBase.C b/src/frontends/gnome/GnomeBase.C index de37831333..36c93f9228 100644 --- a/src/frontends/gnome/GnomeBase.C +++ b/src/frontends/gnome/GnomeBase.C @@ -19,7 +19,7 @@ #include "support/filetools.h" #include -GnomeBase::GnomeBase(ControlBase & c, string const & glade_file, string const & name) +GnomeBase::GnomeBase(ControlButton & c, string const & glade_file, string const & name) : ViewBC(c), file_(glade_file), widget_name_(name), xml_(0) {} diff --git a/src/frontends/gnome/GnomeBase.h b/src/frontends/gnome/GnomeBase.h index d982e8b505..5f8cbb9b36 100644 --- a/src/frontends/gnome/GnomeBase.h +++ b/src/frontends/gnome/GnomeBase.h @@ -38,7 +38,7 @@ class Dialog; class GnomeBase : public ViewBC, 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(); diff --git a/src/frontends/gnome/gnomeBC.C b/src/frontends/gnome/gnomeBC.C index 76b88e9384..d47decabcb 100644 --- a/src/frontends/gnome/gnomeBC.C +++ b/src/frontends/gnome/gnomeBC.C @@ -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(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); } diff --git a/src/frontends/gnome/gnomeBC.h b/src/frontends/gnome/gnomeBC.h index 8f0524e440..15b1157b03 100644 --- a/src/frontends/gnome/gnomeBC.h +++ b/src/frontends/gnome/gnomeBC.h @@ -14,68 +14,35 @@ #ifndef GNOMEBC_H #define GNOMEBC_H -#include "ButtonController.h" #include #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 { 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 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 diff --git a/src/frontends/kde/ChangeLog b/src/frontends/kde/ChangeLog index befcf445c2..0f76827b14 100644 --- a/src/frontends/kde/ChangeLog +++ b/src/frontends/kde/ChangeLog @@ -1,3 +1,7 @@ +2001-03-29 Baruch Even + + * kdeBC.[Ch]: Changed to use the new GuiBC template. + 2001-03-15 Lars Gullik Bjønnes * several files: remove CXX_WORKING_NAMESPACES diff --git a/src/frontends/kde/kdeBC.C b/src/frontends/kde/kdeBC.C index 87ec207db5..84647ae110 100644 --- a/src/frontends/kde/kdeBC.C +++ b/src/frontends/kde/kdeBC.C @@ -8,48 +8,23 @@ #include kdeBC::kdeBC(string const & cancel, string const & close) - : ButtonControllerBase(cancel, close), - okay_(0), apply_(0), cancel_(0), undo_all_(0), read_only_() + : GuiBC(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::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()); } diff --git a/src/frontends/kde/kdeBC.h b/src/frontends/kde/kdeBC.h index 03d1631b70..2833dd7738 100644 --- a/src/frontends/kde/kdeBC.h +++ b/src/frontends/kde/kdeBC.h @@ -15,63 +15,33 @@ #ifndef KDEBC_H #define KDEBC_H -#include "ButtonController.h" #include #ifdef __GNUG__ #pragma interface #endif +#include "ButtonControllerBase.h" +#include "ButtonController.h" + class QWidget; class QPushButton; -class kdeBC : public ButtonControllerBase +class kdeBC : public GuiBC { 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 read_only_; + /// Set the label on the button + void setButtonLabel(QPushButton * btn, string const & label); }; #endif // KDEBC_H diff --git a/src/frontends/qt2/ChangeLog b/src/frontends/qt2/ChangeLog index 7d75cf993e..5adbb8fd01 100644 --- a/src/frontends/qt2/ChangeLog +++ b/src/frontends/qt2/ChangeLog @@ -1,3 +1,7 @@ +2001-03-30 Angus Leeming + + * Qt2Base.[Ch]: changed ControlBase to ControlButton. + 2001-03-19 Edwin Leuven * qt2 compiles again: diff --git a/src/frontends/qt2/Qt2Base.C b/src/frontends/qt2/Qt2Base.C index 9b53697936..b9ef03c270 100644 --- a/src/frontends/qt2/Qt2Base.C +++ b/src/frontends/qt2/Qt2Base.C @@ -28,7 +28,7 @@ #include -Qt2Base::Qt2Base(ControlBase & c, string const & t) +Qt2Base::Qt2Base(ControlButton & c, string const & t) : ViewBC(c), title_(t) {} diff --git a/src/frontends/qt2/Qt2Base.h b/src/frontends/qt2/Qt2Base.h index e3087690b9..5cbf618dc2 100644 --- a/src/frontends/qt2/Qt2Base.h +++ b/src/frontends/qt2/Qt2Base.h @@ -38,7 +38,7 @@ class Qt2Base : public QObject, public ViewBC 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 -Qt2DB::Qt2DB(ControlBase & c, string const & t) +Qt2DB::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 -Qt2CB::Qt2CB(ControlBase & c, string const & t) +Qt2CB::Qt2CB(ControlButton & c, string const & t) : Base(c, t) {} diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index c108e5c24c..aa687420d3 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -1,3 +1,31 @@ +2001-03-30 Angus Leeming + + * 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 + + * 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 * FormMinipage.C: removed widthp_ and all it's functions and changed @@ -5,9 +33,9 @@ 2001-03-28 Angus Leeming - * FormGraphics.C: + * FormGraphics.[Ch]: * forms/form_graphics.fd: - * FormIndex.C: + * FormIndex.[Ch]: * forms/form_index.fd: implemented controller-view split. * Dialogs.C: associated changes. diff --git a/src/frontends/xforms/Dialogs.C b/src/frontends/xforms/Dialogs.C index d307f1c84e..2783a4cc2a 100644 --- a/src/frontends/xforms/Dialogs.C +++ b/src/frontends/xforms/Dialogs.C @@ -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(*lv, *this)); add(new GUICredits(*lv, *this)); add(new GUIError(*lv, *this)); + add(new GUIExternal(*lv, *this)); add(new GUIGraphics(*lv, *this)); add(new GUIInclude(*lv, *this)); add(new GUIIndex(*lv, *this)); @@ -121,7 +124,6 @@ Dialogs::Dialogs(LyXView * lv) add(new GUIVCLog(*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)); diff --git a/src/frontends/xforms/FormBase.C b/src/frontends/xforms/FormBase.C index d1cd266962..8ba2319ff6 100644 --- a/src/frontends/xforms/FormBase.C +++ b/src/frontends/xforms/FormBase.C @@ -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(c), minw_(0), minh_(0), title_(t) {} diff --git a/src/frontends/xforms/FormBase.h b/src/frontends/xforms/FormBase.h index fe7761e2fe..e2911c42ff 100644 --- a/src/frontends/xforms/FormBase.h +++ b/src/frontends/xforms/FormBase.h @@ -33,7 +33,7 @@ class FormBase : public ViewBC { 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 -FormDB::FormDB(ControlBase & c, string const & t) +FormDB::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 -FormCB::FormCB(ControlBase & c, string const & t) +FormCB::FormCB(ControlButton & c, string const & t) : Base(c, t) {} diff --git a/src/frontends/xforms/FormBrowser.C b/src/frontends/xforms/FormBrowser.C index 2b2aae8f81..64d8610ff5 100644 --- a/src/frontends/xforms/FormBrowser.C +++ b/src/frontends/xforms/FormBrowser.C @@ -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(c, t) {} diff --git a/src/frontends/xforms/FormBrowser.h b/src/frontends/xforms/FormBrowser.h index 6e601ef2b8..ed54aec323 100644 --- a/src/frontends/xforms/FormBrowser.h +++ b/src/frontends/xforms/FormBrowser.h @@ -25,7 +25,7 @@ struct FD_form_browser; class FormBrowser : public FormDB { public: /// - FormBrowser(ControlBase &, string const &); + FormBrowser(ControlButton &, string const &); private: /// Build the dialog. diff --git a/src/frontends/xforms/FormCitation.C b/src/frontends/xforms/FormCitation.C index f698d53a53..fe8fa9eacf 100644 --- a/src/frontends/xforms/FormCitation.C +++ b/src/frontends/xforms/FormCitation.C @@ -1,4 +1,3 @@ -// -*- C++ -*- /* This file is part of * ====================================================== * @@ -8,7 +7,8 @@ * * ====================================================== * - * \author Angus Leeming + * \file FormCitation.C + * \author Angus Leeming, a.leeming@ic.ac.uk */ #include @@ -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::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) { diff --git a/src/frontends/xforms/FormExternal.C b/src/frontends/xforms/FormExternal.C index 95748aa736..596ddaa1a6 100644 --- a/src/frontends/xforms/FormExternal.C +++ b/src/frontends/xforms/FormExternal.C @@ -1,202 +1,120 @@ -/** - * \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 -#include - -#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 > 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(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(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(ob->form->u_vdata); - - form->apply(); - form->inset_->editExternal(); -} - - -void FormExternal::viewCB(FL_OBJECT * ob, long) -{ - FormExternal * form = static_cast(ob->form->u_vdata); - - form->apply(); - form->inset_->viewExternal(); -} - - -void FormExternal::updateCB(FL_OBJECT * ob, long) -{ - FormExternal * form = static_cast(ob->form->u_vdata); - - form->apply(); - form->inset_->updateExternal(); + bool const enabled = (!controller().params().templ.automaticProduction); + setEnabled(dialog_->button_update, enabled); } diff --git a/src/frontends/xforms/FormExternal.h b/src/frontends/xforms/FormExternal.h index 16e97d66ae..34de5021fb 100644 --- a/src/frontends/xforms/FormExternal.h +++ b/src/frontends/xforms/FormExternal.h @@ -1,113 +1,55 @@ -/** - * \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 - #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 > { 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 dialog_; - - /// The ButtonController - ButtonController bc_; }; - -inline -xformsBC & FormExternal::bc() -{ - return bc_; -} - #endif // FORMEXTERNAL_H diff --git a/src/frontends/xforms/FormGraphics.C b/src/frontends/xforms/FormGraphics.C index c20fdd3623..36b1ab081f 100644 --- a/src/frontends/xforms/FormGraphics.C +++ b/src/frontends/xforms/FormGraphics.C @@ -22,17 +22,13 @@ #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 > 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 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); - } -} diff --git a/src/frontends/xforms/FormGraphics.h b/src/frontends/xforms/FormGraphics.h index af7378a4d7..a43e48996d 100644 --- a/src/frontends/xforms/FormGraphics.h +++ b/src/frontends/xforms/FormGraphics.h @@ -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(); diff --git a/src/frontends/xforms/FormInclude.C b/src/frontends/xforms/FormInclude.C index 66efb6d087..78f80f2738 100644 --- a/src/frontends/xforms/FormInclude.C +++ b/src/frontends/xforms/FormInclude.C @@ -8,31 +8,20 @@ * \author Angus Leeming, a.leeming@.ac.uk */ +#include #include -#include #ifdef __GNUG__ #pragma implementation #endif -#include #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 > 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; -} diff --git a/src/frontends/xforms/FormInclude.h b/src/frontends/xforms/FormInclude.h index 8904d86258..65e4077a1f 100644 --- a/src/frontends/xforms/FormInclude.h +++ b/src/frontends/xforms/FormInclude.h @@ -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(); }; diff --git a/src/frontends/xforms/FormPreferences.C b/src/frontends/xforms/FormPreferences.C index 31f398fd0d..447a5a7142 100644 --- a/src/frontends/xforms/FormPreferences.C +++ b/src/frontends/xforms/FormPreferences.C @@ -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" diff --git a/src/frontends/xforms/FormPrint.C b/src/frontends/xforms/FormPrint.C index d25cf9d5a1..fd5f7c776e 100644 --- a/src/frontends/xforms/FormPrint.C +++ b/src/frontends/xforms/FormPrint.C @@ -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); - } -} diff --git a/src/frontends/xforms/FormPrint.h b/src/frontends/xforms/FormPrint.h index b101eab159..b76783af68 100644 --- a/src/frontends/xforms/FormPrint.h +++ b/src/frontends/xforms/FormPrint.h @@ -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(); diff --git a/src/frontends/xforms/form_citation.C b/src/frontends/xforms/form_citation.C index d41283bc9b..b28173ebb7 100644 --- a/src/frontends/xforms/form_citation.C +++ b/src/frontends/xforms/form_citation.C @@ -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))); diff --git a/src/frontends/xforms/form_citation.h b/src/frontends/xforms/form_citation.h index 931fa26dc5..c168b10351 100644 --- a/src/frontends/xforms/form_citation.h +++ b/src/frontends/xforms/form_citation.h @@ -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; diff --git a/src/frontends/xforms/form_external.C b/src/frontends/xforms/form_external.C index f5d4aed97e..62b949b4d1 100644 --- a/src/frontends/xforms/form_external.C +++ b/src/frontends/xforms/form_external.C @@ -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); diff --git a/src/frontends/xforms/form_external.h b/src/frontends/xforms/form_external.h index 2802df3a59..8cddeb634d 100644 --- a/src/frontends/xforms/form_external.h +++ b/src/frontends/xforms/form_external.h @@ -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); diff --git a/src/frontends/xforms/forms/form_citation.fd b/src/frontends/xforms/forms/form_citation.fd index a373942bf0..9e4100cdf9 100644 --- a/src/frontends/xforms/forms/form_citation.fd +++ b/src/frontends/xforms/forms/form_citation.fd @@ -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 diff --git a/src/frontends/xforms/forms/form_external.fd b/src/frontends/xforms/forms/form_external.fd index 5cea763567..228758e0fb 100644 --- a/src/frontends/xforms/forms/form_external.fd +++ b/src/frontends/xforms/forms/form_external.fd @@ -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 -------------------- diff --git a/src/frontends/xforms/xformsBC.C b/src/frontends/xforms/xformsBC.C index c904cd167a..422aa17103 100644 --- a/src/frontends/xforms/xformsBC.C +++ b/src/frontends/xforms/xformsBC.C @@ -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 - * \author Angus Leeming + * \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 @@ -16,50 +22,24 @@ #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(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::iterator iter = read_only_.begin(); - iter != read_only_.end(); ++iter) { - setEnabled(*iter, enable); - } - } + fl_set_object_label(obj, label.c_str()); } diff --git a/src/frontends/xforms/xformsBC.h b/src/frontends/xforms/xformsBC.h index 614b3e9fed..d000484bb4 100644 --- a/src/frontends/xforms/xformsBC.h +++ b/src/frontends/xforms/xformsBC.h @@ -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 - * Non-xforms-specific code stripped-out and placed in a base class by - * Angus Leeming + * \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 @@ -26,61 +23,25 @@ #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 { 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 read_only_; + /// Set the label on the button + void setButtonLabel(FL_OBJECT *, string const & label); }; #endif // XFORMSBC_H diff --git a/src/frontends/xforms/xforms_helpers.C b/src/frontends/xforms/xforms_helpers.C index f8601b7517..87459b34f7 100644 --- a/src/frontends/xforms/xforms_helpers.C +++ b/src/frontends/xforms/xforms_helpers.C @@ -14,10 +14,8 @@ #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 const & dir1, - pair 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(). diff --git a/src/frontends/xforms/xforms_helpers.h b/src/frontends/xforms/xforms_helpers.h index d7d2bd2240..a8c1731270 100644 --- a/src/frontends/xforms/xforms_helpers.h +++ b/src/frontends/xforms/xforms_helpers.h @@ -5,9 +5,6 @@ #pragma interface #endif -#include // pair -//#include -#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 const & dir1, - std::pair const & dir2); - /// struct holding xform-specific colors struct XformsColor : public NamedColor { int colorID; diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index 4b7f9b4009..de982e2042 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,9 @@ +2001-03-29 Angus Leeming + + * insetexternal.[Ch]: renamed InsetExternal::InsetExternalParams as + InsetExternal::Params. + Added operator==() and operator!=() for the Params struct. + 2001-03-29 Juergen Vigna * lyxinset.h: changed parameter of getMaxWidth from Painter & to @@ -8,7 +14,7 @@ 2001-03-28 Angus Leeming - * 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 diff --git a/src/insets/insetexternal.C b/src/insets/insetexternal.C index 92fcf4e999..513eeeb65a 100644 --- a/src/insets/insetexternal.C +++ b/src/insets/insetexternal.C @@ -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); +} + diff --git a/src/insets/insetexternal.h b/src/insets/insetexternal.h index fdc870e6aa..486c3244af 100644 --- a/src/insets/insetexternal.h +++ b/src/insets/insetexternal.h @@ -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 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 -- 2.39.2