Implemented controller-view split for FormError and FormInclude.

Cleaned up code in controllers in the process; I think that the interface
is stabilising now.
Cleaned up code in InsetInclude a little.

Mental note (to me?!): the Bibitem, Bibtex and Include insets create an
inset when the appropriate menu item is selected. This is incorrect;
the inset should only be created when "Ok" is pressed, as with the
majority of insets. CREATE_XXX flags and associated code are needed.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1817 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Angus Leeming 2001-03-23 17:09:34 +00:00
parent fb28d5b938
commit 9705be9f1b
41 changed files with 853 additions and 666 deletions

View File

@ -2928,13 +2928,14 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
if (!bv_->insertInset(inset, "Standard", true))
delete inset;
}
break;
case LFUN_CHILD_INSERT:
{
InsetInclude::InsetIncludeParams p;
InsetInclude::Params p;
p.cparams.setFromString(argument);
p.buffer = buffer_;
p.masterFilename_ = buffer_->fileName();
InsetInclude * inset = new InsetInclude(p);
if (!bv_->insertInset(inset))

View File

@ -2,6 +2,9 @@
* LString.h: removed "using std::getline"!
* BufferView_pimpl.C (Dispatch): changes due to changes in
InsetInclude::Params.
* buffer.C (tag_name): removed redundant break statements as they were
producing lots of warnings with my compiler.

View File

@ -1,3 +1,25 @@
2001-03-23 Angus Leeming <a.leeming@ic.ac.uk>
* ControlDialogs.h: moved class ControlInset into its own file.
* ControlInset.h: new file. class ControlInset has been expanded to take
two template parameters, Inset and Params. Believe that all inset
controllers can be derived from this with the minimum of effort.
* ControlBibitem.[Ch]:
* ControlBibtex.[Ch]:
* ControlCitation.[Ch]:
* ControlCommand.[Ch]: moved most code into ControlInset.
* lots of files. Moved protected stuff into private where possible.
* ControlError.[Ch]:
* ControlInclude.[Ch]: new files; controllers for the LaTeX error and
Include popups, respectively.
* GUI.h:
* Makefile.am: associated changes.
2001-03-23 Angus Leeming <a.leeming@ic.ac.uk>
* ControlCredits.[Ch] (getCredits): returns a stringstream not a

View File

@ -23,7 +23,7 @@
#include "ControlBibitem.h"
#include "Dialogs.h"
#include "LyXView.h"
#include "BufferView.h"
#include "buffer.h"
using SigC::slot;
@ -33,24 +33,19 @@ ControlBibitem::ControlBibitem(LyXView & lv, Dialogs & d)
d_.showBibitem.connect(slot(this, &ControlBibitem::showInset));
}
void ControlBibitem::apply()
void ControlBibitem::applyParamsToInset()
{
view().apply();
if (inset_ && params() != inset_->params()) {
// FIXME:
// confirm, is this only necessary for FormBibTeX ???
if (params().getContents() != inset_->params().getContents())
lv_.view()->ChangeCitationsIfUnique(
inset_->params().getContents(),
if (params().getContents() != inset()->params().getContents())
lv_.view()->ChangeCitationsIfUnique(inset()->params().getContents(),
params().getContents());
inset_->setParams(params());
lv_.view()->updateInset(inset_, true);
inset()->setParams(params());
lv_.view()->updateInset(inset(), true);
// We need to do a redraw because the maximum
// InsetBibKey width could have changed
lv_.view()->redraw();
lv_.view()->fitCursor(lv_.view()->getLyXText());
}
}

View File

@ -30,9 +30,13 @@ public:
///
ControlBibitem(LyXView &, Dialogs &);
protected:
/// Get changed parameters and Dispatch them to the kernel.
virtual void apply();
private:
/// Dispatch the changed parameters to the kernel.
virtual void applyParamsToInset();
/// not needed.
virtual void applyParamsNoInset() {}
/// not needed.
virtual void clearDaughterParams() {}
};
#endif // CONTROLBIBITEM_H

View File

@ -23,7 +23,7 @@
#include "ControlBibtex.h"
#include "Dialogs.h"
#include "LyXView.h"
#include "BufferView.h"
#include "buffer.h"
using SigC::slot;
@ -33,22 +33,21 @@ ControlBibtex::ControlBibtex(LyXView & lv, Dialogs & d)
d_.showBibtex.connect(slot(this, &ControlBibtex::showInset));
}
void ControlBibtex::apply()
void ControlBibtex::applyParamsToInset()
{
view().apply();
if (inset_ && params() != inset_->params()) {
if (params().getContents() != inset_->params().getContents())
lv_.view()->ChangeCitationsIfUnique(
inset_->params().getContents(),
if (params().getContents() != inset()->params().getContents())
lv_.view()->ChangeCitationsIfUnique(inset()->params().getContents(),
params().getContents());
inset_->setParams(params());
lv_.view()->updateInset(inset_, true);
inset()->setParams(params());
lv_.view()->updateInset(inset(), true);
// We need to do a redraw because the maximum
// InsetBibKey width could have changed
lv_.view()->redraw();
lv_.view()->fitCursor(lv_.view()->getLyXText());
}
}
void ControlBibtex::applyParamsNoInset()
{}

View File

@ -30,9 +30,13 @@ public:
///
ControlBibtex(LyXView &, Dialogs &);
protected:
/// Get changed parameters and Dispatch them to the kernel.
virtual void apply();
private:
/// Dispatch the changed parameters to the kernel.
virtual void applyParamsToInset();
///
virtual void applyParamsNoInset();
/// not needed.
virtual void clearDaughterParams() {}
};
#endif // CONTROLBIBTEX_H

View File

@ -71,7 +71,7 @@ public:
///
void setToggleAll(bool);
protected:
private:
/// Get changed parameters and Dispatch them to the kernel.
virtual void apply();
/// set the params before show or update.
@ -79,8 +79,9 @@ protected:
/// clean-up on hide.
virtual void clearParams();
private:
///
LyXFont * font_;
///
bool toggleall_;
};

View File

@ -45,7 +45,7 @@ ControlCitation::ControlCitation(LyXView & lv, Dialogs & d)
}
void ControlCitation::clearParams()
void ControlCitation::clearDaughterParams()
{
bibkeysInfo_.clear();
}

View File

@ -55,8 +55,8 @@ public:
Empty if no info exists. */
string const getBibkeyInfo(string const &);
private:
/// Clean up, then hide dialog.
virtual void clearParams();
/// clean-up any daughter class-particular data on hide.
virtual void clearDaughterParams();
/// The info associated with each key
InfoMap bibkeysInfo_;
};

View File

