Convert the preamble dialog to the Dialog-based scheme.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8576 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Angus Leeming 2004-03-31 20:55:59 +00:00
parent 2bff4a6c86
commit b518346bbd
21 changed files with 136 additions and 147 deletions

View File

@ -1,3 +1,8 @@
2004-03-31 Angus Leeming <leeming@lyx.org>
* lyxfunc.C (dispatch): Fall through to the generic
Dialogs::show("preamble").
2004-03-31 Angus Leeming <leeming@lyx.org>
* lyxfunc.C (dispatch): Fall through to the generic

View File

@ -1,3 +1,12 @@
2004-03-31 Angus Leeming <leeming@lyx.org>
* Dialogs.h (showPreamble):
* guiapi.[Ch] (gui_Preamble): removed.
* Dialogs.[Ch] (build): return a boost::shared_ptr rather than
a raw Dialog*. Nicer, but also enables the Qt frontend to
re-use the document dialog.
2004-03-31 Angus Leeming <leeming@lyx.org>
* Dialogs.h (showSpellchecker):

View File

@ -89,7 +89,7 @@ Dialog * Dialogs::find_or_build(string const & name)
if (it != dialogs_.end())
return it->second.get();
dialogs_[name] = DialogPtr(build(name));
dialogs_[name] = build(name);
return dialogs_[name].get();
}

View File

