* 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
This commit is contained in:
Angus Leeming 2001-03-30 09:51:46 +00:00
parent ba1c81aad3
commit 58d99b4a97
62 changed files with 1061 additions and 1002 deletions

View File

@ -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 <list>
#include "ButtonPolicies.h"
#include "LString.h"
#include "gettext.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
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);
///
void readWrite();
///
void valid(bool = true);
///
void invalid();
GuiBC(string const & cancel, string const & close);
protected:
///
void setOK(Button * obj) { okay_ = obj; }
///
void setApply(Button * obj) { apply_ = obj; }
///
void setCancel(Button * obj) { cancel_ = obj; }
///
string cancel_label;
void setUndoAll(Button * obj) { undo_all_ = obj; }
///
string close_label;
void addReadOnly(Widget * obj) { read_only_.push_back(obj); }
///
void eraseReadOnly() { read_only_.clear(); }
/// 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
{

View File

@ -8,7 +8,7 @@
*
* ======================================================
*
* \file ButtonController.C
* \file ButtonControllerBase.C
* \author Allan Rae
*/
@ -17,13 +17,13 @@
#endif
#include <config.h>
#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)
{}

View File

@ -0,0 +1,81 @@
/* This file is part of
* ======================================================
*
* LyX, The Document Processor
*
* Copyright 2000-2001 The LyX Team.
*
* ======================================================
*
* \file ButtonControllerBase.h
* \author Allan Rae, rae@lyx.org
*/
#ifndef BUTTONCONTROLLERBASE_H
#define BUTTONCONTROLLERBASE_H
#ifdef __GNUG__
#pragma interface
#endif
#include "ButtonPolicies.h"
#include "LString.h"
/** Abstract base class for a ButtonController
* Controls the activation of the OK, Apply and Cancel buttons.
* Actually supports 4 buttons in all and it's up to the user to decide on
* the activation policy and which buttons correspond to which output of the
* state machine.
* Author: Allan Rae <rae@lyx.org>.
* This abstract base class stripped of xforms-specific code by
* Angus Leeming <a.leeming@ic.ac.uk>
*/
class ButtonControllerBase : public boost::noncopyable
{
public:
/** Constructor.
The cancel/close label entries are _not_ managed within the class
thereby allowing you to reassign at will and to use static labels.
It also means if you really don't want to have the Cancel button
label be different when there is nothing changed in the dialog then
you can just assign "Cancel" to both labels. Or even reuse this
class for something completely different.
*/
ButtonControllerBase(string const & cancel, string const & close);
///
virtual ~ButtonControllerBase() {}
///
virtual ButtonPolicy & bp() = 0;
///
virtual void input(ButtonPolicy::SMInput);
///
void ok();
///
void apply();
///
void cancel();
///
void undoAll();
///
void hide();
///
virtual void refresh() = 0;
/// Passthrough function -- returns its input value
bool readOnly(bool = true);
///
void readWrite();
///
void valid(bool = true);
///
void invalid();
protected:
///
string cancel_label_;
///
string close_label_;
};
#endif // BUTTONCONTROLLERBASE_H

View File

@ -1,3 +1,44 @@
2001-03-30 Angus Leeming <a.leeming@ic.ac.uk>
* ButtonController.[Ch]: renamed as ButtonControllerBase.[Ch]
* BCTemplates.h: renamed as ButtonController.h
* ControlBase.[Ch]: renamed as ControlButton.[Ch]. Class named to match.
* ViewBase.h:
* ControlConnections.h: associated change in #include and class names.
* ControlExternal.[Ch]: new files; a controller for the External
Material popup.
* GUI.h:
* Makefile.am: associated changes with all of the above.
* ControlGraphics.[Ch]:
* ControlInclude.[Ch]:
* ControlPrint.[Ch]:
(lv): removed.
(Browse): new method. Returns the results of a FileDialog browse.
* helper_funcs.[Ch] (browseFile): moved from xforms_helpers.[Ch].
(getVectorFromString): fixed bug.
* biblio.C (simpleSearch): cleaned up.
2001-03-29 Angus Leeming <a.leeming@ic.ac.uk>
* A slight reworking of Baruch Even's ButtonController patch.
* BCTemplates.h: new file; all the templates for the ButtonController.
Including Baruch's new GuiBC class, with setCancelCloseButton() changed
to the more generic setButtonLabel().
* ButtonController.[Ch]: renamed cancel_label and close_label as
cancel_label_ and close_label_.
* Makefile.am: added BCTemplates.h
2001-03-29 Juergen Vigna <jug@sad.it>
* ControlMinipage.C: removed widthp_ and all it's functions and changed

View File

@ -8,27 +8,26 @@
*
* ======================================================
*
* \file ControlBase.C
* \file ControlButton.C
* \author Angus Leeming <a.leeming@ic.ac.uk>
*/
#include <config.h>
#ifdef __GNUG__
#pragma implementation
#endif
#include <config.h>
#include "ControlButton.h"
#include "ButtonController.h"
#include "ControlBase.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();

View File

@ -7,10 +7,10 @@
*
* ======================================================
*
* \file ControlBase.h
* \file ControlButton.h
* \author Angus Leeming <a.leeming@ic.ac.uk>
*
* 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

View File

@ -34,7 +34,7 @@
#pragma interface
#endif
#include "ControlBase.h"
#include "ControlButton.h"
class Dialogs;
class LyXView;
@ -43,7 +43,7 @@ class LyXView;
kernel. It is meant to be used solely as the parent class to
ControlConnectBI and ControlConnectBD.
*/
class ControlConnectBase : public ControlBase
class ControlConnectBase : public ControlButton
{
public:
///

View File

@ -0,0 +1,175 @@
/* This file is part of
* ======================================================
*
* LyX, The Document Processor
*
* Copyright 2001 The LyX Team.
*
* ======================================================
*
* \file ControlExternal.C
* \author Asger Alstrup
* \author John Levon
* \author Angus Leeming, a.leeming@ic.ac.uk
*/
#include <config.h>
#include <utility>
#include <vector>
#ifdef __GNUG__
#pragma implementation
#endif
#include "ControlExternal.h"
#include "buffer.h"
#include "Dialogs.h"
#include "Liason.h"
#include "LyXView.h"
#include "support/filetools.h"
#include "frontends/FileDialog.h"
#include "lyx_gui_misc.h" // WriteAlert
using std::make_pair;
using std::vector;
ControlExternal::ControlExternal(LyXView & lv, Dialogs & d)
: ControlInset<InsetExternal, InsetExternal::Params>(lv, d)
{
d_.showExternal.connect(SigC::slot(this, &ControlExternal::showInset));
}
InsetExternal::Params const ControlExternal::getParams(string const &)
{
return InsetExternal::Params();
}
InsetExternal::Params const
ControlExternal::getParams(InsetExternal const & inset)
{
return inset.params();
}
void ControlExternal::editExternal()
{
inset()->setFromParams(params());
inset()->editExternal();
}
void ControlExternal::viewExternal()
{
inset()->setFromParams(params());
inset()->viewExternal();
}
void ControlExternal::updateExternal()
{
inset()->setFromParams(params());
inset()->updateExternal();
}
vector<string> const ControlExternal::getTemplates() const
{
vector<string> result;
ExternalTemplateManager::Templates::const_iterator i1, i2;
i1 = ExternalTemplateManager::get().getTemplates().begin();
i2 = ExternalTemplateManager::get().getTemplates().end();
for (; i1 != i2; ++i1) {
result.push_back(i1->second.lyxName);
}
return result;
}
int ControlExternal::getTemplateNumber(string const & name) const
{
int i = 0;
ExternalTemplateManager::Templates::const_iterator i1, i2;
i1 = ExternalTemplateManager::get().getTemplates().begin();
i2 = ExternalTemplateManager::get().getTemplates().end();
for (; i1 != i2; ++i1) {
if (i1->second.lyxName == name)
return i;
++i;
}
// we can get here if a LyX document has a template not installed
// on this machine.
return -1;
}
ExternalTemplate ControlExternal::getTemplate(int i) const
{
ExternalTemplateManager::Templates::const_iterator i1;
i1 = ExternalTemplateManager::get().getTemplates().begin();
for (int n = 1; n < i; ++n)
++i1;
return (*i1).second;
}
string const ControlExternal::Browse(string const & input) const
{
string buf = MakeAbsPath(lv_.buffer()->fileName());
string buf2 = OnlyPath(buf);
if (!input.empty()) {
buf = MakeAbsPath(input, buf2);
buf = OnlyPath(buf);
} else {
buf = OnlyPath(lv_.buffer()->fileName());
}
FileDialog fileDlg(&lv_,
_("Select external file"),
LFUN_SELECT_FILE_SYNC,
make_pair(string(_("Document")), string(buf)));
/// Determine the template file extension
ExternalTemplate const & et = params().templ;
string regexp = et.fileRegExp;
if (regexp.empty())
regexp = "*";
// FIXME: a temporary hack until the FileDialog interface is updated
regexp += "|";
static int once = 0;
string current_path;
while (1) {
string const path = (once) ? current_path : buf;
FileDialog::Result result = fileDlg.Select(path, regexp, input);
if (result.second.empty())
return string();
string p = result.second;
buf = MakeRelPath(input, buf2);
current_path = OnlyPath(input);
once = 1;
if (contains(input, "#") ||
contains(input, "~") ||
contains(input, "$") ||
contains(input, "%")) {
WriteAlert(_("Filename can't contain any "
"of these characters:"),
// xgettext:no-c-format
_("'#', '~', '$' or '%'."));
} else
break;
}
return buf;
}

View File

@ -0,0 +1,61 @@
/* This file is part of
* ======================================================
*
* LyX, The Document Processor
*
* Copyright 2001 The LyX Team.
*
* ======================================================
*
* \file ControlExternal.h
* \author Asger Alstrup
* \author John Levon
* \author Angus Leeming, a.leeming@ic.ac.uk
*/
#ifndef CONTROLEXTERNAL_H
#define CONTROLEXTERNAL_H
#ifdef __GNUG__
#pragma interface
#endif
#include "ControlInset.h"
#include "insets/insetexternal.h"
/** A controller for External dialogs.
*/
class ControlExternal
: public ControlInset<InsetExternal, InsetExternal::Params>
{
public:
///
ControlExternal(LyXView &, Dialogs &);
///
void editExternal();
///
void viewExternal();
///
void updateExternal();
///
std::vector<string> const getTemplates() const;
///
int getTemplateNumber(string const &) const;
///
ExternalTemplate getTemplate(int) const;
///
string const Browse(string const &) const;
private:
/// not needed.
virtual void applyParamsToInset() {}
///
virtual void applyParamsNoInset() {}
/// get the parameters from the string passed to createInset.
virtual InsetExternal::Params const getParams(string const &);
/// get the parameters from the inset passed to showInset.
virtual InsetExternal::Params const getParams(InsetExternal const &);
};
#endif // CONTROLEXTERNAL_H

View File

@ -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<InsetGraphics, InsetGraphicsParams>(lv, d)
{
@ -32,12 +39,6 @@ ControlGraphics::ControlGraphics(LyXView & lv, Dialogs & d)
}
LyXView * ControlGraphics::lv() const
{
return &lv_;
}
InsetGraphicsParams const ControlGraphics::getParams(string const &)
{
return InsetGraphicsParams();
@ -64,3 +65,27 @@ void ControlGraphics::applyParamsToInset()
void ControlGraphics::applyParamsNoInset()
{}
// We need these in the file browser.
extern string system_lyxdir;
extern string user_lyxdir;
string const ControlGraphics::Browse(string const & in_name)
{
string const title = N_("Graphics");
// FIXME: currently we need the second '|' to prevent mis-interpretation
string const pattern = "*.(ps|png)|";
// Does user clipart directory exist?
string clipdir = AddName (user_lyxdir, "clipart");
FileInfo fileInfo(clipdir);
if (!(fileInfo.isOK() && fileInfo.isDir()))
// No - bail out to system clipart directory
clipdir = AddName (system_lyxdir, "clipart");
pair<string, string> dir1(N_("Clipart"), clipdir);
// Show the file browser dialog
return browseFile(&lv_, in_name, title, pattern, dir1,
make_pair(string(), string()));
}

View File

@ -32,8 +32,8 @@ public:
///
ControlGraphics(LyXView &, Dialogs &);
/// The file dialog popup requires a LyXView * ???
LyXView * lv() const;
/// Browse for a file
string const Browse(string const &);
private:
/// Dispatch the changed parameters to the kernel.

View File

@ -8,17 +8,24 @@
* \author Angus Leeming, a.leeming@.ac.uk
*/
#include <config.h>
#include <utility>
#ifdef __GNUG__
#pragma implementation
#endif
#include <config.h>
#include "ControlInclude.h"
#include "buffer.h"
#include "Dialogs.h"
#include "lyxfunc.h"
#include "LyXView.h"
#include "helper_funcs.h"
#include "lyxrc.h"
using std::pair;
using std::make_pair;
using SigC::slot;
ControlInclude::ControlInclude(LyXView & lv, Dialogs & d)
@ -27,14 +34,37 @@ ControlInclude::ControlInclude(LyXView & lv, Dialogs & d)
d_.showInclude.connect(slot(this, &ControlInclude::showInset));
}
LyXView * ControlInclude::lv() const
{
return &lv_;
}
void ControlInclude::applyParamsToInset()
{
inset()->set(params());
lv_.view()->updateInset(inset(), true);
}
string const ControlInclude::Browse(string const & in_name, Type in_type)
{
string const title = N_("Select document to include");
string pattern;
// input TeX, verbatim, or LyX file ?
switch (in_type) {
case INPUT:
pattern = _("*.tex| LaTeX Documents (*.tex)");
break;
case VERBATIM:
pattern = _("*| All files ");
break;
case INCLUDE:
pattern = _("*.lyx| LyX Documents (*.lyx)");
break;
}
pair<string, string> dir1(N_("Documents"), string(lyxrc.document_path));
return browseFile(&lv_, in_name, title, pattern, dir1,
make_pair(string(), string()));
}

View File

@ -24,11 +24,20 @@ class ControlInclude
: public ControlInset<InsetInclude, InsetInclude::Params>
{
public:
///
enum Type {
///
INPUT,
///
VERBATIM,
///
INCLUDE
};
///
ControlInclude(LyXView &, Dialogs &);
/// The file dialog popup requires a LyXView * ???
LyXView * lv() const;
/// Browse for a file
string const Browse(string const &, Type);
private:
/// Dispatch the changed parameters to the kernel.

View File

@ -65,7 +65,7 @@ private:
/// Instantiation of ControlBase virtual methods.
/// Instantiation of ControlButton virtual methods.
/// Get changed parameters and Dispatch them to the kernel.
virtual void apply();

View File

@ -12,6 +12,7 @@
*/
#include <config.h>
#include <utility>
#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<ControlConnectBD>(lv, d)
@ -52,12 +54,6 @@ void ControlPrint::apply()
}
LyXView * ControlPrint::lv() const
{
return &lv_;
}
PrinterParams & ControlPrint::params() const
{
Assert(params_);
@ -83,3 +79,13 @@ void ControlPrint::clearParams()
}
string const ControlPrint::Browse(string const & in_name)
{
string const title = N_("Print to file");
string const pattern = "*.ps";
// Show the file browser dialog
return browseFile(&lv_, in_name, title, pattern,
make_pair(string(), string()),
make_pair(string(), string()));
}

View File

@ -29,8 +29,8 @@ public:
///
ControlPrint(LyXView &, Dialogs &);
/// The file dialog popup requires a LyXView * ???
LyXView * lv() const;
/// Browse for a file
string const Browse(string const &);
///
PrinterParams & params() const;

View File

@ -154,6 +154,20 @@ public:
};
/** Specialization for External dialog
*/
class ControlExternal;
template <class GUIview, class GUIbc>
class GUIExternal :
public GUI<ControlExternal, GUIview, OkCancelReadOnlyPolicy, GUIbc> {
public:
///
GUIExternal(LyXView & lv, Dialogs & d)
: GUI<ControlExternal, GUIview, OkCancelReadOnlyPolicy, GUIbc>(lv, d) {}
};
/** Specialization for Graphics dialog
*/
class ControlGraphics;

View File

@ -14,16 +14,17 @@ libcontrollers_la_SOURCES=\
biblio.h \
character.C \
character.h \
ButtonController.C \
ButtonController.h \
ButtonControllerBase.C \
ButtonControllerBase.h \
ButtonPolicies.C \
ButtonPolicies.h \
ControlBase.C \
ControlBase.h \
ControlBibitem.C \
ControlBibitem.h \
ControlBibtex.C \
ControlBibtex.h \
ControlButton.C \
ControlButton.h \
ControlCharacter.C \
ControlCharacter.h \
ControlCitation.C \
@ -39,6 +40,8 @@ libcontrollers_la_SOURCES=\
ControlDialogs.h \
ControlError.h \
ControlError.C \
ControlExternal.h \
ControlExternal.C \
ControlGraphics.h \
ControlGraphics.C \
ControlInclude.C \

View File

@ -15,13 +15,13 @@
#define VIEWBASE_H
#include <boost/utility.hpp>
#include "ControlBase.h"
#include "ControlButton.h"
#include "ControlSplash.h"
class ViewBase {
public:
///
ViewBase(ControlBase & c) : controller_(c) {}
ViewBase(ControlButton & c) : controller_(c) {}
///
virtual ~ViewBase() {}
@ -50,7 +50,7 @@ public:
protected:
/// The view is, after all, controlled!
ControlBase & controller_;
ControlButton & controller_;
};
@ -84,7 +84,7 @@ template <class GUIbc>
class ViewBC : public ViewBase {
public:
///
ViewBC(ControlBase & c) : ViewBase(c) {}
ViewBC(ControlButton & c) : ViewBase(c) {}
protected:
///

View File

@ -129,7 +129,7 @@ searchKeys(InfoMap const & theMap,
string search_expr = frontStrip(strip(expr));
if (search_expr.empty())
return start;
return keys.end();
if (type == SIMPLE)
return simpleSearch(theMap, keys, search_expr, start, dir,
@ -147,7 +147,11 @@ simpleSearch(InfoMap const & theMap,
Direction dir,
bool caseSensitive)
{
vector<string> searchwords = getVectorFromString(expr, " ");
string tmp = expr;
if (!caseSensitive)
tmp = lowercase(tmp);
vector<string> searchwords = getVectorFromString(tmp, " ");
// Loop over all keys from start...
for (vector<string>::const_iterator it = start;
@ -166,24 +170,11 @@ simpleSearch(InfoMap const & theMap,
bool found = true;
// Loop over all search words...
if (caseSensitive) {
for (vector<string>::const_iterator sit=
searchwords.begin();
sit<searchwords.end(); ++sit) {
if (data.find(*sit) == string::npos) {
found = false;
break;
}
}
} else {
for (vector<string>::const_iterator sit=
searchwords.begin();
sit<searchwords.end(); ++sit) {
if (data.find(lowercase(*sit)) ==
string::npos) {
found = false;
break;
}
for (vector<string>::const_iterator sit = searchwords.begin();
sit != searchwords.end(); ++sit) {
if (data.find(*sit) == string::npos) {
found = false;
break;
}
}

View File

@ -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<string> const & vec,
string const & delim)
@ -50,6 +58,42 @@ vector<string> const getVectorFromString(string const & str,
keys = keys.substr(start);
}
if (vec.empty()) // unable to separate
vec.push_back(str);
return vec;
}
string const browseFile(LyXView * lv, string const & filename,
string const & title,
string const & pattern,
pair<string,string> const & dir1,
pair<string,string> const & dir2)
{
string lastPath = ".";
if (!filename.empty()) lastPath = OnlyPath(filename);
FileDialog fileDlg(lv, title, LFUN_SELECT_FILE_SYNC, dir1, dir2);
FileDialog::Result result;
while (1) {
result = fileDlg.Select(lastPath, pattern, OnlyFilename(filename));
if (result.second.empty())
return result.second;
lastPath = OnlyPath(result.second);
if (result.second.find_first_of("#~$% ") == string::npos)
break;
WriteAlert(_("Filename can't contain any "
"of these characters:"),
_("space, '#', '~', '$' or '%'."));
}
return result.second;
}

View File

@ -15,6 +15,8 @@
#ifndef HELPERFUNCS_H
#define HELPERFUNCS_H
#include <utility> // pair
#ifdef __GNUG__
#pragma interface
#endif
@ -29,6 +31,20 @@ getStringFromVector(std::vector<string> const & vec, string const & delim=",");
std::vector<string> const
getVectorFromString(string const & str, string const & delim=",");
class LyXView;
/** Launch a file dialog and return the chosen file.
filename: a suggested filename.
title: the title of the dialog.
pattern: *.ps etc.
dir1 = (name, dir), dir2 = (name, dir): extra buttons on the dialog.
*/
string const browseFile(LyXView *lv, string const & filename,
string const & title,
string const & pattern,
std::pair<string,string> const & dir1,
std::pair<string,string> const & dir2);
/** Functions to extract vectors of the first and second elems from a
vector<pair<A,B> >
*/

View File

@ -1,3 +1,17 @@
2001-03-30 Angus Leeming <a.leeming@ic.ac.uk>
* GnomeBase.[Ch]: changed ControlBase to ControlButton.
2001-03-29 Angus Leeming <a.leeming@ic.ac.uk>
* gnomeBC.[Ch]: Patched in a slight reworking of Baruch Even's patch.
Code moved into the generic template base class. Replaced
setCancelCloseButton() with setButtonLabel().
2001-03-29 Baruch Even <baruch@lyx.org>
* gnomeBC.[Ch]: Changed to use the new GuiBC template.
2001-03-29 Baruch Even <baruch@lyx.org>
* FormUrl.C (d-tor):

View File

@ -19,7 +19,7 @@
#include "support/filetools.h"
#include <glib.h>
GnomeBase::GnomeBase(ControlBase & c, string const & glade_file, string const & name)
GnomeBase::GnomeBase(ControlButton & c, string const & glade_file, string const & name)
: ViewBC<gnomeBC>(c), file_(glade_file), widget_name_(name), xml_(0)
{}

View File

@ -38,7 +38,7 @@ class Dialog;
class GnomeBase : public ViewBC<gnomeBC>, public SigC::Object {
public:
///
GnomeBase(ControlBase & c, string const & glade_file, string const & name);
GnomeBase(ControlButton & c, string const & glade_file, string const & name);
///
virtual ~GnomeBase();

View File

@ -9,46 +9,25 @@
#include "gtk--/button.h"
gnomeBC::gnomeBC(string const & cancel, string const & close)
: ButtonControllerBase(cancel, close),
okay_(0), apply_(0), cancel_(0), undo_all_(0)
: GuiBC<Gtk::Button, Gtk::Widget>(cancel, close)
{}
void gnomeBC::setSensitive(Gtk::Button * btn, ButtonPolicy::Button id)
void gnomeBC::setWidgetEnabled(Gtk::Widget * obj, bool enabled)
{
if (btn) {
bool const enabled = bp().buttonStatus(id);
btn->set_sensitive(enabled);
}
if (obj)
obj->set_sensitive(enabled);
}
void gnomeBC::refresh()
void gnomeBC::setButtonEnabled(Gtk::Button * btn, bool enabled)
{
setSensitive(okay_, ButtonPolicy::OKAY);
setSensitive(apply_, ButtonPolicy::APPLY);
setSensitive(undo_all_, ButtonPolicy::UNDO_ALL);
#warning Handle the cancel button correctly! (be 20010327)
#if 0
if (cancel_) {
bool const enabled = bp().buttonStatus(ButtonPolicy::CANCEL);
// if (enabled)
// Change label to cancel_label_
// else
// Change label to close_label_
//Need to adapt it somehow since we use stock Gnome buttons.
}
#endif
if (!read_only_.empty()) {
bool enable = true;
if (bp().isReadOnly()) enable = false;
WidgetList::const_iterator end = read_only_.end();
for (WidgetList::const_iterator iter = read_only_.begin();
iter != end; ++iter) {
(*iter)->set_sensitive(enable);
}
}
setWidgetEnabled(btn, enabled);
}
void gnomeBC::setButtonLabel(Gtk::Button * obj, string const & label)
{
#warning Implement me! (be 20010329)
obj->set_text(label);
}

View File

@ -14,68 +14,35 @@
#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

View File

@ -1,3 +1,7 @@
2001-03-29 Baruch Even <baruch@lyx.org>
* kdeBC.[Ch]: Changed to use the new GuiBC template.
2001-03-15 Lars Gullik Bjønnes <larsbj@trylle.birdstep.com>
* several files: remove CXX_WORKING_NAMESPACES

View File

@ -8,48 +8,23 @@
#include <qpushbutton.h>
kdeBC::kdeBC(string const & cancel, string const & close)
: ButtonControllerBase(cancel, close),
okay_(0), apply_(0), cancel_(0), undo_all_(0), read_only_()
: GuiBC<QPushButton, QWidget>(cancel, close)
{}
void kdeBC::refresh()
void setButtonEnabled(QPushButton * btn, bool enabled)
{
if (okay_) {
if (bp().buttonStatus(ButtonPolicy::OKAY)) {
okay_->setEnabled(true);
} else {
okay_->setEnabled(false);
}
}
if (apply_) {
if (bp().buttonStatus(ButtonPolicy::APPLY)) {
apply_->setEnabled(true);
} else {
apply_->setEnabled(false);
}
}
if (undo_all_) {
if (bp().buttonStatus(ButtonPolicy::UNDO_ALL)) {
undo_all_->setEnabled(true);
} else {
undo_all_->setEnabled(false);
}
}
if (cancel_) {
if (bp().buttonStatus(ButtonPolicy::CANCEL)) {
cancel_->setText(cancel_label.c_str());
} else {
cancel_->setText(close_label.c_str());
}
}
if (!read_only_.empty()) {
bool enable = true;
if (bp().isReadOnly()) enable = false;
for (std::list<QWidget *>::iterator iter = read_only_.begin();
iter != read_only_.end(); ++iter) {
(*iter)->setEnabled(enable);
}
}
btn->setEnabled(true);
}
void setWidgetEnabled(QWidget * obj, bool enabled)
{
obj->setEnabled(true);
}
void setButtonLabel(QPushButton * btn, string const & label)
{
btn->setText(label.c_str());
}

View File

@ -15,63 +15,33 @@
#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());
}
/* Action Functions */
/// force a refresh of the buttons
virtual void refresh();
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_;
/// Updates the button sensitivity (enabled/disabled)
void setButtonEnabled(QPushButton * btn, bool enabled);
/// Updates the widget sensitivity (enabled/disabled)
void setWidgetEnabled(QWidget * obj, bool enabled);
/// Set the label on the button
void setButtonLabel(QPushButton * btn, string const & label);
};
#endif // KDEBC_H

View File

@ -1,3 +1,7 @@
2001-03-30 Angus Leeming <a.leeming@ic.ac.uk>
* Qt2Base.[Ch]: changed ControlBase to ControlButton.
2001-03-19 Edwin Leuven <leuven@fee.uva.nl>
* qt2 compiles again:

View File

@ -28,7 +28,7 @@
#include <stdio.h>
Qt2Base::Qt2Base(ControlBase & c, string const & t)
Qt2Base::Qt2Base(ControlButton & c, string const & t)
: ViewBC<qt2BC>(c), title_(t)
{}

View File

@ -38,7 +38,7 @@ class Qt2Base : public QObject, public ViewBC<qt2BC>
Q_OBJECT
public:
///
Qt2Base(ControlBase &, string const &);
Qt2Base(ControlButton &, string const &);
///
virtual ~Qt2Base() {}
@ -84,7 +84,7 @@ class Qt2DB: public Qt2Base
{
protected:
///
Qt2DB(ControlBase &, string const &);
Qt2DB(ControlButton &, string const &);
/// Pointer to the actual instantiation of the Qt dialog
virtual QDialog* form() const;
/// Real GUI implementation.
@ -93,7 +93,7 @@ protected:
template <class Dialog>
Qt2DB<Dialog>::Qt2DB(ControlBase & c, string const & t)
Qt2DB<Dialog>::Qt2DB(ControlButton & c, string const & t)
: Qt2Base(c, t)
{}
@ -110,14 +110,14 @@ class Qt2CB: public Base
{
protected:
///
Qt2CB(ControlBase &, string const &);
Qt2CB(ControlButton &, string const &);
/// The parent controller
Controller & controller() const;
};
template <class Controller, class Base>
Qt2CB<Controller, Base>::Qt2CB(ControlBase & c, string const & t)
Qt2CB<Controller, Base>::Qt2CB(ControlButton & c, string const & t)
: Base(c, t)
{}

View File

@ -1,3 +1,31 @@
2001-03-30 Angus Leeming <a.leeming@ic.ac.uk>
* FormBase.[Ch]:
* FormBrowser.[Ch]: changes associated with renaming ControlBase as
ControlButton.
* FormExternal.[Ch]:
* forms/form_external.fd: implemented controller-view split.
* Dialogs.C: associated changes.
* FormGraphics.[Ch]:
* FormInclude.[Ch]:
* FormPrint.[Ch]:
moved the browsing functionality into the controller.
* xforms_helpers.[Ch]: moved browseFile to
../controllers/helper_funcs.[Ch]
* FormCitation.C
* forms/form_citation.fd: added case sensitive search button.
2001-03-29 Angus Leeming <a.leeming@ic.ac.uk>
* xformsBC.[Ch]: Patched in a slight reworking of Baruch Even's patch.
Code moved into the generic template base class. Replaced
setCancelCloseButton() with setButtonLabel().
2001-03-29 Juergen Vigna <jug@sad.it>
* FormMinipage.C: removed widthp_ and all it's functions and changed
@ -5,9 +33,9 @@
2001-03-28 Angus Leeming <a.leeming@ic.ac.uk>
* FormGraphics.C:
* FormGraphics.[Ch]:
* forms/form_graphics.fd:
* FormIndex.C:
* FormIndex.[Ch]:
* forms/form_index.fd: implemented controller-view split.
* Dialogs.C: associated changes.

View File

@ -26,6 +26,7 @@
#include "ControlCopyright.h"
#include "ControlCredits.h"
#include "ControlError.h"
#include "ControlExternal.h"
#include "ControlGraphics.h"
#include "ControlInclude.h"
#include "ControlIndex.h"
@ -51,6 +52,7 @@
#include "form_copyright.h"
#include "form_credits.h"
#include "form_error.h"
#include "form_external.h"
#include "form_graphics.h"
#include "form_include.h"
#include "form_index.h"
@ -70,6 +72,7 @@
#include "FormCopyright.h"
#include "FormCredits.h"
#include "FormError.h"
#include "FormExternal.h"
#include "FormGraphics.h"
#include "FormInclude.h"
#include "FormIndex.h"
@ -85,7 +88,6 @@
#include "FormVCLog.h"
#include "FormDocument.h"
#include "FormExternal.h"
#include "FormMathsPanel.h"
#include "FormParagraph.h"
#include "FormPreferences.h"
@ -107,6 +109,7 @@ Dialogs::Dialogs(LyXView * lv)
add(new GUICopyright<FormCopyright, xformsBC>(*lv, *this));
add(new GUICredits<FormCredits, xformsBC>(*lv, *this));
add(new GUIError<FormError, xformsBC>(*lv, *this));
add(new GUIExternal<FormExternal, xformsBC>(*lv, *this));
add(new GUIGraphics<FormGraphics, xformsBC>(*lv, *this));
add(new GUIInclude<FormInclude, xformsBC>(*lv, *this));
add(new GUIIndex<FormIndex, xformsBC>(*lv, *this));
@ -121,7 +124,6 @@ Dialogs::Dialogs(LyXView * lv)
add(new GUIVCLog<FormVCLog, xformsBC>(*lv, *this));
add(new FormDocument(lv, this));
add(new FormExternal(lv, this));
add(new FormMathsPanel(lv, this));
add(new FormParagraph(lv, this));
add(new FormPreferences(lv, this));

View File

@ -25,7 +25,7 @@
extern "C" int C_FormBaseWMHideCB(FL_FORM * form, void *);
FormBase::FormBase(ControlBase & c, string const & t)
FormBase::FormBase(ControlButton & c, string const & t)
: ViewBC<xformsBC>(c), minw_(0), minh_(0), title_(t)
{}

View File

@ -33,7 +33,7 @@ class FormBase : public ViewBC<xformsBC>
{
public:
///
FormBase(ControlBase &, string const &);
FormBase(ControlButton &, string const &);
///
virtual ~FormBase() {}
@ -76,7 +76,7 @@ class FormDB: public FormBase
{
protected:
///
FormDB(ControlBase &, string const &);
FormDB(ControlButton &, string const &);
/// Pointer to the actual instantiation of xform's form
virtual FL_FORM * form() const;
/// Real GUI implementation.
@ -85,7 +85,7 @@ protected:
template <class Dialog>
FormDB<Dialog>::FormDB(ControlBase & c, string const & t)
FormDB<Dialog>::FormDB(ControlButton & c, string const & t)
: FormBase(c, t)
{}
@ -103,14 +103,14 @@ class FormCB: public Base
{
protected:
///
FormCB(ControlBase &, string const &);
FormCB(ControlButton &, string const &);
/// The parent controller
Controller & controller() const;
};
template <class Controller, class Base>
FormCB<Controller, Base>::FormCB(ControlBase & c, string const & t)
FormCB<Controller, Base>::FormCB(ControlButton & c, string const & t)
: Base(c, t)
{}

View File

@ -12,7 +12,7 @@
#include "form_browser.h"
#include "xformsBC.h"
FormBrowser::FormBrowser(ControlBase & c, string const & t)
FormBrowser::FormBrowser(ControlButton & c, string const & t)
: FormDB<FD_form_browser>(c, t)
{}

View File

@ -25,7 +25,7 @@ struct FD_form_browser;
class FormBrowser : public FormDB<FD_form_browser> {
public:
///
FormBrowser(ControlBase &, string const &);
FormBrowser(ControlButton &, string const &);
private:
/// Build the dialog.

View File

@ -1,4 +1,3 @@
// -*- C++ -*-
/* This file is part of
* ======================================================
*
@ -8,7 +7,8 @@
*
* ======================================================
*
* \author Angus Leeming <a.leeming@ic.ac.uk>
* \file FormCitation.C
* \author Angus Leeming, a.leeming@ic.ac.uk
*/
#include <config.h>
@ -68,6 +68,7 @@ void FormCitation::build()
fl_set_input_return(dialog_->input_after, FL_RETURN_CHANGED);
fl_set_input_return(dialog_->input_before, FL_RETURN_CHANGED);
fl_set_button(dialog_->button_search_case, 0);
fl_set_button(dialog_->button_search_type, 0);
fl_set_object_label(dialog_->button_search_type, _("Simple"));
@ -228,12 +229,20 @@ ButtonPolicy::SMInput FormCitation::input(FL_OBJECT * ob, long)
activate = ButtonPolicy::SMI_VALID;
} else if (ob == dialog_->button_search_type) {
fl_freeze_form(form());
// Fudge to overcome xforms drawing bug
fl_hide_object(dialog_->button_search_type);
if (fl_get_button(dialog_->button_search_type))
fl_set_object_label(dialog_->button_search_type,
_("Regex"));
else
fl_set_object_label(dialog_->button_search_type,
_("Simple"));
fl_show_object(dialog_->button_search_type);
fl_unfreeze_form(form());
return ButtonPolicy::SMI_NOOP;
} else if (ob == dialog_->button_previous ||
@ -260,9 +269,12 @@ ButtonPolicy::SMInput FormCitation::input(FL_OBJECT * ob, long)
else
start -= 1;
bool const caseSensitive =
fl_get_button(dialog_->button_search_case);
vector<string>::const_iterator const cit =
biblio::searchKeys(theMap, bibkeys, str,
start, type, dir);
start, type, dir, caseSensitive);
if (cit == bibkeys.end())
return ButtonPolicy::SMI_NOOP;
@ -437,6 +449,10 @@ void FormCitation::setSize(int hbrsr, bool bibPresent) const
y = dialog_->button_previous->y;
fl_set_object_position(dialog_->button_search_type, x, y);
x = dialog_->button_search_case->x;
y = dialog_->button_next->y;
fl_set_object_position(dialog_->button_search_case, x, y);
y = dialog_->frame_search->y + hframe + dh1;
if (natbib) {

View File

@ -1,125 +1,48 @@
/**
* \file FormExternal.C
* Copyright 2001 the LyX Team
* Read the file COPYING
/* This file is part of
* ======================================================
*
* \author unknown
* LyX, The Document Processor
*
* Copyright 2000-2001 The LyX Team.
*
* ======================================================
*
* \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"
#include "gettext.h"
#include "xforms_helpers.h"
#include "helper_funcs.h"
using std::pair;
using std::make_pair;
using std::endl;
using SigC::slot;
typedef FormCB<ControlExternal, FormDB<FD_form_external> > base_class;
FormExternal::FormExternal(LyXView * lv, Dialogs * d)
: FormBaseBD(lv, d, _("Edit external file")),
inset_(0), ih_(0)
FormExternal::FormExternal(ControlExternal & c)
: base_class(c, _("Edit external file"))
{}
void FormExternal::apply()
{
d->showExternal.connect(slot(this, &FormExternal::showInset));
}
controller().params().filename =
fl_get_input(dialog_->input_filename);
controller().params().parameters =
fl_get_input(dialog_->input_parameters);
extern "C" void ExternalTemplateCB(FL_OBJECT * ob, long data)
{
FormExternal::templateCB(ob, data);
}
extern "C" void ExternalBrowseCB(FL_OBJECT * ob, long data)
{
FormExternal::browseCB(ob, data);
}
extern "C" void ExternalEditCB(FL_OBJECT * ob, long data)
{
FormExternal::editCB(ob, data);
}
extern "C" void ExternalViewCB(FL_OBJECT * ob, long data)
{
FormExternal::viewCB(ob, data);
}
extern "C" void ExternalUpdateCB(FL_OBJECT * ob, long data)
{
FormExternal::updateCB(ob, data);
}
FL_FORM * FormExternal::form() const
{
if (dialog_.get())
return dialog_->form;
return 0;
}
void FormExternal::connect()
{
u_ = d_->updateBufferDependent.
connect(slot(this, &FormExternal::updateSlot));
h_ = d_->hideBufferDependent.
connect(slot(this, &FormExternal::hide));
FormBaseDeprecated::connect();
}
void FormExternal::disconnect()
{
inset_ = 0;
ih_.disconnect();
FormBaseBD::disconnect();
}
void FormExternal::updateSlot(bool switched)
{
if (switched)
hide();
else
update();
}
void FormExternal::showInset(InsetExternal * inset)
{
Assert(inset);
// If connected to another inset, disconnect from it.
if (inset_)
ih_.disconnect();
inset_ = inset;
params_ = inset_->params();
ih_ = inset->hideDialog.connect(slot(this, &FormExternal::hide));
show();
int const choice = fl_get_choice(dialog_->choice_template);
controller().params().templ = controller().getTemplate(choice);
}
@ -127,76 +50,71 @@ void FormExternal::build()
{
dialog_.reset(build_external());
fl_addto_choice(dialog_->choice_template,
getTemplatesComboString().c_str());
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();
bc().setOK(dialog_->button_ok);
bc().setCancel(dialog_->button_cancel);
bc().refresh();
bc_.addReadOnly(dialog_->input_filename);
bc_.addReadOnly(dialog_->button_filenamebrowse);
bc_.addReadOnly(dialog_->input_parameters);
}
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;
}
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;
bc().addReadOnly(dialog_->input_filename);
bc().addReadOnly(dialog_->button_filenamebrowse);
bc().addReadOnly(dialog_->input_parameters);
}
void FormExternal::update()
{
fl_set_input(dialog_->input_filename, params_.filename.c_str());
fl_set_input(dialog_->input_parameters, params_.parameters.c_str());
InsetExternal::Params const & params = controller().params();
fl_set_choice(dialog_->choice_template, getTemplateComboNumber(params_.templ.lyxName));
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);
updateComboChange();
}
bc_.valid();
ButtonPolicy::SMInput FormExternal::input(FL_OBJECT * ob, long)
{
if (ob == dialog_->choice_template) {
// set to the chosen template
int const choice = fl_get_choice(dialog_->choice_template);
controller().params().templ = controller().getTemplate(choice);
updateComboChange();
} 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());
} else if (ob == dialog_->button_edit) {
apply();
controller().editExternal();
} else if (ob == dialog_->button_view) {
apply();
controller().viewExternal();
} else if (ob == dialog_->button_update) {
apply();
controller().updateExternal();
}
return ButtonPolicy::SMI_VALID;
}
@ -204,134 +122,10 @@ void FormExternal::updateComboChange()
{
// Update the help text
fl_clear_browser(dialog_->browser_helptext);
fl_addto_browser(dialog_->browser_helptext, params_.templ.helpText.c_str());
fl_addto_browser(dialog_->browser_helptext,
controller().params().templ.helpText.c_str());
fl_set_browser_topline(dialog_->browser_helptext, 0);
if (params_.templ.automaticProduction) {
fl_deactivate_object(dialog_->button_update);
fl_set_object_lcol(dialog_->button_update, FL_INACTIVE);
} else {
fl_activate_object(dialog_->button_update);
fl_set_object_lcol(dialog_->button_update, FL_BLACK);
}
}
bool FormExternal::input(FL_OBJECT *, long)
{
// FIXME: anything to do here ?
return true;
}
void FormExternal::apply()
{
Assert(inset_);
if (lv_->buffer()->isReadonly())
return;
params_.filename = fl_get_input(dialog_->input_filename);
params_.parameters = fl_get_input(dialog_->input_parameters);
params_.templ = getTemplate(fl_get_choice(dialog_->choice_template));
inset_->setFromParams(params_);
lv_->view()->updateInset(inset_, true);
}
void FormExternal::templateCB(FL_OBJECT * ob, long)
{
FormExternal * form = static_cast<FormExternal*>(ob->form->u_vdata);
// set to the chosen template
form->params_.templ = form->getTemplate(fl_get_choice(form->dialog_->choice_template));
form->updateComboChange();
}
void FormExternal::browseCB(FL_OBJECT * ob, long)
{
FormExternal * form = static_cast<FormExternal*>(ob->form->u_vdata);
static string current_path;
static int once = 0;
string p = fl_get_input(form->dialog_->input_filename);
string buf = MakeAbsPath(form->lv_->buffer()->fileName());
string buf2 = OnlyPath(buf);
if (!p.empty()) {
buf = MakeAbsPath(p, buf2);
buf = OnlyPath(buf);
} else {
buf = OnlyPath(form->lv_->buffer()->fileName());
}
FileDialog fileDlg(form->lv_, _("Select external file"),
LFUN_SELECT_FILE_SYNC,
make_pair(string(_("Document")), string(buf)));
/// Determine the template file extension
ExternalTemplate const & et = form->params_.templ;
string regexp = et.fileRegExp;
if (regexp.empty())
regexp = "*";
// FIXME: a temporary hack until the FileDialog interface is updated
regexp += "|";
while (1) {
string const path = (once) ? current_path : buf;
FileDialog::Result result = fileDlg.Select(path, regexp, fl_get_input(form->dialog_->input_filename));
if (result.second.empty())
return;
string p = result.second;
buf = MakeRelPath(p, buf2);
current_path = OnlyPath(p);
once = 1;
if (contains(p, "#") || contains(p, "~") || contains(p, "$")
|| contains(p, "%")) {
WriteAlert(_("Filename can't contain any "
"of these characters:"),
// xgettext:no-c-format
_("'#', '~', '$' or '%'."));
} else
break;
}
fl_set_input(form->dialog_->input_filename, buf.c_str());
}
void FormExternal::editCB(FL_OBJECT * ob, long)
{
FormExternal * form = static_cast<FormExternal*>(ob->form->u_vdata);
form->apply();
form->inset_->editExternal();
}
void FormExternal::viewCB(FL_OBJECT * ob, long)
{
FormExternal * form = static_cast<FormExternal*>(ob->form->u_vdata);
form->apply();
form->inset_->viewExternal();
}
void FormExternal::updateCB(FL_OBJECT * ob, long)
{
FormExternal * form = static_cast<FormExternal*>(ob->form->u_vdata);
form->apply();
form->inset_->updateExternal();
bool const enabled = (!controller().params().templ.automaticProduction);
setEnabled(dialog_->button_update, enabled);
}

View File

@ -1,113 +1,55 @@
/**
* \file FormExternal.h
* Copyright 2001 the LyX Team
* Read the file COPYING
/* This file is part of
* ======================================================
*
* \author unknown
* LyX, The Document Processor
*
* Copyright 2000-2001 The LyX Team.
*
* ======================================================
*
* \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;
/// apply changes
void apply();
/// 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;
/// 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();
/// Filter the inputs on callback from xforms
ButtonPolicy::SMInput input(FL_OBJECT *, long);
bool input(FL_OBJECT * obj, long data);
///
void updateComboChange();
/// inset::hide connection.
SigC::Connection ih_;
/// 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

View File

@ -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<ControlGraphics, FormDB<FD_form_graphics> > base_class;
@ -229,8 +225,18 @@ ButtonPolicy::SMInput FormGraphics::input(FL_OBJECT *, long data)
activate = checkInput();
break;
case BROWSE:
browse();
{
// Get the filename from the dialog
string const in_name = fl_get_input(dialog_->input_filename);
string const out_name = controller().Browse(in_name);
if (out_name != in_name && !out_name.empty()) {
fl_set_input(dialog_->input_filename, out_name.c_str());
input(0, 0);
}
break;
}
case ADVANCEDINPUT:
lyxerr << "Advanced Options button depressed, "
<< "show advanced options dialog"
@ -289,37 +295,3 @@ ButtonPolicy::SMInput FormGraphics::checkInput()
return activate;
}
// We need these in the file browser.
extern string system_lyxdir;
extern string user_lyxdir;
void FormGraphics::browse()
{
// Get the filename from the dialog
string const filename = fl_get_input(dialog_->input_filename);
string const title = N_("Graphics");
// FIXME: currently we need the second '|' to prevent mis-interpretation
string const pattern = "*.(ps|png)|";
// Does user clipart directory exist?
string clipdir = AddName (user_lyxdir, "clipart");
FileInfo fileInfo(clipdir);
if (!(fileInfo.isOK() && fileInfo.isDir()))
// No - bail out to system clipart directory
clipdir = AddName (system_lyxdir, "clipart");
pair<string, string> dir1(N_("Clipart"), clipdir);
// Show the file browser dialog
string const new_filename =
browseFile(controller().lv(), filename, title, pattern, dir1,
make_pair(string(), string()));
// Save the filename to the dialog
if (new_filename != filename && !new_filename.empty()) {
fl_set_input(dialog_->input_filename, new_filename.c_str());
input(0, 0);
}
}

View File

@ -75,8 +75,6 @@ private:
/// Verify that the input is correct. If not disable ok/apply buttons.
ButtonPolicy::SMInput checkInput();
/// Open the file browse dialog to select an image file.
void browse();
/// Fdesign generated method
FD_form_graphics * build_graphics();

View File

@ -8,31 +8,20 @@
* \author Angus Leeming, a.leeming@.ac.uk
*/
#include <config.h>
#include <algorithm>
#include <utility>
#ifdef __GNUG__
#pragma implementation
#endif
#include <config.h>
#include "xformsBC.h"
#include "ControlInclude.h"
#include "FormInclude.h"
#include "form_include.h"
#include "insets/insetinclude.h"
#include "frontends/FileDialog.h"
#include "LyXView.h"
#include "buffer.h"
#include "xforms_helpers.h" // setEnabled
#include "support/filetools.h"
#include "support/lstrings.h"
#include "lyxrc.h"
using std::make_pair;
using std::pair;
#include "support/lstrings.h" // compare
typedef FormCB<ControlInclude, FormDB<FD_form_include> > base_class;
@ -118,8 +107,23 @@ void FormInclude::apply()
ButtonPolicy::SMInput FormInclude::input(FL_OBJECT * ob, long)
{
if (ob == dialog_->button_browse)
return inputBrowse();
if (ob == dialog_->button_browse) {
ControlInclude::Type type;
if (fl_get_button(dialog_->check_useinput))
type = ControlInclude::INPUT;
else if (fl_get_button(dialog_->check_verbatim))
type = ControlInclude::VERBATIM;
else
type = ControlInclude::INCLUDE;
string const in_name = fl_get_input(dialog_->input_filename);
fl_freeze_form(form());
string const out_name = controller().Browse(in_name, type);
fl_set_input(dialog_->input_filename, out_name.c_str());
fl_unfreeze_form(form());
return ButtonPolicy::SMI_VALID;
}
if (ob == dialog_->button_load) {
if (compare(fl_get_input(dialog_->input_filename),"")) {
@ -139,44 +143,3 @@ ButtonPolicy::SMInput FormInclude::input(FL_OBJECT * ob, long)
return ButtonPolicy::SMI_VALID;
}
ButtonPolicy::SMInput FormInclude::inputBrowse()
{
// Should browsing too be disabled in RO-mode?
FileDialog fileDlg(controller().lv(),
_("Select document to include"),
LFUN_SELECT_FILE_SYNC,
make_pair(string(_("Documents")),
string(lyxrc.document_path)));
string ext;
// input TeX, verbatim, or LyX file ?
if (fl_get_button(dialog_->check_useinput))
ext = _("*.tex| LaTeX Documents (*.tex)");
else if (fl_get_button(dialog_->check_verbatim))
ext = _("*| All files ");
else
ext = _("*.lyx| LyX Documents (*.lyx)");
string const mpath =
OnlyPath(controller().params().masterFilename_);
FileDialog::Result const result =
fileDlg.Select(mpath, ext,
fl_get_input(dialog_->input_filename));
// check selected filename
if (result.second.empty())
return ButtonPolicy::SMI_NOOP;
string const filename2 = MakeRelPath(result.second, mpath);
if (prefixIs(filename2, ".."))
fl_set_input(dialog_->input_filename, result.second.c_str());
else
fl_set_input(dialog_->input_filename, filename2.c_str());
return ButtonPolicy::SMI_VALID;
}

View File

@ -37,9 +37,6 @@ private:
/// Filter the inputs on callback from xforms
virtual ButtonPolicy::SMInput input(FL_OBJECT *, long);
///
ButtonPolicy::SMInput inputBrowse();
/// Fdesign generated method
FD_form_include * build_include();
};

View File

@ -42,6 +42,7 @@
#include "lyxlex.h"
#include "input_validators.h"
#include "xforms_helpers.h"
#include "helper_funcs.h"
#include "converter.h"
#include "support/lyxfunctional.h"
#include "support/lyxmanip.h"

View File

@ -210,7 +210,15 @@ ButtonPolicy::SMInput FormPrint::input(FL_OBJECT * ob, long)
}
if (ob == dialog_->button_browse) {
browse();
// Get the filename from the dialog
string const in_name = fl_get_input(dialog_->input_file);
string const out_name = controller().Browse(in_name);
// Save the filename to the dialog
if (out_name != in_name && !out_name.empty()) {
fl_set_input(dialog_->input_file, out_name.c_str());
input(0, 0);
}
}
// it is probably legal to have no printer name since the system will
@ -221,25 +229,3 @@ ButtonPolicy::SMInput FormPrint::input(FL_OBJECT * ob, long)
// }
return activate;
}
void FormPrint::browse()
{
// Get the filename from the dialog
string const filename = fl_get_input(dialog_->input_file);
string const title = N_("Print to file");
string const pattern = "*.ps";
// Show the file browser dialog
string const new_filename =
browseFile(controller().lv(), filename, title, pattern,
make_pair(string(), string()),
make_pair(string(), string()));
// Save the filename to the dialog
if (new_filename != filename && !new_filename.empty()) {
fl_set_input(dialog_->input_file, new_filename.c_str());
input(0, 0);
}
}

View File

@ -48,9 +48,6 @@ private:
/// Filter the inputs on callback from xforms
virtual ButtonPolicy::SMInput input(FL_OBJECT *, long);
/// Open the file browse dialog.
void browse();
/// Fdesign generated method
FD_form_print * build_print();

View File

@ -73,9 +73,11 @@ FD_form_citation * FormCitation::build_citation()
fl_set_object_lalign(obj, FL_ALIGN_TOP);
fl_set_object_gravity(obj, FL_SouthWest, FL_SouthEast);
fl_set_object_resize(obj, FL_RESIZE_NONE);
fdui->button_search_type = obj = fl_add_button(FL_PUSH_BUTTON, 25, 525, 90, 30, _("Simple"));
fdui->button_search_type = obj = fl_add_checkbutton(FL_PUSH_BUTTON, 25, 525, 30, 30, _("Simple"));
fl_set_object_gravity(obj, FL_SouthWest, FL_SouthWest);
fl_set_object_callback(obj, C_FormBaseInputCB, 0);
fdui->button_search_case = obj = fl_add_checkbutton(FL_PUSH_BUTTON, 25, 560, 30, 30, _("Case sensitive"));
fl_set_object_gravity(obj, FL_SouthWest, FL_SouthWest);
{
char const * const dummy = N_("Previous|#P");
fdui->button_previous = obj = fl_add_button(FL_NORMAL_BUTTON, 315, 525, 90, 30, idex(_(dummy)));

View File

@ -28,6 +28,7 @@ struct FD_form_citation {
FL_OBJECT *frame_search;
FL_OBJECT *input_search;
FL_OBJECT *button_search_type;
FL_OBJECT *button_search_case;
FL_OBJECT *button_previous;
FL_OBJECT *button_next;
FL_OBJECT *choice_style;

View File

@ -33,7 +33,7 @@ FD_form_external * FormExternal::build_external()
fl_set_object_boxtype(obj, FL_FRAME_BOX);
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
fl_set_object_gravity(obj, FL_NorthWest, FL_NorthEast);
fl_set_object_callback(obj, ExternalTemplateCB, 0);
fl_set_object_callback(obj, C_FormBaseInputCB, 0);
{
char const * const dummy = N_("File|#F");
fdui->input_filename = obj = fl_add_input(FL_NORMAL_INPUT, 130, 190, 190, 30, idex(_(dummy)));
@ -49,7 +49,7 @@ FD_form_external * FormExternal::build_external()
}
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
fl_set_object_gravity(obj, FL_SouthEast, FL_SouthEast);
fl_set_object_callback(obj, ExternalBrowseCB, 0);
fl_set_object_callback(obj, C_FormBaseInputCB, 0);
{
char const * const dummy = N_("Parameters|#P");
fdui->input_parameters = obj = fl_add_input(FL_NORMAL_INPUT, 130, 230, 300, 30, idex(_(dummy)));
@ -65,7 +65,7 @@ FD_form_external * FormExternal::build_external()
fl_set_object_color(obj, FL_COL1, FL_BLACK);
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
fl_set_object_gravity(obj, FL_NorthEast, FL_NorthEast);
fl_set_object_callback(obj, ExternalEditCB, 0);
fl_set_object_callback(obj, C_FormBaseInputCB, 0);
{
char const * const dummy = N_("View result|#V");
fdui->button_view = obj = fl_add_button(FL_NORMAL_BUTTON, 435, 90, 110, 30, idex(_(dummy)));
@ -74,7 +74,7 @@ FD_form_external * FormExternal::build_external()
fl_set_object_color(obj, FL_COL1, FL_BLACK);
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
fl_set_object_gravity(obj, FL_NorthEast, FL_NorthEast);
fl_set_object_callback(obj, ExternalViewCB, 0);
fl_set_object_callback(obj, C_FormBaseInputCB, 0);
{
char const * const dummy = N_("Update result|#U");
fdui->button_update = obj = fl_add_button(FL_NORMAL_BUTTON, 435, 130, 110, 30, idex(_(dummy)));
@ -83,7 +83,7 @@ FD_form_external * FormExternal::build_external()
fl_set_object_color(obj, FL_COL1, FL_BLACK);
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
fl_set_object_gravity(obj, FL_NorthEast, FL_NorthEast);
fl_set_object_callback(obj, ExternalUpdateCB, 0);
fl_set_object_callback(obj, C_FormBaseInputCB, 0);
fdui->button_ok = obj = fl_add_button(FL_RETURN_BUTTON, 315, 270, 110, 30, _("OK"));
fl_set_object_color(obj, FL_COL1, FL_BLACK);
fl_set_object_lsize(obj, FL_NORMAL_SIZE);

View File

@ -5,12 +5,7 @@
#define FD_form_external_h_
/** Callbacks, globals and object handlers **/
extern "C" void ExternalTemplateCB(FL_OBJECT *, long);
extern "C" void C_FormBaseInputCB(FL_OBJECT *, long);
extern "C" void ExternalBrowseCB(FL_OBJECT *, long);
extern "C" void ExternalEditCB(FL_OBJECT *, long);
extern "C" void ExternalViewCB(FL_OBJECT *, long);
extern "C" void ExternalUpdateCB(FL_OBJECT *, long);
extern "C" void C_FormBaseOKCB(FL_OBJECT *, long);
extern "C" void C_FormBaseCancelCB(FL_OBJECT *, long);

View File

@ -10,7 +10,7 @@ Unit of measure: FL_COORD_PIXEL
Name: form_citation
Width: 430
Height: 830
Number of Objects: 20
Number of Objects: 21
--------------------
class: FL_BOX
@ -193,11 +193,11 @@ callback:
argument:
--------------------
class: FL_BUTTON
class: FL_CHECKBUTTON
type: PUSH_BUTTON
box: 25 525 90 30
boxtype: FL_UP_BOX
colors: FL_COL1 FL_COL1
box: 25 525 30 30
boxtype: FL_NO_BOX
colors: FL_COL1 FL_YELLOW
alignment: FL_ALIGN_CENTER
style: FL_NORMAL_STYLE
size: FL_DEFAULT_SIZE
@ -210,6 +210,24 @@ name: button_search_type
callback: C_FormBaseInputCB
argument: 0
--------------------
class: FL_CHECKBUTTON
type: PUSH_BUTTON
box: 25 560 30 30
boxtype: FL_NO_BOX
colors: FL_COL1 FL_YELLOW
alignment: FL_ALIGN_CENTER
style: FL_NORMAL_STYLE
size: FL_DEFAULT_SIZE
lcol: FL_BLACK
label: Case sensitive
shortcut:
resize: FL_RESIZE_NONE
gravity: FL_SouthWest FL_SouthWest
name: button_search_case
callback:
argument:
--------------------
class: FL_BUTTON
type: NORMAL_BUTTON
@ -222,7 +240,7 @@ size: FL_DEFAULT_SIZE
lcol: FL_BLACK
label: Previous|#P
shortcut:
resize: FL_RESIZE_ALL
resize: FL_RESIZE_NONE
gravity: FL_SouthEast FL_SouthEast
name: button_previous
callback: C_FormBaseInputCB
@ -240,7 +258,7 @@ size: FL_DEFAULT_SIZE
lcol: FL_BLACK
label: Next|#N
shortcut:
resize: FL_RESIZE_ALL
resize: FL_RESIZE_NONE
gravity: FL_SouthEast FL_SouthEast
name: button_next
callback: C_FormBaseInputCB

View File

@ -45,7 +45,7 @@ shortcut:
resize: FL_RESIZE_ALL
gravity: FL_NorthWest FL_NorthEast
name: choice_template
callback: ExternalTemplateCB
callback: C_FormBaseInputCB
argument: 0
--------------------
@ -81,7 +81,7 @@ shortcut:
resize: FL_RESIZE_ALL
gravity: FL_SouthEast FL_SouthEast
name: button_filenamebrowse
callback: ExternalBrowseCB
callback: C_FormBaseInputCB
argument: 0
--------------------
@ -117,7 +117,7 @@ shortcut:
resize: FL_RESIZE_ALL
gravity: FL_NorthEast FL_NorthEast
name: button_edit
callback: ExternalEditCB
callback: C_FormBaseInputCB
argument: 0
--------------------
@ -135,7 +135,7 @@ shortcut:
resize: FL_RESIZE_ALL
gravity: FL_NorthEast FL_NorthEast
name: button_view
callback: ExternalViewCB
callback: C_FormBaseInputCB
argument: 0
--------------------
@ -153,7 +153,7 @@ shortcut:
resize: FL_RESIZE_ALL
gravity: FL_NorthEast FL_NorthEast
name: button_update
callback: ExternalUpdateCB
callback: C_FormBaseInputCB
argument: 0
--------------------

View File

@ -1,10 +1,16 @@
/**
* \file xformsBC.C
* Copyright 2001 the LyX Team
* Read the file COPYING
/* This file is part of
* ======================================================
*
* \author Allan Rae <rae@lyx.org>
* \author Angus Leeming <a.leeming@ic.ac.uk>
* LyX, The Document Processor
*
* Copyright 2001 The LyX Team.
*
* ======================================================
*
* \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>
@ -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<FL_OBJECT, FL_OBJECT>(cancel, close)
{}
void xformsBC::refresh()
void xformsBC::setButtonEnabled(FL_OBJECT * obj, bool enabled)
{
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);
}
}
setEnabled(obj, enabled);
}
void xformsBC::setWidgetEnabled(FL_OBJECT * obj, bool enabled)
{
setEnabled(obj, enabled);
}
void xformsBC::setButtonLabel(FL_OBJECT * obj, string const & label)
{
fl_set_object_label(obj, label.c_str());
}

View File

@ -1,19 +1,16 @@
// -*- C++ -*-
/* This file is part of
* ======================================================
*
* LyX, The Document Processor
*
* Copyright 1995 Matthias Ettrich
* Copyright 1995-2000 The LyX Team.
* Copyright 2001 The LyX Team.
*
* This file Copyright 2000
* Allan Rae
* ======================================================
*
* Author: Allan Rae <rae@lyx.org>
* Non-xforms-specific code stripped-out and placed in a base class by
* Angus Leeming <a.leeming@ic.ac.uk>
* \file xformsBC.h
* \author Allan Rae, rae@lyx.org
* \author Angus Leeming, a.leeming@ic.ac.uk
* \author Baruch Even, baruch.even@writeme.com
*/
#ifndef XFORMSBC_H
@ -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<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());
}
/* Action Functions */
/// force a refresh of the buttons
virtual void refresh();
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_;
/// Updates the button sensitivity (enabled/disabled)
void setButtonEnabled(FL_OBJECT *, bool enabled);
/// Updates the widget sensitivity (enabled/disabled)
void setWidgetEnabled(FL_OBJECT *, bool enabled);
/// Set the label on the button
void setButtonLabel(FL_OBJECT *, string const & label);
};
#endif // XFORMSBC_H

View File

@ -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<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().

View File

@ -5,9 +5,6 @@
#pragma interface
#endif
#include <utility> // pair
//#include <config.h>
#include "LString.h"
#include "Color.h"
// Set an FL_OBJECT to activated or deactivated
@ -17,20 +14,6 @@ void setEnabled(FL_OBJECT *, bool enable);
string formatted(string const &label, int w,
int=FL_NORMAL_SIZE, int=FL_NORMAL_STYLE);
class LyXView;
/** Launch a file dialog and return the chosen file.
filename: a suggested filename.
title: the title of the dialog.
pattern: *.ps etc.
dir1 = (name, dir), dir2 = (name, dir): extra buttons on the dialog.
*/
string const browseFile(LyXView *lv, string const & filename,
string const & title,
string const & pattern,
std::pair<string,string> const & dir1,
std::pair<string,string> const & dir2);
/// struct holding xform-specific colors
struct XformsColor : public NamedColor {
int colorID;

View File

@ -1,3 +1,9 @@
2001-03-29 Angus Leeming <a.leeming@ic.ac.uk>
* insetexternal.[Ch]: renamed InsetExternal::InsetExternalParams as
InsetExternal::Params.
Added operator==() and operator!=() for the Params struct.
2001-03-29 Juergen Vigna <jug@sad.it>
* lyxinset.h: changed parameter of getMaxWidth from Painter & to
@ -8,7 +14,7 @@
2001-03-28 Angus Leeming <a.leeming@ic.ac.uk>
* insets/figinset.[Ch]: changed headers lyx.h, form1.h -> figure_form.h.
* figinset.[Ch]: changed headers lyx.h, form1.h -> figure_form.h.
2001-03-27 Angus Leeming <a.leeming@ic.ac.uk>

View File

@ -48,13 +48,13 @@ InsetExternal::~InsetExternal()
}
InsetExternal::InsetExternalParams InsetExternal::params() const
InsetExternal::Params InsetExternal::params() const
{
return params_;
}
void InsetExternal::setFromParams(InsetExternalParams const & p)
void InsetExternal::setFromParams(Params const & p)
{
params_.filename = p.filename;
params_.parameters = p.parameters;
@ -290,3 +290,20 @@ void InsetExternal::editExternal() const
et.editCommand),
view->buffer());
}
bool operator==(InsetExternal::Params const & left,
InsetExternal::Params const & right)
{
return ((left.filename == right.filename) &&
(left.parameters == right.parameters) &&
(left.templ.lyxName == right.templ.lyxName));
}
bool operator!=(InsetExternal::Params const & left,
InsetExternal::Params const & right)
{
return !(left == right);
}

View File

@ -25,8 +25,8 @@
class InsetExternal : public InsetButton {
public:
/// hold parameters settable from the GUI
struct InsetExternalParams {
InsetExternalParams(string const & f = string(),
struct Params {
Params(string const & f = string(),
string const & p = string(),
ExternalTemplate const & t = ExternalTemplate())
: filename(f), parameters(p), templ(t) {}
@ -82,7 +82,7 @@ public:
// The following public members are used from the frontends code
/// set the parameters from a Params structure
virtual void setFromParams(InsetExternalParams const &);
virtual void setFromParams(Params const &);
/// update the file represented by the template
void updateExternal() const;
@ -94,7 +94,7 @@ public:
void viewExternal() const;
/// return a copy of our current params
InsetExternalParams params() const;
Params params() const;
/// hide connection
SigC::Signal0<void> hideDialog;
@ -114,10 +114,15 @@ private:
BufferView * view;
/// the current params
InsetExternalParams params_;
Params params_;
/// A temp filename
string tempname;
};
///
bool operator==(InsetExternal::Params const &, InsetExternal::Params const &);
///
bool operator!=(InsetExternal::Params const &, InsetExternal::Params const &);
#endif