@ -1,4 +1,3 @@
// -*- C++ -*-
/* This file is part of
* ======================================================
*
@ -19,95 +18,39 @@
#include <config.h>
#include "ControlCommand.h"
#include "BufferView.h"
#include "buffer.h"
#include "Dialogs.h"
#include "lyxfunc.h"
#include "LyXView.h"
#include "support/LAssert.h"
ControlCommand::ControlCommand(LyXView & lv, Dialogs & d, kb_action ac)
: ControlInset<InsetCommand>(lv, d),
params_(0), action_(ac)
: ControlInset<InsetCommand, InsetCommandParams>(lv, d),
action_(ac)
{}
void ControlCommand::showInset(InsetCommand * inset)
InsetCommandParams const ControlCommand::getParams(string const & arg)
{
if (inset == 0) return; // maybe we should Assert this?
connectInset(inset);
show(inset->params());
}
void ControlCommand::createInset(string const & arg)
{
connectInset();
if ( !arg.empty() )
bc().valid(); // so that the user can press Ok
InsetCommandParams params;
params.setFromString(arg);
show(params);
return params;
}
void ControlCommand::update()
InsetCommandParams const ControlCommand::getParams(InsetCommand const & inset)
{
if (params_) delete params_;
if (inset_)
params_ = new InsetCommandParams(inset_->params());
else
params_ = new InsetCommandParams;
bc().readOnly(isReadonly());
view().update();
return inset.params();
}
void ControlCommand::show(InsetCommandParams const & params)
void ControlCommand::applyParamsToInset()
{
if (params_) delete params_;
params_ = new InsetCommandParams(params);
bc().readOnly(isReadonly());
view().show();
inset()->setParams(params());
lv_.view()->updateInset(inset(), true);
}
void ControlCommand::hide()
void ControlCommand::applyParamsNoInset()
{
if (params_) {
delete params_;
params_ = 0;
}
if (action_ == LFUN_NOACTION) return;
clearParams();
disconnect();
view().hide();
}
InsetCommandParams & ControlCommand::params() const
{
Assert(params_);
return *params_;
}
void ControlCommand::apply()
{
view().apply();
if (inset_) {
// Only update if contents have changed
if (params() != inset_->params()) {
inset_->setParams(params());
lv_.view()->updateInset(inset_, true);
}
} else if (action_ != LFUN_NOACTION){
lv_.getLyXFunc()->Dispatch(action_, params().getAsString());
}
}

View File

@ -1,4 +1,3 @@
// -*- C++ -*-
/* This file is part of
* ======================================================
*
@ -27,49 +26,29 @@
#pragma interface
#endif
#include "ControlDialogs.h"
#include "ControlInset.h"
#include "insets/insetcommand.h"
#include "commandtags.h" // kb_action
/** The Inset dialog controller. Connects/disconnects signals, launches
GUI-dependent View and returns the output from this View to the kernel.
*/
class ControlCommand : public ControlInset<InsetCommand>
class ControlCommand : public ControlInset<InsetCommand, InsetCommandParams>
{
public:
///
ControlCommand(LyXView &, Dialogs &, kb_action=LFUN_NOACTION);
/// Allow the View access to the local copy.
InsetCommandParams & params() const;
protected:
/// Slots connected in the daughter classes c-tor.
/// Slot launching dialog to (possibly) create a new inset.
void createInset(string const &);
/// Slot launching dialog to an existing inset.
void showInset(InsetCommand *);
/// Connect signals and launch View.
void show(InsetCommandParams const &);
/// Instantiation of private ControlBase virtual methods.
/// Get changed parameters and Dispatch them to the kernel.
virtual void apply();
/// Disconnect signals and hide View.
virtual void hide();
/// Update dialog before showing it.
virtual void update();
/// clean-up on hide.
virtual void clearParams() {}
private:
/** A local copy of the inset's params.
Memory is allocated only whilst the dialog is visible.
*/
InsetCommandParams * params_;
/// Dispatch the changed parameters to the kernel.
virtual void applyParamsToInset();
///
virtual void applyParamsNoInset();
/// get the parameters from the string passed to createInset.
virtual InsetCommandParams const getParams(string const &);
/// get the parameters from the inset passed to showInset.
virtual InsetCommandParams const getParams(InsetCommand const &);
/// Controls what is done in LyXFunc::Dispatch()
kb_action const action_;
};

View File

@ -108,17 +108,17 @@ public:
protected:
///
virtual bool isBufferDependent() const { return true; }
/** Slot connected to update signal.
Bool indicates if a buffer switch took place.
Default behaviour is to ignore this and simply update().
*/
virtual void updateSlot(bool) { update(); }
/// Connect signals
virtual void connect();
/// Disconnect signals
virtual void disconnect();
private:
/** Slot connected to update signal.
Bool indicates if a buffer switch took place.
Default behaviour is to ignore this and simply update().
*/
virtual void updateSlot(bool) { update(); }
/// Update connection.
SigC::Connection u_;
};

View File

@ -10,33 +10,16 @@
* \file ControlDialogs.h
* \author Angus Leeming <a.leeming@ic.ac.uk>
*
* ControlDialogs.h contains the definition of two template controller classes,
* ControlDialog and ControlInset, rather clumsy names for classes that
* control the showing, updating and hiding of popups.
*
* ControlInset is to be used as a parent class for popups that display and
* can perhaps modify the contents of an individual inset. An example being the
* ubiquitous Citation popup.
*
* ControlDialog is to be used as a parent class for popups that are not
* Inset-popups. (An ugly description I know, but I hope the meaning is clear!
* Can anyone do any better?) Examples would be the Document and Paragraph
* popups.
*
* At the moment, ControlDialog is reaching a state of maturity as several
* controllers are now derived from it and its required functionality
* becaomes clear.
*
* ControlInset is still in a state of flux as currently only InsetCommand-type
* insets have a controller.
*
*/
#ifndef CONTROLCONNECTIONS2_H
#define CONTROLCONNECTIONS2_H
#ifndef CONTROLDIALOGS_H
#define CONTROLDIALOGS_H
#include "ControlConnections.h"
#include "LyXView.h"
/** Base class to control connection/disconnection of signals with the LyX
kernel for dialogs NOT used with insets.
@ -57,46 +40,14 @@ protected:
/// Update the dialog.
virtual void update();
/// set the params before show or update
virtual void setParams() {}
/// clean-up on hide.
virtual void clearParams() {}
/// set the params before show or update
virtual void setParams() {}
};
/** Base class to control connection/disconnection of signals with the LyX
kernel for Inset dialogs.
*/
class Inset;
template <class Inset>
class ControlInset : public ControlConnectBD
{
public:
///
ControlInset(LyXView &, Dialogs &);
protected:
/// Slot connected to update signal.
virtual void updateSlot(bool);
/// Connect signals
void connectInset(Inset * = 0);
/// Disconnect signals
virtual void disconnect();
///
void disconnectInset();
protected:
/// pointer to the inset passed through connectInset
Inset * inset_;
private:
/// inset::hide connection.
SigC::Connection ih_;
};
#include "LyXView.h"
template <class Base>
@ -138,56 +89,4 @@ void ControlDialog<Base>::hide()
view().hide();
}
template <class Inset>
ControlInset<Inset>::ControlInset(LyXView & lv, Dialogs & d)
: ControlConnectBD(lv, d),
inset_(0), ih_(0)
{}
template <class Inset>
void ControlInset<Inset>::updateSlot(bool switched)
{
if (switched)
hide();
else
update();
}
template <class Inset>
void ControlInset<Inset>::disconnect()
{
inset_ = 0;
ih_.disconnect();
ControlConnectBD::disconnect();
}
template <class Inset>
void ControlInset<Inset>::connectInset(Inset * inset)
{
// If connected to another inset, disconnect from it.
if (inset_) {
ih_.disconnect();
inset_ = 0;
}
if (inset) {
inset_ = inset;
ih_ = inset->hideDialog.connect(
SigC::slot(this, &ControlInset::hide));
}
connect();
}
template <class Inset>
void ControlInset<Inset>::disconnectInset()
{
ih_.disconnect();
}
#endif // CONTROLCONNECTIONS2_H
#endif // CONTROLDIALOGS_H