@ -62,13 +62,6 @@ public:
*/
void updateBufferDependent(bool) const ;
/**@name Dialog Access Signals.
Put into some sort of alphabetical order */
//@{
///
void showPreamble();
//@}
/** \param name == "about" etc; an identifier used to
launch a particular dialog.
\param data is a string encoding of the data used to populate
@ -117,15 +110,15 @@ private:
///
Dialog * find_or_build(std::string const & name);
///
Dialog * build(std::string const & name);
typedef boost::shared_ptr<Dialog> DialogPtr;
///
DialogPtr build(std::string const & name);
///
LyXView & lyxview_;
///
std::map<std::string, InsetBase *> open_insets_;
///
typedef boost::shared_ptr<Dialog> DialogPtr;
///
std::map<std::string, DialogPtr> dialogs_;

View File

@ -1,3 +1,7 @@
2004-03-31 Angus Leeming <leeming@lyx.org>
* ControlPreamble.[Ch]: converted to the dialog-based scheme.
2004-03-31 Angus Leeming <leeming@lyx.org>
* ControlSpellchecker.C: converted to the dialog-based scheme.

View File

@ -10,36 +10,40 @@
#include <config.h>
#include "ControlPreamble.h"
#include "ViewBase.h"
#include "buffer.h"
#include "bufferparams.h"
#include "gettext.h"
#include "frontends/LyXView.h"
using std::string;
ControlPreamble::ControlPreamble(LyXView & lv, Dialogs & d)
: ControlDialogBD(lv, d)
ControlPreamble::ControlPreamble(Dialog & parent)
: Dialog::Controller(parent)
{}
void ControlPreamble::apply()
bool ControlPreamble::initialiseParams(std::string const &)
{
if (!bufferIsAvailable())
return;
params_ = kernel().buffer().params().preamble;
return true;
}
view().apply();
buffer()->params().preamble = params();
buffer()->markDirty();
lv_.message(_("LaTeX preamble set"));
void ControlPreamble::clearParams()
{
params_.erase();
}
void ControlPreamble::dispatchParams()
{
// This can stay because we're going to throw the class away
// as soon as xforms 1.1 is released.
// Ie, there's no need to define LFUN_BUFFERPREAMBLE_APPLY.
Buffer & buffer = kernel().buffer();
buffer.params().preamble = params();
buffer.markDirty();
}
@ -53,15 +57,3 @@ void ControlPreamble::params(string const & newparams)
{
params_ = newparams;
}
void ControlPreamble::setParams()
{
params_ = buffer()->params().preamble;
}
void ControlPreamble::clearParams()
{
params_.erase();
}

View File

@ -12,29 +12,28 @@
#ifndef CONTROLPREAMBLE_H
#define CONTROLPREAMBLE_H
#include "ControlDialog_impl.h"
#include "Dialog.h"
/** A controller for Preamble dialogs.
*/
class ControlPreamble : public ControlDialogBD {
class ControlPreamble : public Dialog::Controller {
public:
///
ControlPreamble(LyXView &, Dialogs &);
ControlPreamble(Dialog &);
///
virtual bool initialiseParams(std::string const &);
///
virtual void clearParams();
///
virtual void dispatchParams();
///
virtual bool isBufferDependent() const { return true; }
///
std::string const & params() const;
///
void params(std::string const & newparams);
private:
/// Get changed parameters and Dispatch them to the kernel.
virtual void apply();
/// set the params before show or update.
virtual void setParams();
/// clean-up on hide.
virtual void clearParams();
///
std::string params_;
};

View File

@ -1,3 +1,7 @@
2004-03-31 Angus Leeming <leeming@lyx.org>
* Dialogs.C (build): added preamble dialog.
2004-03-31 Angus Leeming <leeming@lyx.org>
* Dialogs.C (build): added spellchecker dialog.

View File

@ -34,6 +34,7 @@
#include "ControlMath.h"
#include "ControlNote.h"
#include "ControlParagraph.h"
#include "ControlPreamble.h"
#include "ControlPrefs.h"
#include "ControlPrint.h"
#include "ControlRef.h"
@ -73,6 +74,7 @@
#include "FormMathsStyle.h"
#include "FormNote.h"
#include "FormParagraph.h"
#include "FormPreamble.h"
#include "FormPreferences.h"
#include "FormPrint.h"
#include "FormRef.h"
@ -111,6 +113,7 @@
#include "ams_nrel.xbm"
#include "ams_ops.xbm"
#include <boost/assert.hpp>
#include <vector>
using std::string;
@ -134,8 +137,8 @@ char const * const dialognames[] = {
"mathgreek", "mathmisc", "mathdots", "mathbigoperators", "mathamsmisc",
"mathamsarrows", "mathamsrelations", "mathamsnegatedrelations",
"mathamsoperators", "mathdelimiter", "mathmatrix", "mathspace", "mathstyle",
"note", "paragraph", "prefs", "print", "ref", "sendto", "spellchecker",
"tabular", "tabularcreate", "texinfo",
"note", "paragraph", "preamble", "prefs", "print", "ref", "sendto",
"spellchecker", "tabular", "tabularcreate", "texinfo",
#ifdef HAVE_LIBAIKSAURUS
"thesaurus",
@ -165,12 +168,11 @@ bool Dialogs::isValidName(string const & name) const
}
Dialog * Dialogs::build(string const & name)
Dialogs::DialogPtr Dialogs::build(string const & name)
{
if (!isValidName(name))
return 0;
BOOST_ASSERT(isValidName(name));
Dialog * dialog = new Dialog(lyxview_, name);
DialogPtr dialog(new Dialog(lyxview_, name));
dialog->bc().view(new xformsBC(dialog->bc()));
if (name == "aboutlyx") {
@ -450,6 +452,10 @@ Dialog * Dialogs::build(string const & name)
dialog->setController(new ControlParagraph(*dialog));
dialog->setView(new FormParagraph(*dialog));
dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
} else if (name == "preamble") {
dialog->setController(new ControlPreamble(*dialog));
dialog->setView(new FormPreamble(*dialog));
dialog->bc().bp(new OkApplyCancelPolicy);
} else if (name == "prefs") {
dialog->setController(new ControlPrefs(*dialog));
dialog->setView(new FormPreferences(*dialog));

View File

@ -22,9 +22,4 @@ void gui_show_dialog(Dialogs * d, char const * name, char const * data)
d->show(name, data, 0);
}
void gui_ShowPreamble(Dialogs & d)
{
d.showPreamble();
}
} // extern "C"

View File

@ -12,16 +12,12 @@
#ifndef GUIAPI_H
#define GUIAPI_H
class Dialogs;
extern "C" {
void gui_show_dialog(Dialogs *, char const * name, char const * data);
void gui_ShowPreamble(Dialogs &);
} // extern "C"
#endif // GUIAPI_H

View File

@ -1,3 +1,8 @@
2004-03-31 Angus Leeming <leeming@lyx.org>
* Dialogs.C (build): added "preamble" as a symonym for "document".
* Dialogs2.C (showPreamble): removed.
2004-03-31 Angus Leeming <leeming@lyx.org>
* Dialogs.C (build): added spellchecker dialog.

View File

@ -91,6 +91,8 @@
#include "qt_helpers.h"
#include <boost/assert.hpp>
using std::string;
@ -100,8 +102,8 @@ char const * const dialognames[] = {
"aboutlyx", "bibitem", "bibtex", "box", "branch", "changes", "character",
"citation", "document", "error", "errorlist", "ert", "external", "file",
"findreplace", "float", "graphics", "include", "index", "label", "log",
"mathpanel", "mathdelimiter", "mathmatrix", "note", "paragraph", "prefs",
"print", "ref", "sendto", "spellchecker","tabular", "tabularcreate",
"mathpanel", "mathdelimiter", "mathmatrix", "note", "paragraph", "preamble",
"prefs", "print", "ref", "sendto", "spellchecker","tabular", "tabularcreate",
#ifdef HAVE_LIBAIKSAURUS
"thesaurus",
@ -132,12 +134,11 @@ bool Dialogs::isValidName(string const & name) const
}
Dialog * Dialogs::build(string const & name)
Dialogs::DialogPtr Dialogs::build(string const & name)
{
if (!isValidName(name))
return 0;
BOOST_ASSERT(isValidName(name));
Dialog * dialog = new Dialog(lyxview_, name);
DialogPtr dialog(new Dialog(lyxview_, name));
dialog->bc().view(new Qt2BC(dialog->bc()));
if (name == "aboutlyx") {
@ -172,10 +173,25 @@ Dialog * Dialogs::build(string const & name)
dialog->setController(new ControlCitation(*dialog));
dialog->setView(new QCitation(*dialog));
dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
} else if (name == "document") {
dialog->setController(new ControlDocument(*dialog));
dialog->setView(new QDocument(*dialog));
dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
} else if (name == "document" || name == "preamble") {
// This nastiness will exist only as long as xforms
// has a separate preamble dialog.
string const other = (name == "document") ?
"preamble" : "document";
std::map<string, DialogPtr>::iterator it =
dialogs_.find(other);
if (it != dialogs_.end())
dialog = it->second;
else {
dialog->setController(new ControlDocument(*dialog));
dialog->setView(new QDocument(*dialog));
dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
}
} else if (name == "errorlist") {
dialog->setController(new ControlErrorList(*dialog));
dialog->setView(new QErrorList(*dialog));

View File

@ -12,28 +12,13 @@
#include <config.h>
#include "debug.h"
#include "Dialogs.h"
#include "controllers/GUI.h"
#include "ButtonController.h"
#include "Qt2BC.h"
// Here would be an appropriate point to lecture on the evils
// of the Qt headers, those most fucked up of disgusting ratholes.
// But I won't.
#undef signals
struct Dialogs::Impl {
Impl(LyXView & lv, Dialogs & d);
Impl(LyXView &, Dialogs &) {}
};
Dialogs::Impl::Impl(LyXView &, Dialogs &)
{}
void Dialogs::init_pimpl()
{
pimpl_ = new Impl(lyxview_, *this);
@ -44,11 +29,3 @@ Dialogs::~Dialogs()
{
delete pimpl_;
}
void Dialogs::showPreamble()
{
show("document");
// Oh Angus, won't you help a poor child ?
//pimpl_->document.view()->showPreamble();
}

View File

@ -1,3 +1,11 @@
2004-03-31 Angus Leeming <leeming@lyx.org>
* Dialogs.C (build): added preamble dialog.
* Dialogs2.C (showPreamble): removed.
* FormPreamble.[Ch]:
* forms/form_preamble.fd: converted to the Dialog-based scheme.
2004-03-31 Angus Leeming <leeming@lyx.org>
* Dialogs.C (build): added spellchecker dialog.

View File

@ -31,6 +31,7 @@
#include "ControlMath.h"
#include "ControlNote.h"
#include "ControlParagraph.h"
#include "ControlPreamble.h"
#include "ControlPrefs.h"
#include "ControlPrint.h"
#include "ControlRef.h"
@ -68,6 +69,7 @@
#include "FormMathsStyle.h"
#include "FormNote.h"
#include "FormParagraph.h"
#include "FormPreamble.h"
#include "FormPreferences.h"
#include "FormPrint.h"
#include "FormRef.h"
@ -107,6 +109,8 @@
#include "ams_nrel.xbm"
#include "ams_ops.xbm"
#include <boost/assert.hpp>
using std::string;
@ -129,8 +133,8 @@ char const * const dialognames[] = {
"mathgreek", "mathmisc", "mathdots", "mathbigoperators", "mathamsmisc",
"mathamsarrows", "mathamsrelations", "mathamsnegatedrelations",
"mathamsoperators", "mathdelimiter", "mathmatrix", "mathspace", "mathstyle",
"note", "paragraph", "prefs", "print", "ref", "sendto", "spellchecker",
"tabular", "tabularcreate", "texinfo",
"note", "paragraph", "preamble", "prefs", "print", "ref", "sendto",
"spellchecker", "tabular", "tabularcreate", "texinfo",
#ifdef HAVE_LIBAIKSAURUS
"thesaurus",
@ -160,12 +164,11 @@ bool Dialogs::isValidName(string const & name) const
}
Dialog * Dialogs::build(string const & name)
Dialogs::DialogPtr Dialogs::build(string const & name)
{
if (!isValidName(name))
return 0;
BOOST_ASSERT(isValidName(name));
Dialog * dialog = new Dialog(lyxview_, name);
DialogPtr dialog(new Dialog(lyxview_, name));
dialog->bc().view(new xformsBC(dialog->bc()));
if (name == "aboutlyx") {
@ -440,6 +443,10 @@ Dialog * Dialogs::build(string const & name)
dialog->setController(new ControlParagraph(*dialog));
dialog->setView(new FormParagraph(*dialog));
dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
} else if (name == "preamble") {
dialog->setController(new ControlPreamble(*dialog));
dialog->setView(new FormPreamble(*dialog));
dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
} else if (name == "prefs") {
dialog->setController(new ControlPrefs(*dialog));
dialog->setView(new FormPreferences(*dialog));

View File

@ -12,32 +12,12 @@
#include <config.h>
#include "Dialogs.h"
#include "controllers/GUI.h"
#include "ButtonController.h"
#include "xformsBC.h"
#include "xforms_helpers.h"
#include "ControlPreamble.h"
#include "FormPreamble.h"
#include "forms/form_preamble.h"
typedef GUI<ControlPreamble, FormPreamble, NoRepeatedApplyReadOnlyPolicy, xformsBC>
PreambleDialog;
struct Dialogs::Impl {
Impl(LyXView & lv, Dialogs & d);
PreambleDialog preamble;
Impl(LyXView &, Dialogs &) {}
};
Dialogs::Impl::Impl(LyXView & lv, Dialogs & d)
: preamble(lv, d)
{}
void Dialogs::init_pimpl()
{
pimpl_ = new Impl(lyxview_, *this);
@ -48,9 +28,3 @@ Dialogs::~Dialogs()
{
delete pimpl_;
}
void Dialogs::showPreamble()
{
pimpl_->preamble.controller().show();
}

View File

@ -11,19 +11,20 @@
#include <config.h>
#include "FormPreamble.h"
#include "ControlPreamble.h"
#include "forms/form_preamble.h"
#include "controllers/ControlPreamble.h"
#include "xforms_helpers.h"
#include "xformsBC.h"
#include "lyx_forms.h"
typedef FormCB<ControlPreamble, FormDB<FD_preamble> > base_class;
typedef FormController<ControlPreamble, FormView<FD_preamble> > base_class;
FormPreamble::FormPreamble()
: base_class(_("LaTeX Preamble"))
FormPreamble::FormPreamble(Dialog & parent)
: base_class(parent, _("LaTeX Preamble"))
{}

View File

@ -12,18 +12,18 @@
#ifndef FORMPREAMBLE_H
#define FORMPREAMBLE_H
#include "FormBase.h"
#include "FormDialogView.h"
class ControlPreamble;
struct FD_preamble;
/** This class provides an XForms implementation of the Preamble Dialog.
*/
class FormPreamble : public FormCB<ControlPreamble, FormDB<FD_preamble> > {
class FormPreamble
: public FormController<ControlPreamble, FormView<FD_preamble> > {
public:
///
FormPreamble();
FormPreamble(Dialog &);
private:
/// Apply from dialog
virtual void apply();

View File

@ -46,7 +46,7 @@ shortcut:
resize: FL_RESIZE_NONE
gravity: FL_SouthEast FL_SouthEast
name: button_ok
callback: C_FormBaseOKCB
callback: C_FormDialogView_OKCB
argument: 0
--------------------
@ -64,7 +64,7 @@ shortcut:
resize: FL_RESIZE_NONE
gravity: FL_SouthEast FL_SouthEast
name: button_apply
callback: C_FormBaseApplyCB
callback: C_FormDialogView_ApplyCB
argument: 0
--------------------
@ -82,7 +82,7 @@ shortcut:
resize: FL_RESIZE_NONE
gravity: FL_SouthEast FL_SouthEast
name: button_close
callback: C_FormBaseCancelCB
callback: C_FormDialogView_CancelCB
argument: 0
--------------------
@ -100,7 +100,7 @@ shortcut:
resize: FL_RESIZE_ALL
gravity: FL_NorthWest FL_SouthEast
name: input_preamble
callback: C_FormBaseInputCB
callback: C_FormDialogView_InputCB
argument: 0
==============================

View File

@ -1049,8 +1049,6 @@ void LyXFunc::dispatch(FuncRequest const & cmd, bool verbose)
if (!data.empty())
owner->getDialogs().show("character", data);
}
else if (name == "preamble")
owner->getDialogs().showPreamble();
else if (name == "latexlog") {
pair<Buffer::LogType, string> const logfile =