+2003-03-05 Angus Leeming <leeming@lyx.org>
+
+ * ui/default.ui: use 'dialog-show-new-inset "graphics"' instead
+ of graphics-insert'.
+
2003-03-06 Serge Winitzki <serge@cosmos.phy.tufts.edu>
* bind/sciword.bind: update for 1.3.x
Separator
Item "TeX|T" "ert-insert"
Item "Minipage|p" "minipage-insert"
- Item "Graphics...|G" "graphics-insert"
+ Item "Graphics...|G" "dialog-show-new-inset graphics"
Item "Tabular Material...|b" "tabular-insert"
Submenu "Floats|a" "insert_floats"
Separator
Icon "marginalnote-insert"
Icon "depth-increment"
Separator
- Icon "graphics-insert"
+ Icon "dialog-show-new-inset graphics"
Icon "tabular-insert"
End
// a tabular-inset
break;
- case LFUN_INSET_GRAPHICS:
- {
- Inset * new_inset = new InsetGraphics;
- if (!insertInset(new_inset)) {
- delete new_inset;
- } else {
- // this is need because you don't use a inset->Edit()
- updateInset(new_inset, true);
- new_inset->edit(bv_);
- }
- break;
- }
-
case LFUN_LAYOUT_COPY:
bv_->copyEnvironment();
break;
-2003-03-05 Angus Leeming <leeming@lyx.org>
+2003-03-07 Angus Leeming <leeming@lyx.org>
+
+ * BufferView_pimpl.C (dispatch):
+ * LyXAction.C (init):
+ * ToolbarDefaults.C (init):
+ * commandtags.h:
+ * lyxfunc.C (getStatus):
+ remove LFUN_INSET_GRAPHICS.
+
+ * factory.C (createInset): add "graphics" to LFUN_INSET_APPLY.
+
+2003-03-07 Angus Leeming <leeming@lyx.org>
* commandtags.h:
* LyXAction.C (init):
N_("Remove all error boxes"), ReadOnly },
{ LFUN_INSET_ERT, "ert-insert",
N_("Insert a new ERT Inset"), Noop },
- { LFUN_INSET_GRAPHICS, "graphics-insert",
- N_("Insert Graphics"), Noop },
{ LFUN_FILE_INSERT, "file-insert", "", Noop },
{ LFUN_FILE_INSERT_ASCII, "file-insert-ascii", _("Insert ASCII files as lines"), Noop },
{ LFUN_FILE_INSERT_ASCII_PARA, "file-insert-ascii-para", _("Insert ASCII file as a paragraph"), Noop },
add(LFUN_MATH_MODE);
add(SEPARATOR);
- add(LFUN_INSET_GRAPHICS);
+// add(LFUN_INSET_GRAPHICS);
add(LFUN_TABULAR_INSERT);
}
LFUN_DATE_INSERT, // jdblair 20000131
LFUN_LANGUAGE, // Dekel 20000203
LFUN_INSET_ERT, // Jug 20000218
- LFUN_INSET_GRAPHICS, // Lgb 20000226
LFUN_INSET_FOOTNOTE, // Jug 20000307
LFUN_PARAGRAPH_SPACING, // Lgb 20000411
LFUN_TABULAR_INSERT, // Jug 20000412
#include "insets/insetexternal.h"
#include "insets/insetfloat.h"
#include "insets/insetfoot.h"
+#include "insets/insetgraphics.h"
#include "insets/insetinclude.h"
#include "insets/insetindex.h"
#include "insets/insetlabel.h"
inset->setFromParams(iep);
return inset;
+ } else if (name == "graphics") {
+ InsetGraphicsParams igp;
+ InsetGraphicsMailer::string2params(cmd.argument, igp);
+ InsetGraphics * inset = new InsetGraphics;
+ string const fpath = cmd.view()->buffer()->filePath();
+ inset->setParams(igp, fpath);
+ return inset;
+
} else if (name == "include") {
InsetInclude::Params iip;
InsetIncludeMailer::string2params(cmd.argument, iip);
+2003-03-07 Angus Leeming <leeming@lyx.org>
+
+ * Dialogs.h: remove showGraphics.
+ * guiapi.[Ch]: remove gui_showGraphics.
+
2003-03-07 Angus Leeming <leeming@lyx.org>
* Dialogs.h: remove showMinipage, updateMinipage.
class InsetBase;
class LyXView;
-class InsetGraphics;
class InsetInfo;
class Paragraph;
class InsetTabular;
void showFile(string const &);
/// show all forked child processes
void showForks();
- ///
- void showGraphics(InsetGraphics *);
/// show the LaTeX log or build file
void showLogFile();
/// display the top-level maths panel
+2003-03-07 Angus Leeming <leeming@lyx.org>
+
+ * ControlGraphics.[Ch]: rewrite to use the Dialog-based scheme.
+
+ * ControlInset.{h, tmpl}: remove.
+ * Makefile.am: remove files.
+
2003-03-07 Angus Leeming <leeming@lyx.org>
* ControlBibitem.[Ch]:
#include "buffer.h"
#include "BufferView.h"
+#include "funcrequest.h"
#include "gettext.h"
#include "lyxrc.h"
extern string user_lyxdir;
-ControlGraphics::ControlGraphics(LyXView & lv, Dialogs & d)
- : ControlInset<InsetGraphics, InsetGraphicsParams>(lv, d)
+ControlGraphics::ControlGraphics(Dialog & parent)
+ : Dialog::Controller(parent)
{}
-InsetGraphicsParams const ControlGraphics::getParams(string const &)
+void ControlGraphics::initialiseParams(string const & data)
{
- return InsetGraphicsParams();
+ InsetGraphicsParams params;
+ InsetGraphicsMailer::string2params(data, params);
+ params_.reset(new InsetGraphicsParams(params));
}
-InsetGraphicsParams const
-ControlGraphics::getParams(InsetGraphics const & inset)
+void ControlGraphics::clearParams()
{
- return inset.params();
+ params_.reset();
}
-void ControlGraphics::applyParamsToInset()
+void ControlGraphics::dispatchParams()
{
- // Set the parameters in the inset, it also returns true if the new
- // parameters are different from what was in the inset already.
- bool changed = inset()->setParams(params(), buffer()->filePath());
-
- // Tell LyX we've got a change, and mark the document dirty,
- // if it changed.
- bufferview()->updateInset(inset(), changed);
+ string const lfun = InsetGraphicsMailer::params2string(params());
+ kernel().dispatch(FuncRequest(LFUN_INSET_APPLY, lfun));
}
-void ControlGraphics::applyParamsNoInset()
-{}
-
-
string const ControlGraphics::Browse(string const & in_name)
{
string const title = _("Select graphics file");
pair<string, string> dir1(_("Clipart|#C#c"), clipdir);
pair<string, string> dir2(_("Documents|#o#O"), string(lyxrc.document_path));
// Show the file browser dialog
- return browseRelFile(in_name, buffer()->filePath(),
+ return browseRelFile(in_name, kernel().buffer()->filePath(),
title, "*.*", false, dir1, dir2);
}
string const ControlGraphics::readBB(string const & file)
{
- string const abs_file = MakeAbsPath(file, buffer()->filePath());
+ string const abs_file =
+ MakeAbsPath(file, kernel().buffer()->filePath());
// try to get it from the file, if possible. Zipped files are
// unzipped in the readBB_from_PSFile-Function
bool ControlGraphics::isFilenameValid(string const & fname) const
{
// It may be that the filename is relative.
- string const name = MakeAbsPath(fname, buffer()->filePath());
+ string const name = MakeAbsPath(fname, kernel().buffer()->filePath());
return IsFileReadable(name);
}
#define CONTROLGRAPHICS_H
-#include "ControlInset.h"
-
-// needed to instatiate inset->hideDialog in ControlInset
-#include "insets/insetgraphics.h"
-
+#include "Dialog.h"
#include <utility>
#include <vector>
/** A controller for Graphics dialogs.
*/
-class ControlGraphics
- : public ControlInset<InsetGraphics, InsetGraphicsParams> {
+class ControlGraphics : public Dialog::Controller {
public:
///
- ControlGraphics(LyXView &, Dialogs &);
+ ControlGraphics(Dialog &);
+ ///
+ virtual void initialiseParams(string const & data);
+ /// clean-up on hide.
+ virtual void clearParams();
+ /// clean-up on hide.
+ virtual void dispatchParams();
+ ///
+ virtual bool isBufferDependent() const { return true; }
+ ///
+ InsetGraphicsParams & params() { return *params_.get(); }
+ ///
+ InsetGraphicsParams const & params() const { return *params_.get(); }
/// Browse for a file
string const Browse(string const &);
bool isFilenameValid(string const & fname) const;
private:
- /// Dispatch the changed parameters to the kernel.
- virtual void applyParamsToInset();
///
- virtual void applyParamsNoInset();
- /// get the parameters from the string passed to createInset.
- virtual InsetGraphicsParams const getParams(string const &);
- /// get the parameters from the inset passed to showInset.
- virtual InsetGraphicsParams const getParams(InsetGraphics const &);
+ boost::scoped_ptr<InsetGraphicsParams> params_;
};
namespace frnt {
+++ /dev/null
-// -*- C++ -*-
-/**
- * \file ControlInset.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Angus Leeming
- *
- * Full author contact details are available in file CREDITS
- *
- * ControlInset is to be used as a parent class for dialogs that display and
- * can perhaps modify the contents of an individual inset. An example being the
- * ubiquitous Citation dialog.
- */
-
-#ifndef CONTROLINSET_H
-#define CONTROLINSET_H
-
-#include "ControlConnections.h"
-#include "LString.h"
-
-#include <boost/signals/connection.hpp>
-
-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();
- ///
- Params const & params() const;
-
- /// 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 *);
-protected:
- /// Allow the daughter methods to access the inset.
- Inset * inset() const;
-private:
- /** These 7 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;
-
- /// 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;
-
- /** Most derived classes won't need these two, so they default to empty.
- */
-
- /// set any daughter class-particular data on show().
- virtual void setDaughterParams() {}
- /// clean-up any daughter class-particular data on hide().
- virtual void clearDaughterParams() {}
-
- /** Some dialogs may find it beneficial to disconnect from the inset
- when the Apply button is pressed. E.g., doing this with the citation
- dialog allows multiple citiations to be inserted easily. */
- virtual bool disconnectOnApply() { return false; }
-
- /// Instantiation of ControlButtons 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);
-
- /// pointer to the inset passed through connectInset
- Inset * inset_;
- /// inset::hide connection.
- boost::signals::connection ih_;
- /** A local copy of the inset's params.
- Memory is allocated only whilst the dialog is visible.
- */
- Params * params_;
-
- /// is the dialog built ?
- bool dialog_built_;
-};
-
-#include "ControlInset.tmpl"
-
-#endif // CONTROLINSET_H
+++ /dev/null
-// -*- C++ -*-
-/**
- * \file ControlInset.tmpl
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Angus Leeming
- *
- * Full author contact details are available in file CREDITS
- *
- * ControlInset is a base class and so these templatised methods will be
- * instantiated if this file is #included in the derived classes' .C file.
- */
-
-#include "ControlInset.h"
-
-#include "ButtonControllerBase.h"
-#include "ViewBase.h"
-#include "support/LAssert.h"
-
-#include <boost/bind.hpp>
-
-template <class Inset, class Params>
-ControlInset<Inset, Params>::ControlInset(LyXView & lv, Dialogs & d)
- : ControlConnectBD(lv, d),
- inset_(0), params_(0), dialog_built_(false)
-{}
-
-
-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));
-
- // The widgets may not be valid, so refresh the button controller
- bc().refresh();
-}
-
-
-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)
-{
- // paranoia check
- if (params_) delete params_;
-
- params_ = new Params(params);
- setDaughterParams();
-
- if (emergency_exit_) {
- hide();
- return;
- }
-
- if (!dialog_built_) {
- view().build();
- dialog_built_ = true;
- }
-
- bc().readOnly(bufferIsReadonly());
- view().show();
-}
-
-
-template <class Inset, class Params>
-void ControlInset<Inset, Params>::update()
-{
- // paranoia check
- if (params_) delete params_;
-
- if (inset_)
- params_ = new Params(getParams(*inset_));
- else
- params_ = new Params();
-
- if (emergency_exit_) {
- hide();
- return;
- }
-
- bc().readOnly(bufferIsReadonly());
- view().update();
-
- // The widgets may not be valid, so refresh the button controller
- bc().refresh();
-}
-
-
-template <class Inset, class Params>
-void ControlInset<Inset, Params>::hide()
-{
- emergency_exit_ = false;
- if (params_) {
- delete params_;
- params_ = 0;
- }
- inset_ = 0;
-
- clearDaughterParams();
-
- ih_.disconnect();
- disconnect();
- view().hide();
-}
-
-
-template <class Inset, class Params>
-void ControlInset<Inset, Params>::apply()
-{
- if (bufferIsReadonly())
- return;
-
- view().apply();
-
- if (inset_) {
- if (params() != getParams(*inset_)) {
- applyParamsToInset();
- }
- } else {
- applyParamsNoInset();
- }
-
- if (disconnectOnApply() && !isClosing()) {
- *params_ = getParams(string());
- inset_ = 0;
- ih_.disconnect();
-
- view().update();
- }
-}
-
-
-template <class Inset, class Params>
-Params & ControlInset<Inset, Params>::params()
-{
- lyx::Assert(params_);
- return *params_;
-}
-
-
-template <class Inset, class Params>
-Params const & ControlInset<Inset, Params>::params() const
-{
- lyx::Assert(params_);
- return *params_;
-}
-
-
-template <class Inset, class Params>
-Inset * ControlInset<Inset, Params>::inset() const
-{
- lyx::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>::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(
- boost::bind(&ControlInset::hide, this));
- }
- connect();
-}
INCLUDES = -I$(top_srcdir)/src \
$(BOOST_INCLUDES)
-EXTRA_DIST = ButtonController.tmpl ControlDialog.tmpl ControlInset.tmpl
+EXTRA_DIST = ButtonController.tmpl ControlDialog.tmpl
libcontrollers_la_SOURCES= \
Dialog.C \
ControlGraphics.h \
ControlInclude.C \
ControlInclude.h \
- ControlInset.h \
ControlLog.C \
ControlLog.h \
ControlMath.C \
}
-void gui_ShowGraphics(InsetGraphics * ig, Dialogs & d)
-{
- d.showGraphics(ig);
-}
-
-
void gui_ShowLogFile(Dialogs & d)
{
d.showLogFile();
#include "LString.h"
class Dialogs;
-class InsetGraphics;
class InsetTabular;
extern "C" {
void gui_ShowDocument(Dialogs &);
void gui_ShowFile(string const &, Dialogs &);
void gui_ShowForks(Dialogs &);
-void gui_ShowGraphics(InsetGraphics *, Dialogs &);
void gui_ShowLogFile(Dialogs &);
void gui_ShowMathPanel(Dialogs &);
void gui_ShowParagraph(Dialogs &);
* QPrefs.C:
* QPrefSpellcheckerModule.ui: Add 'hspell' option.
+2003-03-07 Angus Leeming <leeming@lyx.org>
+
+ * Dialogs.C:
+ * Dialogs2.C:
+ * Dialogs_impl.h: remove graphics dialog.
+
+ * Dialogs3.C: add graphics dialog.
+
+ * QGraphics.[Ch]: changes to use the new Dialog-based scheme.
+
2003-03-07 Angus Leeming <leeming@lyx.org>
* Dialogs.C:
character(lv, d),
document(lv, d),
file(lv, d),
- graphics(lv, d),
logfile(lv, d),
paragraph(lv, d),
prefs(lv, d),
{}
-void Dialogs::showGraphics(InsetGraphics * ig)
-{
- pimpl_->graphics.controller().showInset(ig);
-}
-
-
void Dialogs::showLogFile()
{
pimpl_->logfile.controller().show();
#include "ControlERT.h"
#include "ControlExternal.h"
#include "ControlFloat.h"
+#include "ControlGraphics.h"
#include "ControlInclude.h"
#include "ControlMinipage.h"
#include "ControlRef.h"
// of the Qt headers, those most fucked up of disgusting ratholes.
// But I won't.
#undef signals
+#include "QGraphics.h"
+#include "QGraphicsDialog.h"
#include "QInclude.h"
#include "QIncludeDialog.h"
#include "QIndex.h"
char const * const dialognames[] = { "bibitem", "bibtex", "citation",
"error", "ert", "external", "float",
- "include", "index", "label", "minipage",
- "ref", "toc", "url", "wrap" };
+ "graphics", "include", "index", "label",
+ "minipage", "ref", "toc", "url", "wrap" };
char const * const * const end_dialognames =
dialognames + (sizeof(dialognames) / sizeof(char *));
dialog->setController(new ControlFloat(*dialog));
dialog->setView(new QFloat(*dialog));
dialog->setButtonController(new NoRepeatedApplyReadOnlyBC);
+ } else if (name == "graphics") {
+ dialog->setController(new ControlGraphics(*dialog));
+ dialog->setView(new QGraphics(*dialog));
+ dialog->setButtonController(new NoRepeatedApplyReadOnlyBC);
} else if (name == "include") {
dialog->setController(new ControlInclude(*dialog));
dialog->setView(new QInclude(*dialog));
#include "ControlCharacter.h"
#include "ControlDocument.h"
#include "ControlForks.h"
-#include "ControlGraphics.h"
-#include "insets/insetgraphicsParams.h"
#include "ControlLog.h"
#include "ControlParagraph.h"
#include "ControlPrefs.h"
// of the Qt headers, those most fucked up of disgusting ratholes.
// But I won't.
#undef signals
-#include "QGraphics.h"
-#include "QGraphicsDialog.h"
#include "QLog.h"
#include "QLogDialog.h"
#include "QParagraph.h"
typedef GUI<ControlShowFile, QShowFile, OkCancelPolicy, Qt2BC>
FileDialog;
-typedef GUI<ControlGraphics, QGraphics, NoRepeatedApplyReadOnlyPolicy, Qt2BC>
-GraphicsDialog;
-
typedef GUI<ControlLog, QLog, OkCancelPolicy, Qt2BC>
LogFileDialog;
CharacterDialog character;
DocumentDialog document;
FileDialog file;
- GraphicsDialog graphics;
LogFileDialog logfile;
ParagraphDialog paragraph;
PrefsDialog prefs;
using std::vector;
using std::endl;
-typedef Qt2CB<ControlGraphics, Qt2DB<QGraphicsDialog> > base_class;
+typedef QController<ControlGraphics, QView<QGraphicsDialog> > base_class;
-QGraphics::QGraphics()
- : base_class(qt_("LyX: Insert Graphics"))
+QGraphics::QGraphics(Dialog & parent)
+ : base_class(parent, qt_("LyX: Insert Graphics"))
{
}
#define QGRAPHICS_H
-#include "insets/insetgraphics.h"
-#include "Qt2Base.h"
+#include "QDialogView.h"
+
class ControlGraphics;
class QGraphicsDialog;
///
class QGraphics
- : public Qt2CB<ControlGraphics, Qt2DB<QGraphicsDialog> >
+ : public QController<ControlGraphics, QView<QGraphicsDialog> >
{
public:
///
friend class QGraphicsDialog;
///
- QGraphics();
+ QGraphics(Dialog &);
protected:
virtual bool isValid();
private:
+2003-03-07 Angus Leeming <leeming@lyx.org>
+
+ * Dialogs.C:
+ * Dialogs2.C:
+ * Dialogs_impl.h: remove graphics dialog.
+
+ * Dialogs3.C: add graphics dialog.
+
+ * FormGraphics.[Ch]:
+ * forms/form_graphics.fd: changes to use the new Dialog-based scheme.
+
2003-03-07 Angus Leeming <leeming@lyx.org>
* Dialogs.C:
document(lv, d),
file(lv, d),
forks(lv, d),
- graphics(lv, d),
logfile(lv, d),
mathpanel(lv, d),
paragraph(lv, d),
}
-void Dialogs::showGraphics(InsetGraphics * ig)
-{
- pimpl_->graphics.controller().showInset(ig);
-}
-
-
void Dialogs::showLogFile()
{
pimpl_->logfile.controller().show();
#include "ControlERT.h"
#include "ControlExternal.h"
#include "ControlFloat.h"
+#include "ControlGraphics.h"
#include "ControlInclude.h"
#include "ControlMinipage.h"
#include "ControlRef.h"
#include "forms/form_external.h"
#include "FormFloat.h"
#include "forms/form_float.h"
+#include "FormGraphics.h"
+#include "forms/form_graphics.h"
#include "FormInclude.h"
#include "forms/form_include.h"
#include "FormMinipage.h"
namespace {
-// char const * const dialognames[] = { "bibitem", "bibtex", "citation",
-// "error", "ert", "external", "float",
-// "graphics", "include", "index",
-// "minipage", "ref", "tabular", "toc",
-// "url", "wrap" };
char const * const dialognames[] = { "bibitem", "bibtex", "citation",
"error", "ert", "external", "float",
- "include", "index", "label", "minipage",
- "ref", "toc", "url", "wrap" };
+ "graphics", "include", "index", "label",
+ "minipage", "ref", "toc", "url", "wrap" };
+
char const * const * const end_dialognames =
dialognames + (sizeof(dialognames) / sizeof(char *));
dialog->setController(new ControlFloat(*dialog));
dialog->setView(new FormFloat(*dialog));
dialog->setButtonController(new NoRepeatedApplyReadOnlyBC);
+ } else if (name == "graphics") {
+ dialog->setController(new ControlGraphics(*dialog));
+ dialog->setView(new FormGraphics(*dialog));
+ dialog->setButtonController(new NoRepeatedApplyReadOnlyBC);
} else if (name == "include") {
dialog->setController(new ControlInclude(*dialog));
dialog->setView(new FormInclude(*dialog));
#include "FormForks.h"
#include "forms/form_forks.h"
-#include "ControlGraphics.h"
-#include "FormGraphics.h"
-#include "forms/form_graphics.h"
-
#include "ControlLog.h"
#include "FormLog.h"
typedef GUI<ControlForks, FormForks, OkApplyCancelPolicy, xformsBC>
ForksDialog;
-typedef GUI<ControlGraphics, FormGraphics, NoRepeatedApplyReadOnlyPolicy, xformsBC>
-GraphicsDialog;
-
typedef GUI<ControlLog, FormLog, OkCancelPolicy, xformsBC>
LogFileDialog;
DocumentDialog document;
FileDialog file;
ForksDialog forks;
- GraphicsDialog graphics;
LogFileDialog logfile;
MathPanelDialog mathpanel;
ParagraphDialog paragraph;
} // namespace anon
-typedef FormCB<ControlGraphics, FormDB<FD_graphics> > base_class;
+typedef FormController<ControlGraphics, FormView<FD_graphics> > base_class;
-FormGraphics::FormGraphics()
- : base_class(_("Graphics"), false)
+FormGraphics::FormGraphics(Dialog & parent)
+ : base_class(parent, _("Graphics"), false)
{}
#define FORMGRAPHICS_H
-#include "FormBase.h"
+#include "FormDialogView.h"
#include <boost/scoped_ptr.hpp>
/** This class provides an XForms implementation of the Graphics Dialog.
*/
-class FormGraphics : public FormCB<ControlGraphics, FormDB<FD_graphics> > {
+class FormGraphics
+ : public FormController<ControlGraphics, FormView<FD_graphics> > {
public:
///
- FormGraphics();
+ FormGraphics(Dialog &);
private:
/** Redraw the form (on receipt of a Signal indicating, for example,
resize: FL_RESIZE_NONE
gravity: FL_SouthWest FL_SouthWest
name: button_restore
-callback: C_FormBaseRestoreCB
+callback: C_FormDialogView_RestoreCB
argument: 0
--------------------
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: button_ok
-callback: C_FormBaseOKCB
+callback: C_FormDialogView_OKCB
argument: 0
--------------------
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: button_close
-callback: C_FormBaseCancelCB
+callback: C_FormDialogView_CancelCB
argument: 0
--------------------
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: button_apply
-callback: C_FormBaseApplyCB
+callback: C_FormDialogView_ApplyCB
argument: 0
=============== FORM ===============
resize: FL_RESIZE_X
gravity: FL_North FL_NorthEast
name: input_filename
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
argument: 0
--------------------
resize: FL_RESIZE_NONE
gravity: FL_NorthEast FL_NorthEast
name: button_browse
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
argument: 0
--------------------
resize: FL_RESIZE_NONE
gravity: FL_East FL_East
name: check_draft
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
argument: 0
--------------------
resize: FL_RESIZE_NONE
gravity: FL_East FL_East
name: check_nounzip
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
argument: 0
--------------------
resize: FL_RESIZE_X
gravity: FL_West FL_East
name: input_lyxscale
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
argument: 0
--------------------
resize: FL_RESIZE_X
gravity: FL_West FL_East
name: input_width
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
argument: 0
--------------------
resize: FL_RESIZE_NONE
gravity: FL_East FL_East
name: choice_width
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
argument: 0
--------------------
resize: FL_RESIZE_NONE
gravity: FL_East FL_East
name: choice_height
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
argument: 0
--------------------
resize: FL_RESIZE_NONE
gravity: FL_West FL_West
name: check_aspectratio
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
argument: 0
--------------------
resize: FL_RESIZE_X
gravity: FL_West FL_East
name: input_height
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
argument: 0
--------------------
resize: FL_RESIZE_NONE
gravity: FL_East FL_East
name: choice_display
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
argument: 0
=============== FORM ===============
resize: FL_RESIZE_X
gravity: FL_North FL_North
name: input_bb_x1
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
argument: 0
--------------------
resize: FL_RESIZE_X
gravity: FL_North FL_North
name: input_bb_y1
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
argument: 0
--------------------
resize: FL_RESIZE_X
gravity: FL_North FL_North
name: input_bb_x0
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
argument: 0
--------------------
resize: FL_RESIZE_X
gravity: FL_North FL_North
name: input_bb_y0
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
argument: 0
--------------------
resize: FL_RESIZE_NONE
gravity: FL_North FL_North
name: choice_bb_units
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
argument: 0
--------------------
resize: FL_RESIZE_NONE
gravity: FL_NorthWest FL_NorthWest
name: check_clip
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
argument: 0
--------------------
resize: FL_RESIZE_NONE
gravity: FL_NorthWest FL_NorthWest
name: button_getBB
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
argument: 0
=============== FORM ===============
resize: FL_RESIZE_X
gravity: FL_West FL_East
name: input_special
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
argument: 0
--------------------
resize: FL_RESIZE_X
gravity: FL_North FL_North
name: choice_origin
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
argument: 0
--------------------
resize: FL_RESIZE_NONE
gravity: FL_West FL_West
name: check_subcaption
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
argument: 0
--------------------
resize: FL_RESIZE_X
gravity: FL_North FL_North
name: input_rotate_angle
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
argument: 0
--------------------
resize: FL_RESIZE_X
gravity: FL_West FL_East
name: input_subcaption
-callback: C_FormBaseInputCB
+callback: C_FormDialogView_InputCB
argument: 0
==============================
2003-03-07 Angus Leeming <leeming@lyx.org>
+ * insetgraphics.[Ch]: define a new class InsetGraphicsMailer and use
+ it to communicate with the frontend dialogs.
+
+cd src2003-03-07 Angus Leeming <leeming@lyx.org>
+
* insetexternal.C: remove operator== and operator!= for
InsetExternal::Params. They were used only by the old controller
scheme.
#include "buffer.h"
#include "BufferView.h"
#include "converter.h"
-#include "format.h"
-#include "frontends/Painter.h"
-#include "lyxrc.h"
-#include "frontends/font_metrics.h"
#include "debug.h"
+#include "format.h"
+#include "funcrequest.h"
#include "gettext.h"
#include "LaTeXFeatures.h"
#include "lyxlex.h"
+#include "lyxrc.h"
#include "frontends/Alert.h"
#include "frontends/Dialogs.h"
+#include "frontends/font_metrics.h"
#include "frontends/LyXView.h"
-
-#include "frontends/controllers/helper_funcs.h" // getVectorFromString
+#include "frontends/Painter.h"
#include "support/LAssert.h"
#include "support/filetools.h"
InsetGraphics::~InsetGraphics()
{
- // Emits the hide signal to the dialog connected (if any)
- hideDialog();
+ InsetGraphicsMailer mailer(*this);
+ mailer.hideDialog();
+}
+
+
+dispatch_result InsetGraphics::localDispatch(FuncRequest const & cmd)
+{
+ dispatch_result result = UNDISPATCHED;
+
+ switch (cmd.action) {
+ case LFUN_INSET_MODIFY: {
+ InsetGraphicsParams p;
+ InsetGraphicsMailer::string2params(cmd.argument, p);
+ if (p.filename.empty())
+ break;
+
+ string const filepath = cmd.view()->buffer()->filePath();
+ setParams(p, filepath);
+ cmd.view()->updateInset(this, true);
+ result = DISPATCHED;
+ }
+ break;
+
+ case LFUN_INSET_DIALOG_UPDATE: {
+ InsetGraphicsMailer mailer(*this);
+ mailer.updateDialog();
+ }
+ break;
+
+ default:
+ result = DISPATCHED;
+ break;
+ }
+
+ return result;
}
}
+BufferView * InsetGraphics::view() const
+{
+ return cache_->view.lock().get();
+}
+
+
void InsetGraphics::draw(BufferView * bv, LyXFont const & font,
int baseline, float & x, bool) const
{
}
-void InsetGraphics::edit(BufferView *bv, int, int, mouse_button::state)
+void InsetGraphics::edit(BufferView *, int, int, mouse_button::state)
{
- bv->owner()->getDialogs().showGraphics(this);
+ InsetGraphicsMailer mailer(*this);
+ mailer.showDialog();
}
{
return params_;
}
+
+
+string const InsetGraphicsMailer::name_("graphics");
+
+InsetGraphicsMailer::InsetGraphicsMailer(InsetGraphics & inset)
+ : inset_(inset)
+{}
+
+
+string const InsetGraphicsMailer::inset2string() const
+{
+ return params2string(inset_.params());
+}
+
+
+void InsetGraphicsMailer::string2params(string const & in,
+ InsetGraphicsParams & params)
+{
+ params = InsetGraphicsParams();
+
+ istringstream data(in);
+ LyXLex lex(0,0);
+ lex.setStream(data);
+
+ if (lex.isOK()) {
+ lex.next();
+ string const token = lex.getString();
+ if (token != name_)
+ return;
+ }
+
+ InsetGraphics inset;
+ inset.readInsetGraphics(lex);
+ params = inset.params();
+}
+
+
+string const
+InsetGraphicsMailer::params2string(InsetGraphicsParams const & params)
+{
+ ostringstream data;
+ data << name_ << ' ';
+ params.Write(data);
+ data << "\\end_inset\n";
+
+ return data.str();
+}
#include "insets/inset.h"
#include "insets/insetgraphicsParams.h"
-// We need a signal here to hide an active dialog when we are deleted.
-#include <boost/signals/signal0.hpp>
#include <boost/signals/trackable.hpp>
#include <boost/scoped_ptr.hpp>
///
~InsetGraphics();
///
+ virtual dispatch_result localDispatch(FuncRequest const & cmd);
+ ///
int ascent(BufferView *, LyXFont const &) const;
///
int descent(BufferView *, LyXFont const &) const;
/// Get the inset parameters, used by the GUIndependent dialog.
InsetGraphicsParams const & params() const;
- /** This signal is connected by our dialog and called when the inset
- is deleted.
- */
- boost::signal0<void> hideDialog;
-
private:
+ /// Returns the cached BufferView.
+ BufferView * view() const;
+
+ ///
+ friend class InsetGraphicsMailer;
+
/// Is the image ready to draw, or should we display a message instead?
bool imageIsDrawable() const;
boost::scoped_ptr<Cache> const cache_;
};
+
+#include "mailinset.h"
+
+class InsetGraphicsMailer : public MailInset {
+public:
+ ///
+ InsetGraphicsMailer(InsetGraphics & inset);
+ ///
+ virtual Inset & inset() const { return inset_; }
+ ///
+ virtual string const & name() const { return name_; }
+ ///
+ virtual string const inset2string() const;
+ ///
+ static void string2params(string const &, InsetGraphicsParams &);
+ ///
+ static string const params2string(InsetGraphicsParams const &);
+private:
+ ///
+ static string const name_;
+ ///
+ InsetGraphics & inset_;
+};
+
#endif
case LFUN_INSET_ERT:
code = Inset::ERT_CODE;
break;
- case LFUN_INSET_GRAPHICS:
- code = Inset::GRAPHICS_CODE;
- break;
case LFUN_INSET_FOOTNOTE:
code = Inset::FOOT_CODE;
break;