View File

@ -0,0 +1,38 @@
/* This file is part of
* ======================================================
*
* LyX, The Document Processor
*
* Copyright 2001 The LyX Team.
*
* ======================================================
*
* \file ControlError.C
* \author Angus Leeming <a.leeming@ic.ac.uk>
*/
#ifdef __GNUG__
#pragma implementation
#endif
#include <config.h>
#include "ControlError.h"
#include "Dialogs.h"
#include "LyXView.h"
#include "buffer.h"
#include "insets/inseterror.h"
using SigC::slot;
ControlError::ControlError(LyXView & lv, Dialogs & d)
: ControlInset<InsetError, string>(lv, d)
{
d_.showError.connect(slot(this, &ControlError::showInset));
}
string const ControlError::getParams(InsetError const & inset)
{
return inset.getContents();
}

View File

@ -0,0 +1,47 @@
/*
* \file ControlError.h
* This file is part of
* ======================================================
*
* LyX, The Document Processor
*
* Copyright 2000-2001 The LyX Team.
*
* ======================================================
*
* \author Angus Leeming, a.leeming@.ac.uk
*/
#ifndef CONTROLERROR_H
#define CONTROLERROR_H
#ifdef __GNUG__
#pragma interface
#endif
#include "ControlInset.h"
class InsetError;
/** A controller for LaTeX Error dialogs.
*/
class ControlError : public ControlInset<InsetError, string>
{
public:
///
ControlError(LyXView &, Dialogs &);
private:
/// not needed.
virtual void applyParamsToInset() {}
///
virtual void applyParamsNoInset() {}
///
virtual void clearDaughterParams() {}
/// get the parameters from the string passed to createInset.
virtual string const getParams(string const &) { return string(); }
/// get the parameters from the inset passed to showInset.
virtual string const getParams(InsetError const &);
};
#endif // CONTROLERROR_H

View File

@ -0,0 +1,40 @@
/**
* \file ControlInclude.C
* Copyright 2001 the LyX Team
* Read the file COPYING
*
* \author Alejandro Aguilar Sierra
* \author John Levon, moz@compsoc.man.ac.uk
* \author Angus Leeming, a.leeming@.ac.uk
*/
#ifdef __GNUG__
#pragma implementation
#endif
#include <config.h>
#include "ControlInclude.h"
#include "buffer.h"
#include "Dialogs.h"
#include "lyxfunc.h"
#include "LyXView.h"
using SigC::slot;
ControlInclude::ControlInclude(LyXView & lv, Dialogs & d)
: ControlInset<InsetInclude, InsetInclude::Params>(lv, 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);
}

View File

@ -0,0 +1,47 @@
/**
* \file ControlInclude.h
* Copyright 2001 the LyX Team
* See the file COPYING
*
* \author Alejandro Aguilar Sierra
* \author John Levon, moz@compsoc.man.ac.uk
* \author Angus Leeming, a.leeming@.ac.uk
*/
#ifndef CONTROLINCLUDE_H
#define CONTROLINCLUDE_H
#ifdef __GNUG__
#pragma interface
#endif
#include "ControlInset.h"
#include "insets/insetinclude.h" // InsetIncludeParams
/** A controller for the Include file dialog.
*/
class ControlInclude
: public ControlInset<InsetInclude, InsetInclude::Params>
{
public:
///
ControlInclude(LyXView &, Dialogs &);
/// The file dialog popup requires a LyXView * ???
LyXView * lv() const;
private:
/// Dispatch the changed parameters to the kernel.
virtual void applyParamsToInset();
/// Should be used but currently isn't
virtual void applyParamsNoInset() {}
/// not needed.
virtual void clearDaughterParams() {}
/// get the parameters from the string passed to createInset.
virtual InsetInclude::Params const getParams(string const &)
{ return InsetInclude::Params(); }
/// get the parameters from the inset passed to showInset.
virtual InsetInclude::Params const getParams(InsetInclude const & inset)
{ return inset.params(); }
};
#endif // CONTROLINCLUDE_H

View File

