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))
* 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.
+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
#include "ControlBibitem.h"
#include "Dialogs.h"
#include "LyXView.h"
-#include "BufferView.h"
+#include "buffer.h"
using SigC::slot;
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(),
- params().getContents());
-
- 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());
- }
+ // FIXME:
+ // confirm, is this only necessary for FormBibTeX ???
+ if (params().getContents() != inset()->params().getContents())
+ lv_.view()->ChangeCitationsIfUnique(inset()->params().getContents(),
+ params().getContents());
+
+ 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());
}
///
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
#include "ControlBibtex.h"
#include "Dialogs.h"
#include "LyXView.h"
-#include "BufferView.h"
+#include "buffer.h"
using SigC::slot;
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(),
- params().getContents());
-
- 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());
- }
+ if (params().getContents() != inset()->params().getContents())
+ lv_.view()->ChangeCitationsIfUnique(inset()->params().getContents(),
+ params().getContents());
+
+ 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()
+{}
///
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
///
void setToggleAll(bool);
-protected:
+private:
/// Get changed parameters and Dispatch them to the kernel.
virtual void apply();
/// set the params before show or update.
/// clean-up on hide.
virtual void clearParams();
-private:
+ ///
LyXFont * font_;
+ ///
bool toggleall_;
};
}
-void ControlCitation::clearParams()
+void ControlCitation::clearDaughterParams()
{
bibkeysInfo_.clear();
}
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_;
};
-// -*- C++ -*-
/* This file is part of
* ======================================================
*
#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;
- }
-
- clearParams();
-
- disconnect();
- view().hide();
-}
+ if (action_ == LFUN_NOACTION) return;
-InsetCommandParams & ControlCommand::params() const
-{
- Assert(params_);
- return *params_;
+ lv_.getLyXFunc()->Dispatch(action_, params().getAsString());
}
-
-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());
- }
-}
-// -*- C++ -*-
/* This file is part of
* ======================================================
*
#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_;
};
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_;
};
* \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.
/// 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>
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
--- /dev/null
+/* 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();
+}
+
--- /dev/null
+/*
+ * \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
--- /dev/null
+/**
+ * \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);
+}
--- /dev/null
+/**
+ * \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
--- /dev/null
+/* 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
std::pair<Buffer::LogType, string> const & logfile()
{ return logfile_; }
-protected:
+private:
///
virtual void apply() {}
/// set the params before show or update
/// clean-up on hide.
virtual void clearParams();
-private:
std::pair<Buffer::LogType, string> logfile_;
};
///
string const & logfile() { return logfile_; }
-protected:
+private:
///
virtual void apply() {}
/// set the params before show or update
/// clean-up on hide.
virtual void clearParams();
-private:
string logfile_;
};
};
+/** 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;
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 \
+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]:
#include "ControlCitation.h"
#include "ControlCopyright.h"
#include "ControlCredits.h"
+#include "ControlError.h"
+#include "ControlInclude.h"
#include "ControlLog.h"
#include "ControlVCLog.h"
#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"
#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"
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));
///
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);
///
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);
///
///
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 {
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);
-// -*- 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"
-
-using SigC::slot;
-
-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;
-}
+#include "xforms_helpers.h" // formatted
+typedef FormCB<ControlError, FormDB<FD_form_error> > base_class;
-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()
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());
+}
-// -*- 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
* 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>
#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()
dialog_.reset(build_include());
// Manage the ok and cancel buttons
- 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().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::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);
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");
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)
+
+ButtonPolicy::SMInput FormInclude::input(FL_OBJECT * ob, long)
{
- State state = static_cast<State>(data);
+ 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;
+ }
+ }
- switch (state) {
- case BROWSE: {
- // Should browsing too be disabled in RO-mode?
- FileDialog fileDlg(lv_, _("Select document to include"),
- LFUN_SELECT_FILE_SYNC,
- make_pair(string(_("Documents")), string(lyxrc.document_path)));
+ if (ob == dialog_->check_verbatim) {
+ setEnabled(dialog_->check_visiblespace, true);
- 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)");
+ } else if (ob == dialog_->check_useinclude ||
+ ob == dialog_->check_useinput) {
+ fl_set_button(dialog_->check_visiblespace, 0);
+ setEnabled(dialog_->check_visiblespace, false);
+ }
- string mpath;
-
- mpath = OnlyPath(params.buffer->fileName());
-
- FileDialog::Result result = fileDlg.Select(mpath, ext, fl_get_input(dialog_->input_filename));
+ return ButtonPolicy::SMI_VALID;
+}
- // check selected filename
- if (result.second.empty())
- break;
+
+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 filename2 = MakeRelPath(result.second, mpath);
+ string const mpath =
+ OnlyPath(controller().params().masterFilename_);
+
+ FileDialog::Result const result =
+ fileDlg.Select(mpath, ext,
+ fl_get_input(dialog_->input_filename));
- if (prefixIs(filename2, ".."))
- fl_set_input(dialog_->input_filename, result.second.c_str());
- 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;
+ // check selected filename
+ if (result.second.empty())
+ return ButtonPolicy::SMI_NOOP;
- case INPUTINCLUDE:
- fl_set_button(dialog_->check_visiblespace, 0);
- setEnabled(dialog_->check_visiblespace, false);
- break;
- }
- return true;
+ 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;
}
* 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 *);
-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();
+ FormInclude(ControlInclude &);
+private:
+ /// 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
}
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;
#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 ****/
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)));
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)));
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();
#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 ****/
resize: FL_RESIZE_NONE
gravity: FL_South FL_South
name: button_cancel
-callback: C_FormBaseDeprecatedCancelCB
+callback: C_FormBaseCancelCB
argument: 0
==============================
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: button_browse
-callback: C_FormBaseDeprecatedInputCB
-argument: 0
+callback: C_FormBaseInputCB
+argument:
--------------------
class: FL_CHECKBUTTON
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: button_ok
-callback: C_FormBaseDeprecatedOKCB
-argument: 1
+callback: C_FormBaseOKCB
+argument:
--------------------
class: FL_BUTTON
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: button_cancel
-callback: C_FormBaseDeprecatedCancelCB
-argument: 2
+callback: C_FormBaseCancelCB
+argument:
--------------------
class: FL_BUTTON
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: button_load
-callback: C_FormBaseDeprecatedInputCB
-argument: 5
+callback: C_FormBaseInputCB
+argument:
--------------------
class: FL_INPUT
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: check_verbatim
-callback: C_FormBaseDeprecatedInputCB
-argument: 10
+callback: C_FormBaseInputCB
+argument:
--------------------
class: FL_CHECKBUTTON
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: check_useinput
-callback: C_FormBaseDeprecatedInputCB
-argument: 11
+callback: C_FormBaseInputCB
+argument:
--------------------
class: FL_CHECKBUTTON
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
+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):
namespace {
-inline
-string const unique_id() {
+string const unique_id()
+{
static unsigned int seed = 1000;
std::ostringstream ost;
} // 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);
}
}
-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;
+
+ return false;
+}
- params_.flag = p.flag;
- string command;
+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) {
- case INCLUDE:
- command="include";
- break;
- case VERB:
- command="verbatiminput";
- break;
- case INPUT:
- command="input";
- break;
- case VERBAST:
- command="verbatiminput*";
- break;
+ case INCLUDE:
+ command="include";
+ break;
+ case VERB:
+ command="verbatiminput";
+ break;
+ case INPUT:
+ command="input";
+ break;
+ case VERBAST:
+ command="verbatiminput*";
+ break;
}
-
+
params_.cparams.setCmdName(command);
}
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);
}
string const InsetInclude::getMasterFilename() const
{
- return params_.buffer->fileName();
+ return params_.masterFilename_;
}
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();
// to be loaded:
if (loadIfNeeded()) {
// a file got loaded
- Buffer * tmp = bufferlist.getBuffer(getFileName());
- tmp->validate(features);
+ Buffer const * const tmp = bufferlist.getBuffer(getFileName());
+ if (tmp)
+ tmp->validate(features);
}
}
class InsetInclude: public InsetButton, public boost::noncopyable {
public:
/// the type of inclusion
- enum IncludeFlags {
+ enum Flags {
///
- INCLUDE= 0,
+ INCLUDE = 0,
///
VERB = 1,
///
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;
///
Inset::Code LyxCode() const { return Inset::INCLUDE_CODE; }
string const getFileName() const;
/// the parameters
- InsetIncludeParams params_;
+ Params params_;
///
string include_label;
};