@ -0,0 +1,241 @@
/* This file is part of
* ======================================================
*
* LyX, The Document Processor
*
* Copyright 2001 The LyX Team.
*
* ======================================================
*
* \file ControlInsets.h
* \author Angus Leeming <a.leeming@ic.ac.uk>
*
* ControlInset is to be used as a parent class for popups that display and
* can perhaps modify the contents of an individual inset. An example being the
* ubiquitous Citation popup.
*/
#ifndef CONTROLINSET_H
#define CONTROLINSET_H
#include "ControlConnections.h"
class Inset;
template <class Inset, class Params>
class ControlInset : public ControlConnectBD
{
public:
///
ControlInset(LyXView &, Dialogs &);
/// Allow the View access to the local copy.
Params & params() const;
protected:
/// Slots connected in the daughter classes c-tor.
/// Slot launching dialog to (possibly) create a new inset.
void createInset(string const &);
/// Slot launching dialog to an existing inset.
void showInset(Inset * inset);
/// Allow the daughter methods to access the inset.
Inset * inset() const;
private:
/** These 5 methods are all that the individual daughter classes
should need to instantiate. */
/// if the inset exists then do this...
virtual void applyParamsToInset() = 0;
/// else this...
virtual void applyParamsNoInset() = 0;
/// clean-up any daughter class-particular data on hide.
virtual void clearDaughterParams() = 0;
/// get the parameters from the string passed to createInset.
virtual Params const getParams(string const &) = 0;
/// get the parameters from the inset passed to showInset.
virtual Params const getParams(Inset const &) = 0;
/// Instantiation of ControlBase virtual methods.
/// Get changed parameters and Dispatch them to the kernel.
virtual void apply();
/// Disconnect signals and hide View.
virtual void hide();
/// Update the dialog.
virtual void update();
/** Instantiation of ControlConnectBD private virtual method.
Slot connected to update signal. */
virtual void updateSlot(bool);
/// Show the dialog.
void show(Params const &);
/// Connect signals
void connectInset(Inset * = 0);
/// Disconnect signals
virtual void disconnect();
///
void disconnectInset();
/// pointer to the inset passed through connectInset
Inset * inset_;
/// inset::hide connection.
SigC::Connection ih_;
/** A local copy of the inset's params.
Memory is allocated only whilst the dialog is visible.
*/
Params * params_;
};
#include "LyXView.h"
#include "support/LAssert.h"
template <class Inset, class Params>
ControlInset<Inset, Params>::ControlInset(LyXView & lv, Dialogs & d)
: ControlConnectBD(lv, d),
inset_(0), ih_(0), params_(0)
{}
template <class Inset, class Params>
void ControlInset<Inset, Params>::showInset(Inset * inset)
{
if (inset == 0) return; // maybe we should Assert this?
connectInset(inset);
show(getParams(*inset));
}
template <class Inset, class Params>
void ControlInset<Inset, Params>::createInset(string const & arg)
{
connectInset();
if ( !arg.empty() )
bc().valid(); // so that the user can press Ok
show(getParams(arg));
}
template <class Inset, class Params>
void ControlInset<Inset, Params>::show(Params const & params)
{
if (params_) delete params_;
params_ = new Params(params);
bc().readOnly(isReadonly());
view().show();
}
template <class Inset, class Params>
void ControlInset<Inset, Params>::hide()
{
if (params_) {
delete params_;
params_ = 0;
}
clearDaughterParams();
disconnect();
view().hide();
}
template <class Inset, class Params>
void ControlInset<Inset, Params>::update()
{
if (params_) delete params_;
if (inset_)
params_ = new Params(getParams(*inset_));
else
params_ = new Params();
bc().readOnly(isReadonly());
view().update();
}
template <class Inset, class Params>
void ControlInset<Inset, Params>::apply()
{
if (lv_.buffer()->isReadonly() || !inset_)
return;
view().apply();
if (inset_ && params() != getParams(*inset_))
applyParamsToInset();
else if (!inset_)
applyParamsNoInset();
}
template <class Inset, class Params>
Params & ControlInset<Inset, Params>::params() const
{
Assert(params_);
return *params_;
}
template <class Inset, class Params>
Inset * ControlInset<Inset, Params>::inset() const
{
Assert(inset_);
return inset_;
}
template <class Inset, class Params>
void ControlInset<Inset, Params>::updateSlot(bool switched)
{
if (switched)
hide();
else
update();
}
template <class Inset, class Params>
void ControlInset<Inset, Params>::disconnect()
{
inset_ = 0;
ih_.disconnect();
ControlConnectBD::disconnect();
}
template <class Inset, class Params>
void ControlInset<Inset, Params>::connectInset(Inset * inset)
{
// If connected to another inset, disconnect from it.
if (inset_) {
ih_.disconnect();
inset_ = 0;
}
if (inset) {
inset_ = inset;
ih_ = inset->hideDialog.connect(
SigC::slot(this, &ControlInset::hide));
}
connect();
}
template <class Inset, class Params>
void ControlInset<Inset, Params>::disconnectInset()
{
ih_.disconnect();
}
#endif // CONTROLINSET_H

View File

@ -36,7 +36,7 @@ public:
std::pair<Buffer::LogType, string> const & logfile()
{ return logfile_; }
protected:
private:
///
virtual void apply() {}
/// set the params before show or update
@ -44,7 +44,6 @@ protected:
/// clean-up on hide.
virtual void clearParams();
private:
std::pair<Buffer::LogType, string> logfile_;
};

View File

@ -34,7 +34,7 @@ public:
///
string const & logfile() { return logfile_; }
protected:
private:
///
virtual void apply() {}
/// set the params before show or update
@ -42,7 +42,6 @@ protected:
/// clean-up on hide.
virtual void clearParams();
private:
string logfile_;
};

View File

@ -109,6 +109,34 @@ public:
};
/** Specialization for Error dialog
*/
class ControlError;
template <class GUIview, class GUIbc>
class GUIError :
public GUI<ControlError, GUIview, OkCancelPolicy, GUIbc> {
public:
///
GUIError(LyXView & lv, Dialogs & d)
: GUI<ControlError, GUIview, OkCancelPolicy, GUIbc>(lv, d) {}
};
/** Specialization for Include dialog
*/
class ControlInclude;
template <class GUIview, class GUIbc>
class GUIInclude :
public GUI<ControlInclude, GUIview, OkCancelReadOnlyPolicy, GUIbc> {
public:
///
GUIInclude(LyXView & lv, Dialogs & d)
: GUI<ControlInclude, GUIview, OkCancelReadOnlyPolicy, GUIbc>(lv, d) {}
};
/** Specialization for Log dialog
*/
class ControlLog;

View File

@ -29,9 +29,14 @@ libcontrollers_la_SOURCES=\
ControlConnections.C \
ControlConnections.h \
ControlCopyright.C \
ControlCopyright.h \
ControlCredits.h \
ControlCredits.C \
ControlCopyright.h \
ControlError.h \
ControlError.C \
ControlInclude.C \
ControlInclude.h \
ControlInset.h \
ControlLog.C \
ControlLog.h \
ControlVCLog.C \

View File

@ -1,3 +1,21 @@
2001-03-23 Angus Leeming <a.leeming@ic.ac.uk>
* FormError.[Ch]:
* form_error.fd:
* FormInclude.[Ch]:
* form_include.fd: implemented controller-view split.
* Dialogs.C: associated changes.
* FormBibitem.h:
* FormBibtex.h:
* FormCitation.h: moved methods from protected to private.
2001-03-23 Angus Leeming <a.leeming@ic.ac.uk>
* FormCredits.C (build): changes associated with
ControlCredits::getCredits returning a stringstream not a vector<string>
2001-03-22 Angus Leeming <a.leeming@ic.ac.uk>
* FormCopyright.[Ch]:

View File

@ -25,6 +25,8 @@
#include "ControlCitation.h"
#include "ControlCopyright.h"
#include "ControlCredits.h"
#include "ControlError.h"
#include "ControlInclude.h"
#include "ControlLog.h"
#include "ControlVCLog.h"
@ -38,6 +40,8 @@
#include "form_citation.h"
#include "form_copyright.h"
#include "form_credits.h"
#include "form_error.h"
#include "form_include.h"
#include "FormBibitem.h"
#include "FormBibtex.h"
@ -45,14 +49,14 @@
#include "FormCitation.h"
#include "FormCopyright.h"
#include "FormCredits.h"
#include "FormError.h"
#include "FormInclude.h"
#include "FormLog.h"
#include "FormVCLog.h"
#include "FormDocument.h"
#include "FormError.h"
#include "FormExternal.h"
#include "FormGraphics.h"
#include "FormInclude.h"
#include "FormIndex.h"
#include "FormMathsPanel.h"
#include "FormParagraph.h"
@ -82,14 +86,14 @@ Dialogs::Dialogs(LyXView * lv)
add(new GUICitation<FormCitation, xformsBC>(*lv, *this));
add(new GUICopyright<FormCopyright, xformsBC>(*lv, *this));
add(new GUICredits<FormCredits, xformsBC>(*lv, *this));
add(new GUIError<FormError, xformsBC>(*lv, *this));
add(new GUIInclude<FormInclude, xformsBC>(*lv, *this));
add(new GUILog<FormLog, xformsBC>(*lv, *this));
add(new GUIVCLog<FormVCLog, xformsBC>(*lv, *this));
add(new FormDocument(lv, this));
add(new FormError(lv, this));
add(new FormExternal(lv, this));
add(new FormGraphics(lv, this));
add(new FormInclude(lv, this));
add(new FormIndex(lv, this));
add(new FormMathsPanel(lv, this));
add(new FormParagraph(lv, this));

View File

@ -28,16 +28,13 @@ public:
///
FormBibitem(ControlBibitem &);
// Functions accessible to the Controller.
private:
/// Set the Params variable for the Controller.
virtual void apply();
/// Build the dialog.
virtual void build();
/// Update dialog before/whilst showing it.
virtual void update();
private:
/// Filter the inputs on callback from xforms
virtual ButtonPolicy::SMInput input(FL_OBJECT *, long);

View File

@ -28,16 +28,13 @@ public:
///
FormBibtex(ControlBibtex &);
// Functions accessible to the Controller.
private:
/// Set the Params variable for the Controller.
virtual void apply();
/// Build the dialog.
virtual void build();
/// Update dialog before/whilst showing it.
virtual void update();
private:
/// Filter the inputs on callback from xforms
virtual ButtonPolicy::SMInput input(FL_OBJECT *, long);
///

View File

@ -30,17 +30,6 @@ public:
///
FormCitation(ControlCitation &);
// Functions accessible to the Controller.
/// Set the Params variable for the Controller.
virtual void apply();
/// Build the dialog.
virtual void build();
/// Hide the dialog.
virtual void hide();
/// Update dialog before/whilst showing it.
virtual void update();
private:
///
enum State {
@ -50,6 +39,14 @@ private:
OFF
};
/// Set the Params variable for the Controller.
virtual void apply();
/// Build the dialog.
virtual void build();
/// Hide the dialog.
virtual void hide();
/// Update dialog before/whilst showing it.
virtual void update();
/// Filter the inputs on callback from xforms
virtual ButtonPolicy::SMInput input(FL_OBJECT *, long);

View File

@ -1,74 +1,34 @@
// -*- C++ -*-
/* This file is part of
/*
* \file FormError.C
* This file is part of
* ======================================================
*
* LyX, The Document Processor
*
* Copyright 2000 The LyX Team.
* Copyright 2000-2001 The LyX Team.
*
* ======================================================
*
* \author Angus Leeming, a.leeming@.ac.uk
*/
#include <config.h>
#ifdef __GNUG__
#pragma implementation
#endif
#include "Dialogs.h"
#include <config.h>
#include "xformsBC.h"
#include "ControlError.h"
#include "FormError.h"
#include "form_error.h"
#include "insets/inseterror.h"
#include "support/LAssert.h"
#include "xforms_helpers.h" // formatted
using SigC::slot;
typedef FormCB<ControlError, FormDB<FD_form_error> > base_class;
FormError::FormError(LyXView * lv, Dialogs * d)
: FormInset( lv, d, _("LaTeX Error")),
inset_(0)
{
Assert(lv && d);
// let the dialog be shown
// This is a permanent connection so we won't bother
// storing a copy because we won't be disconnecting.
d->showError.connect(slot(this, &FormError::showInset));
}
FL_FORM * FormError::form() const
{
if (dialog_.get()) return dialog_->form;
return 0;
}
void FormError::disconnect()
{
inset_ = 0;
message_.erase();
FormInset::disconnect();
}
void FormError::showInset(InsetError * inset)
{
if (inset == 0) return; // Is this _really_ allowed? (Lgb)
// If connected to another inset, disconnect from it.
if (inset_)
ih_.disconnect();
inset_ = inset;
message_ = inset->getContents();
ih_ = inset->hideDialog.connect(slot(this, &FormError::hide));
show();
}
void FormError::update()
{
fl_set_object_label(dialog_->message, message_.c_str());
}
FormError::FormError(ControlError & c)
: base_class(c, _("LaTeX Error"))
{}
void FormError::build()
@ -79,3 +39,11 @@ void FormError::build()
bc().setCancel(dialog_->button_cancel);
bc().refresh();
}
void FormError::update()
{
string const txt = formatted(controller().params(),
dialog_->message->w-10);
fl_set_object_label(dialog_->message, txt.c_str());
}

View File

@ -1,65 +1,46 @@
// -*- C++ -*-
/* This file is part of
/*
* \file FormError.h
* This file is part of
* ======================================================
*
* LyX, The Document Processor
*
* Copyright 2000 The LyX Team.
* Copyright 2000-2001 The LyX Team.
*
* ======================================================
*
* \author Angus Leeming, a.leeming@.ac.uk
*/
#ifndef FORMERROR_H
#define FORMERROR_H
#include <boost/smart_ptr.hpp>
#ifdef __GNUG__
#pragma interface
#endif
#include "FormInset.h"
#include "FormBase.h"
class InsetError;
class ControlError;
struct FD_form_error;
/** This class provides an XForms implementation of the FormError Dialog.
/** This class provides an XForms implementation of the Error Dialog.
*/
class FormError : public FormInset {
class FormError : public FormCB<ControlError, FormDB<FD_form_error> > {
public:
/// Constructor
FormError(LyXView *, Dialogs *);
private:
/// Pointer to the actual instantiation of the ButtonController.
virtual xformsBC & bc();
/// Disconnect signals. Also perform any necessary housekeeping.
virtual void disconnect();
FormError(ControlError &);
/// Slot launching dialog to an existing inset
void showInset(InsetError *);
/// Update dialog before showing it
virtual void update();
private:
/// not needed.
virtual void apply() {}
/// Build the dialog
virtual void build();
/// Pointer to the actual instantiation of the xforms form
virtual FL_FORM * form() const;
/// Update dialog before showing it
virtual void update();
/// Fdesign generated method
FD_form_error * build_error();
/// Real GUI implementation.
boost::scoped_ptr<FD_form_error> dialog_;
/// pointer to the inset passed through showInset
InsetError * inset_;
/// the error message
string message_;
/// The ButtonController
ButtonController<OkCancelPolicy, xformsBC> bc_;
};
inline
xformsBC & FormError::bc()
{
return bc_;
}
#endif
#endif // FORMERROR_H

View File

@ -4,9 +4,10 @@
* Read the file COPYING
*
* \author Alejandro Aguilar Sierra
* \author John Levon
* \author John Levon, moz@compsoc.man.ac.uk
* \author Angus Leeming, a.leeming@.ac.uk
*/
#include <config.h>
#include <algorithm>
#include <utility>
@ -14,65 +15,30 @@
#pragma implementation
#endif
#include "Dialogs.h"
#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 "support/filetools.h"
#include "support/lstrings.h"
#include "LyXView.h"
#include "buffer.h"
#include "lyxrc.h"
#include "lyxfunc.h"
#include "xforms_helpers.h"
#include "form_include.h"
#include "xforms_helpers.h" // setEnabled
#include "support/filetools.h"
#include "support/lstrings.h"
#include "lyxrc.h"
using std::make_pair;
using std::pair;
using SigC::slot;
FormInclude::FormInclude(LyXView * lv, Dialogs * d)
: FormBaseBD(lv, d, _("Include file")),
ih_(0), inset_(0)
{
d->showInclude.connect(slot(this, &FormInclude::showInclude));
}
typedef FormCB<ControlInclude, FormDB<FD_form_include> > base_class;
FL_FORM * FormInclude::form() const
{
if (dialog_.get())
return dialog_->form;
return 0;
}
void FormInclude::connect()
{
u_ = d_->updateBufferDependent.
connect(slot(this, &FormInclude::updateSlot));
h_ = d_->hideBufferDependent.
connect(slot(this, &FormInclude::hide));
FormBaseDeprecated::connect();
}
void FormInclude::disconnect()
{
ih_.disconnect();
FormBaseBD::disconnect();
inset_ = 0;
}
void FormInclude::updateSlot(bool switched)
{
if (switched)
hide();
else
update();
}
FormInclude::FormInclude(ControlInclude & c)
: base_class(c, _("Include file"))
{}
void FormInclude::build()
@ -80,36 +46,21 @@ void FormInclude::build()
dialog_.reset(build_include());
// Manage the ok and cancel buttons
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_->button_browse);
bc_.addReadOnly(dialog_->check_verbatim);
bc_.addReadOnly(dialog_->check_typeset);
bc_.addReadOnly(dialog_->check_useinput);
bc_.addReadOnly(dialog_->check_useinclude);
}
void FormInclude::showInclude(InsetInclude * inset)
{
// If connected to another inset, disconnect from it.
if (inset_)
ih_.disconnect();
inset_ = inset;
params = inset->params();
ih_ = inset->hideDialog.connect(slot(this, &FormInclude::hide));
show();
bc().addReadOnly(dialog_->button_browse);
bc().addReadOnly(dialog_->check_verbatim);
bc().addReadOnly(dialog_->check_typeset);
bc().addReadOnly(dialog_->check_useinput);
bc().addReadOnly(dialog_->check_useinclude);
}
void FormInclude::update()
{
bc().readOnly(lv_->buffer()->isReadonly());
if (!inset_) {
if (controller().params().noload) {
fl_set_input(dialog_->input_filename, "");
fl_set_button(dialog_->check_typeset, 0);
fl_set_button(dialog_->check_useinput, 0);
@ -121,11 +72,13 @@ void FormInclude::update()
return;
}
fl_set_input(dialog_->input_filename, params.cparams.getContents().c_str());
fl_set_input(dialog_->input_filename,
controller().params().cparams.getContents().c_str());
string const cmdname = params.cparams.getCmdName();
string const cmdname = controller().params().cparams.getCmdName();
fl_set_button(dialog_->check_typeset, int(params.noload));
fl_set_button(dialog_->check_typeset,
int(controller().params().noload));
fl_set_button(dialog_->check_useinput, cmdname == "input");
fl_set_button(dialog_->check_useinclude, cmdname == "include");
@ -145,45 +98,61 @@ void FormInclude::update()
void FormInclude::apply()
{
if (lv_->buffer()->isReadonly())
return;
controller().params().noload = fl_get_button(dialog_->check_typeset);
params.noload = fl_get_button(dialog_->check_typeset);
params.cparams.setContents(fl_get_input(dialog_->input_filename));
controller().params().cparams.
setContents(fl_get_input(dialog_->input_filename));
if (fl_get_button(dialog_->check_useinput))
params.flag = InsetInclude::INPUT;
controller().params().flag = InsetInclude::INPUT;
else if (fl_get_button(dialog_->check_useinclude))
params.flag = InsetInclude::INCLUDE;
controller().params().flag = InsetInclude::INCLUDE;
else if (fl_get_button(dialog_->check_verbatim)) {
if (fl_get_button(dialog_->check_visiblespace))
params.flag = InsetInclude::VERBAST;
controller().params().flag = InsetInclude::VERBAST;
else
params.flag = InsetInclude::VERB;
controller().params().flag = InsetInclude::VERB;
}
inset_->setFromParams(params);
lv_->view()->updateInset(inset_, true);
}
#ifdef WITH_WARNINGS
#warning convert this to use the buttoncontroller
#endif
bool FormInclude::input(FL_OBJECT *, long data)
{
State state = static_cast<State>(data);
switch (state) {
case BROWSE: {
ButtonPolicy::SMInput FormInclude::input(FL_OBJECT * ob, long)
{
if (ob == dialog_->button_browse)
return inputBrowse();
if (ob == dialog_->button_load) {
if (compare(fl_get_input(dialog_->input_filename),"")) {
ApplyButton();
return ButtonPolicy::SMI_NOOP;
}
}
if (ob == dialog_->check_verbatim) {
setEnabled(dialog_->check_visiblespace, true);
} else if (ob == dialog_->check_useinclude ||
ob == dialog_->check_useinput) {
fl_set_button(dialog_->check_visiblespace, 0);
setEnabled(dialog_->check_visiblespace, false);
}
return ButtonPolicy::SMI_VALID;
}
ButtonPolicy::SMInput FormInclude::inputBrowse()
{
// Should browsing too be disabled in RO-mode?
FileDialog fileDlg(lv_, _("Select document to include"),
FileDialog fileDlg(controller().lv(),
_("Select document to include"),
LFUN_SELECT_FILE_SYNC,
make_pair(string(_("Documents")), string(lyxrc.document_path)));
make_pair(string(_("Documents")),
string(lyxrc.document_path)));
string ext;
/* input TeX, verbatim, or LyX file ? */
// 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))
@ -191,15 +160,16 @@ bool FormInclude::input(FL_OBJECT *, long data)
else
ext = _("*.lyx| LyX Documents (*.lyx)");
string mpath;
string const mpath =
OnlyPath(controller().params().masterFilename_);
mpath = OnlyPath(params.buffer->fileName());
FileDialog::Result result = fileDlg.Select(mpath, ext, fl_get_input(dialog_->input_filename));
FileDialog::Result const result =
fileDlg.Select(mpath, ext,
fl_get_input(dialog_->input_filename));
// check selected filename
if (result.second.empty())
break;
return ButtonPolicy::SMI_NOOP;
string const filename2 = MakeRelPath(result.second, mpath);
@ -208,23 +178,5 @@ bool FormInclude::input(FL_OBJECT *, long data)
else
fl_set_input(dialog_->input_filename, filename2.c_str());
} break;
case LOAD:
if (compare(fl_get_input(dialog_->input_filename),"")) {
apply();
lv_->getLyXFunc()->Dispatch(LFUN_CHILDOPEN, params.cparams.getContents());
}
break;
case VERBATIM:
setEnabled(dialog_->check_visiblespace, true);
break;
case INPUTINCLUDE:
fl_set_button(dialog_->check_visiblespace, 0);
setEnabled(dialog_->check_visiblespace, false);
break;
}
return true;
return ButtonPolicy::SMI_VALID;
}

View File

@ -5,86 +5,42 @@
* See the file COPYING
*
* \author Alejandro Aguilar Sierra
* \author John Levon
* \author John Levon, moz@compsoc.man.ac.uk
* \author Angus Leeming <a.leeming@ic.ac.uk>
*/
#ifndef FORMINCLUDE_H
#define FORMINCLUDE_H
#include <boost/smart_ptr.hpp>
#ifdef __GNUG__
#pragma interface
#endif
#include "FormBaseDeprecated.h"
#include "insets/insetinclude.h"
#include "FormBase.h"
class ControlInclude;
struct FD_form_include;
/** This class provides an XForms implementation of the FormInclude Dialog.
/** This class provides an XForms implementation of the Include Dialog.
*/
class FormInclude : public FormBaseBD {
class FormInclude : public FormCB<ControlInclude, FormDB<FD_form_include> > {
public:
///
FormInclude(LyXView *, Dialogs *);
FormInclude(ControlInclude &);
private:
///
enum State {
/// the browse button
BROWSE = 0,
/// the load file button
LOAD = 5,
/// the verbatim radio choice
VERBATIM = 10,
/// the input and include radio choices
INPUTINCLUDE = 11
};
/// Pointer to the actual instantiation of the ButtonController.
virtual xformsBC & bc();
/// Slot launching dialog to an existing inset
void showInclude(InsetInclude *);
/// Connect signals. Also perform any necessary initialisation.
virtual void connect();
/// Disconnect signals. Also perform any necessary housekeeping.
virtual void disconnect();
/// Set the Params variable for the Controller.
virtual void apply();
/// Build the dialog
virtual void build();
/// Filter the inputs
virtual bool input( FL_OBJECT *, long );
/// Update dialog before showing it
virtual void update();
/// Apply from dialog (modify or create inset)
virtual void apply();
/// Pointer to the actual instantiation of the xforms form
virtual FL_FORM * form() const;
/// bool indicates if a buffer switch took place
virtual void updateSlot(bool);
/// Filter the inputs on callback from xforms
virtual ButtonPolicy::SMInput input(FL_OBJECT *, long);
///
ButtonPolicy::SMInput inputBrowse();
/// Type definition from the fdesign produced header file.
FD_form_include * build_include();
/// Real GUI implementation.
boost::scoped_ptr<FD_form_include> dialog_;
/// The ButtonController
ButtonController<OkCancelReadOnlyPolicy, xformsBC> bc_;
/// inset::hide connection.
SigC::Connection ih_;
/// pointer to the inset passed through showInset
InsetInclude * inset_;
/// the nitty-gritty. What is modified and passed back
InsetInclude::InsetIncludeParams params;
};
inline
xformsBC & FormInclude::bc()
{
return bc_;
}
#endif

View File

@ -34,7 +34,7 @@ FD_form_error * FormError::build_error()
}
fl_set_object_gravity(obj, FL_South, FL_South);
fl_set_object_resize(obj, FL_RESIZE_NONE);
fl_set_object_callback(obj, C_FormBaseDeprecatedCancelCB, 0);
fl_set_object_callback(obj, C_FormBaseCancelCB, 0);
fl_end_form();
fdui->form->fdui = fdui;

View File

@ -5,7 +5,7 @@
#define FD_form_error_h_
/** Callbacks, globals and object handlers **/
extern "C" void C_FormBaseDeprecatedCancelCB(FL_OBJECT *, long);
extern "C" void C_FormBaseCancelCB(FL_OBJECT *, long);
/**** Forms and Objects ****/

View File

@ -32,7 +32,7 @@ FD_form_include * FormInclude::build_include()
fl_set_button_shortcut(obj, scex(_(dummy)), 1);
}
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
fl_set_object_callback(obj, C_FormBaseDeprecatedInputCB, 0);
fl_set_object_callback(obj, C_FormBaseInputCB, 0);
{
char const * const dummy = N_("Don't typeset|#D");
fdui->check_typeset = obj = fl_add_checkbutton(FL_PUSH_BUTTON, 180, 70, 150, 30, idex(_(dummy)));
@ -41,21 +41,21 @@ FD_form_include * FormInclude::build_include()
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
fdui->button_ok = obj = fl_add_button(FL_RETURN_BUTTON, 120, 170, 100, 30, _("OK"));
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
fl_set_object_callback(obj, C_FormBaseDeprecatedOKCB, 1);
fl_set_object_callback(obj, C_FormBaseOKCB, 0);
{
char const * const dummy = N_("Cancel|^[");
fdui->button_cancel = obj = fl_add_button(FL_NORMAL_BUTTON, 230, 170, 100, 30, idex(_(dummy)));
fl_set_button_shortcut(obj, scex(_(dummy)), 1);
}
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
fl_set_object_callback(obj, C_FormBaseDeprecatedCancelCB, 2);
fl_set_object_callback(obj, C_FormBaseCancelCB, 0);
{
char const * const dummy = N_("Load|#L");
fdui->button_load = obj = fl_add_button(FL_NORMAL_BUTTON, 230, 130, 100, 30, idex(_(dummy)));
fl_set_button_shortcut(obj, scex(_(dummy)), 1);
}
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
fl_set_object_callback(obj, C_FormBaseDeprecatedInputCB, 5);
fl_set_object_callback(obj, C_FormBaseInputCB, 0);
{
char const * const dummy = N_("File name:|#F");
fdui->input_filename = obj = fl_add_input(FL_NORMAL_INPUT, 10, 30, 210, 30, idex(_(dummy)));
@ -77,21 +77,21 @@ FD_form_include * FormInclude::build_include()
fl_set_button_shortcut(obj, scex(_(dummy)), 1);
}
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
fl_set_object_callback(obj, C_FormBaseDeprecatedInputCB, 10);
fl_set_object_callback(obj, C_FormBaseInputCB, 0);
{
char const * const dummy = N_("Use input|#i");
fdui->check_useinput = obj = fl_add_checkbutton(FL_RADIO_BUTTON, 10, 100, 160, 30, idex(_(dummy)));
fl_set_button_shortcut(obj, scex(_(dummy)), 1);
}
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
fl_set_object_callback(obj, C_FormBaseDeprecatedInputCB, 11);
fl_set_object_callback(obj, C_FormBaseInputCB, 0);
{
char const * const dummy = N_("Use include|#U");
fdui->check_useinclude = obj = fl_add_checkbutton(FL_RADIO_BUTTON, 10, 70, 160, 30, idex(_(dummy)));
fl_set_button_shortcut(obj, scex(_(dummy)), 1);
}
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
fl_set_object_callback(obj, C_FormBaseDeprecatedInputCB, 11);
fl_set_object_callback(obj, C_FormBaseInputCB, 0);
fl_end_group();
fl_end_form();

View File

@ -5,9 +5,9 @@
#define FD_form_include_h_
/** Callbacks, globals and object handlers **/
extern "C" void C_FormBaseDeprecatedInputCB(FL_OBJECT *, long);
extern "C" void C_FormBaseDeprecatedOKCB(FL_OBJECT *, long);
extern "C" void C_FormBaseDeprecatedCancelCB(FL_OBJECT *, long);
extern "C" void C_FormBaseInputCB(FL_OBJECT *, long);
extern "C" void C_FormBaseOKCB(FL_OBJECT *, long);
extern "C" void C_FormBaseCancelCB(FL_OBJECT *, long);
/**** Forms and Objects ****/

View File

@ -63,7 +63,7 @@ shortcut:
resize: FL_RESIZE_NONE
gravity: FL_South FL_South
name: button_cancel
callback: C_FormBaseDeprecatedCancelCB
callback: C_FormBaseCancelCB
argument: 0
==============================

View File

@ -63,8 +63,8 @@ shortcut:
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: button_browse
callback: C_FormBaseDeprecatedInputCB
argument: 0
callback: C_FormBaseInputCB
argument:
--------------------
class: FL_CHECKBUTTON
@ -99,8 +99,8 @@ shortcut: ^M
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: button_ok
callback: C_FormBaseDeprecatedOKCB
argument: 1
callback: C_FormBaseOKCB
argument:
--------------------
class: FL_BUTTON
@ -117,8 +117,8 @@ shortcut:
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: button_cancel
callback: C_FormBaseDeprecatedCancelCB
argument: 2
callback: C_FormBaseCancelCB
argument:
--------------------
class: FL_BUTTON
@ -135,8 +135,8 @@ shortcut:
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: button_load
callback: C_FormBaseDeprecatedInputCB
argument: 5
callback: C_FormBaseInputCB
argument:
--------------------
class: FL_INPUT
@ -207,8 +207,8 @@ shortcut:
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: check_verbatim
callback: C_FormBaseDeprecatedInputCB
argument: 10
callback: C_FormBaseInputCB
argument:
--------------------
class: FL_CHECKBUTTON
@ -225,8 +225,8 @@ shortcut:
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: check_useinput
callback: C_FormBaseDeprecatedInputCB
argument: 11
callback: C_FormBaseInputCB
argument:
--------------------
class: FL_CHECKBUTTON
@ -243,8 +243,8 @@ shortcut:
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: check_useinclude
callback: C_FormBaseDeprecatedInputCB
argument: 11
callback: C_FormBaseInputCB
argument:
--------------------
class: FL_END_GROUP

View File

@ -1,3 +1,9 @@
2001-03-23 Angus Leeming <a.leeming@ic.ac.uk>
* insetinclude.[Ch]: rename InsetInclude::InsetIncludeParams as
InsetInclude::Params. Don't store a buffer * in Params. Store the
master file name instead.
2001-03-23 Juergen Vigna <jug@sad.it>
* insetcollapsable.C (InsetMotionNotify):

View File

@ -31,8 +31,8 @@ extern BufferList bufferlist;
namespace {
inline
string const unique_id() {
string const unique_id()
{
static unsigned int seed = 1000;
std::ostringstream ost;
@ -45,19 +45,16 @@ string const unique_id() {
} // namespace anon
InsetInclude::InsetInclude(InsetIncludeParams const & p)
{
include_label = unique_id();
setFromParams(p);
params_.buffer = p.buffer;
}
InsetInclude::InsetInclude(Params const & p)
: params_(p), include_label(unique_id())
{}
InsetInclude::InsetInclude(InsetCommandParams const & p, Buffer const & b)
{
params_.cparams = p;
params_.masterFilename_ = b.fileName();
include_label = unique_id();
params_.buffer = &b;
setFromParams(p);
}
@ -67,21 +64,33 @@ InsetInclude::~InsetInclude()
}
InsetInclude::InsetIncludeParams const & InsetInclude::params() const
InsetInclude::Params const & InsetInclude::params() const
{
return params_;
}
void InsetInclude::setFromParams(InsetIncludeParams const & p)
bool InsetInclude::Params::operator==(Params const & o) const
{
params_.cparams.setContents(p.cparams.getContents());
params_.noload = p.noload;
if (params_.flag == p.flag)
return;
if (cparams == o.cparams && flag == o.flag &&
noload == o.noload && masterFilename_ == o.masterFilename_)
return true;
params_.flag = p.flag;
return false;
}
bool InsetInclude::Params::operator!=(Params const & o) const
{
return !(*this == o);
}
void InsetInclude::set(Params const & p)
{
params_ = p;
// Just to be safe...
string command;
switch (params_.flag) {
@ -105,10 +114,10 @@ void InsetInclude::setFromParams(InsetIncludeParams const & p)
Inset * InsetInclude::Clone(Buffer const & buffer) const
{
InsetIncludeParams p(params_);
p.buffer = &buffer;
Params p(params_);
p.masterFilename_ = buffer.fileName();
return new InsetInclude (p);
return new InsetInclude(p);
}
@ -184,7 +193,7 @@ string const InsetInclude::getFileName() const
string const InsetInclude::getMasterFilename() const
{
return params_.buffer->fileName();
return params_.masterFilename_;
}
@ -367,11 +376,11 @@ void InsetInclude::Validate(LaTeXFeatures & features) const
string incfile(params_.cparams.getContents());
string writefile;
Buffer const & b = *params_.buffer;
Buffer const * const b = bufferlist.getBuffer(getMasterFilename());
if (!b.tmppath.empty() && b.niceFile) {
if (b && !b->tmppath.empty() && b->niceFile) {
incfile = subst(incfile, '/','@');
writefile = AddName(b.tmppath, incfile);
writefile = AddName(b->tmppath, incfile);
} else
writefile = getFileName();
@ -388,7 +397,8 @@ void InsetInclude::Validate(LaTeXFeatures & features) const
// to be loaded:
if (loadIfNeeded()) {
// a file got loaded
Buffer * tmp = bufferlist.getBuffer(getFileName());
Buffer const * const tmp = bufferlist.getBuffer(getFileName());
if (tmp)
tmp->validate(features);
}
}

View File

@ -27,9 +27,9 @@ struct LaTeXFeatures;
class InsetInclude: public InsetButton, public boost::noncopyable {
public:
/// the type of inclusion
enum IncludeFlags {
enum Flags {
///
INCLUDE= 0,
INCLUDE = 0,
///
VERB = 1,
///
@ -38,28 +38,35 @@ public:
VERBAST = 3
};
struct InsetIncludeParams {
InsetIncludeParams(InsetCommandParams const & cp = InsetCommandParams(),
IncludeFlags f = INCLUDE, bool nl = false, Buffer const * b = 0)
: cparams(cp), flag(f), noload(nl), buffer(b) {}
struct Params {
Params(InsetCommandParams const & cp = InsetCommandParams(),
Flags f = INCLUDE,
bool nl = false,
string const & name = string())
: cparams(cp), flag(f), noload(nl),
masterFilename_(name) {}
InsetCommandParams cparams;
IncludeFlags flag;
Flags flag;
bool noload;
Buffer const * buffer;
string masterFilename_;
///
bool operator==(Params const &) const;
///
bool operator!=(Params const &) const;
};
///
InsetInclude(InsetIncludeParams const &);
InsetInclude(Params const &);
///
InsetInclude(InsetCommandParams const &, Buffer const &);
///
~InsetInclude();
/// get the parameters
InsetIncludeParams const & params(void) const;
Params const & params(void) const;
/// set the parameters
void setFromParams(InsetIncludeParams const & params);
void set(Params const & params);
///
Inset * Clone(Buffer const &) const;
@ -118,7 +125,7 @@ private:
string const getFileName() const;
/// the parameters
InsetIncludeParams params_;
Params params_;
///
string include_label;
};