port the minipage dialog to the new scheme. Various other small changes

in the inset mailers and in the controllers.
Enable the include dialog to be lauched for a new inset (should please John ;-)


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6374 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Angus Leeming 2003-03-07 14:08:10 +00:00
parent 9973bb7aa1
commit e22ee4208d
62 changed files with 496 additions and 571 deletions

View File

@ -1,3 +1,8 @@
2003-03-07 Angus Leeming <leeming@lyx.org>
* lyxfunc.C (dispatch): add "include" to LFUN_SHOW_NEW_INSET and
remove "ert".
2003-03-06 Lars Gullik Bjønnes <larsbj@gullik.net>
* ParagraphList.C (front): new function

View File

@ -1,3 +1,8 @@
2003-03-07 Angus Leeming <leeming@lyx.org>
* Dialogs.h: remove showMinipage, updateMinipage.
* guiapi.[Ch]: remove gui_showMinipage, gui_updateMinipage.
2003-03-06 Alfredo Braunstein <abraunst@libero.it>
* screen.C: use LyXText::top_y() instead of LyXText::first_y

View File

@ -25,7 +25,6 @@ class LyXView;
class InsetGraphics;
class InsetInfo;
class InsetMinipage;
class Paragraph;
class InsetTabular;
@ -96,10 +95,6 @@ public:
/// show the merge changes dialog
void showMergeChanges();
///
void showMinipage(InsetMinipage *);
///
void updateMinipage(InsetMinipage *);
///
void showParagraph();
///
void updateParagraph();

View File

@ -1,3 +1,21 @@
2003-03-07 Angus Leeming <leeming@lyx.org>
* ControlBibitem.[Ch]:
* ControlIndex.[Ch]:
* ControlLabel.[Ch]:
* ControlUrl.[Ch]: removed.
* Makefile.am: remove files.
* ControlERT.C (dispatchParams):
* ControlExternal.C (dispatchParams):
* ControlFloat.C (dispatchParams):
* ControlInclude.C (dispatchParams):
* ControlWrap.C (dispatchParams): no need to pass name to Mailer
anymore.
* ControlMinipage.[Ch]: rewrite to use the Dialog-based scheme.
2003-03-05 Angus Leeming <leeming@lyx.org>
* ControlWrap.[Ch]: rewrite to use the Dialog-based scheme.

View File

@ -1,19 +0,0 @@
/**
* \file ControlBibitem.C
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
* \author John Levon
* \author Angus Leeming
*
* Full author contact details are available in file CREDITS
*/
#include <config.h>
#include "ControlBibitem.h"
ControlBibitem::ControlBibitem(Dialog & d)
: ControlCommand(d, "bibitem")
{}

View File

@ -1,27 +0,0 @@
// -*- C++ -*-
/**
* \file ControlBibitem.h
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
* \author John Levon
* \author Angus Leeming
*
* Full author contact details are available in file CREDITS
*/
#ifndef CONTROLBIBITEM_H
#define CONTROLBIBITEM_H
#include "ControlCommand.h"
/** A controller for Bibitem dialogs.
*/
class ControlBibitem : public ControlCommand {
public:
///
ControlBibitem(Dialog &);
};
#endif // CONTROLBIBITEM_H

View File

@ -34,6 +34,6 @@ void ControlERT::clearParams()
void ControlERT::dispatchParams()
{
string const lfun = InsetERTMailer::params2string("ert", status_);
string const lfun = InsetERTMailer::params2string(status_);
kernel().dispatch(FuncRequest(LFUN_INSET_APPLY, lfun));
}

View File

@ -46,8 +46,7 @@ void ControlExternal::clearParams()
void ControlExternal::dispatchParams()
{
InsetExternal::Params p = params();
string const lfun = InsetExternalMailer::params2string("external", p);
string const lfun = InsetExternalMailer::params2string(params());
kernel().dispatch(FuncRequest(LFUN_INSET_APPLY, lfun));
}

View File

@ -36,6 +36,6 @@ void ControlFloat::clearParams()
void ControlFloat::dispatchParams()
{
string const lfun = InsetFloatMailer::params2string("float", params());
string const lfun = InsetFloatMailer::params2string(params());
kernel().dispatch(FuncRequest(LFUN_INSET_APPLY, lfun));
}

View File

@ -48,7 +48,7 @@ void ControlInclude::clearParams()
void ControlInclude::dispatchParams()
{
InsetInclude::Params p = params();
string const lfun = InsetIncludeMailer::params2string("include", p);
string const lfun = InsetIncludeMailer::params2string(p);
kernel().dispatch(FuncRequest(LFUN_INSET_APPLY, lfun));
}

View File

@ -1,19 +0,0 @@
/**
* \file ControlIndex.C
* 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
*/
#include <config.h>
#include "ControlIndex.h"
ControlIndex::ControlIndex(Dialog & d)
: ControlCommand(d, "index")
{}

View File

@ -1,26 +0,0 @@
// -*- C++ -*-
/**
* \file ControlIndex.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
*/
#ifndef CONTROLINDEX_H
#define CONTROLINDEX_H
#include "ControlCommand.h"
/** A controller for Index dialogs.
*/
class ControlIndex : public ControlCommand {
public:
///
ControlIndex(Dialog &);
};
#endif // CONTROLINDEX_H

View File

@ -1,19 +0,0 @@
/**
* \file ControlLabel.C
* 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
*/
#include <config.h>
#include "ControlLabel.h"
ControlLabel::ControlLabel(Dialog & d)
: ControlCommand(d, "label")
{}

View File

@ -1,26 +0,0 @@
// -*- C++ -*-
/**
* \file ControlLabel.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
*/
#ifndef CONTROLLABEL_H
#define CONTROLLABEL_H
#include "ControlCommand.h"
/** A controller for Label dialogs.
*/
class ControlLabel : public ControlCommand {
public:
///
ControlLabel(Dialog &);
};
#endif // CONTROLLABEL_H

View File

@ -11,53 +11,31 @@
#include <config.h>
#include "ControlMinipage.h"
#include "BufferView.h"
#include "funcrequest.h"
ControlMinipage::ControlMinipage(LyXView & lv, Dialogs & d)
: ControlInset<InsetMinipage, MinipageParams>(lv, d)
ControlMinipage::ControlMinipage(Dialog & parent)
: Dialog::Controller(parent)
{}
void ControlMinipage::applyParamsToInset()
void ControlMinipage::initialiseParams(string const & data)
{
inset()->pageWidth(params().pageWidth);
inset()->pos(params().pos);
bufferview()->updateInset(inset(), true);
InsetMinipage::Params params;
InsetMinipageMailer::string2params(data, params);
params_.reset(new InsetMinipage::Params(params));
}
void ControlMinipage::applyParamsNoInset()
void ControlMinipage::clearParams()
{
params_.reset();
}
MinipageParams const ControlMinipage::getParams(InsetMinipage const & inset)
void ControlMinipage::dispatchParams()
{
return MinipageParams(inset);
}
MinipageParams::MinipageParams()
: pos(InsetMinipage::top)
{}
MinipageParams::MinipageParams(InsetMinipage const & inset)
: pageWidth(inset.pageWidth()), pos(inset.pos())
{}
bool operator==(MinipageParams const & p1, MinipageParams const & p2)
{
return (p1.pageWidth == p2.pageWidth && p1.pos == p2.pos);
}
bool operator!=(MinipageParams const & p1, MinipageParams const & p2)
{
return !(p1 == p2);
string const lfun = InsetMinipageMailer::params2string(params());
kernel().dispatch(FuncRequest(LFUN_INSET_APPLY, lfun));
}

View File

@ -13,49 +13,28 @@
#ifndef CONTROLMINIPAGE_H
#define CONTROLMINIPAGE_H
#include <vector>
#include "Dialog.h"
#include "insets/insetminipage.h"
#include "ControlInset.h"
#include "insets/insetminipage.h" // InsetMinipage::Position
/** This should be moved back into insetminipage.h and InsetMinipage should
contain an instance of it. */
struct MinipageParams {
///
MinipageParams();
///
MinipageParams(InsetMinipage const &);
///
LyXLength pageWidth;
///
InsetMinipage::Position pos;
};
///
bool operator==(MinipageParams const &, MinipageParams const &);
///
bool operator!=(MinipageParams const &, MinipageParams const &);
/** A controller for Minipage dialogs.
*/
class ControlMinipage : public ControlInset<InsetMinipage, MinipageParams> {
class ControlMinipage : public Dialog::Controller {
public:
///
ControlMinipage(LyXView &, Dialogs &);
private:
/// Dispatch the changed parameters to the kernel.
virtual void applyParamsToInset();
ControlMinipage(Dialog &);
///
virtual void applyParamsNoInset();
/// get the parameters from the string passed to createInset.
virtual MinipageParams const getParams(string const &)
{ return MinipageParams(); }
/// get the parameters from the inset passed to showInset.
virtual MinipageParams const getParams(InsetMinipage const &);
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; }
///
InsetMinipage::Params & params() { return *params_.get(); }
///
InsetMinipage::Params const & params() const { return *params_.get(); }
private:
///
boost::scoped_ptr<InsetMinipage::Params> params_;
};
#endif

View File

@ -1,19 +0,0 @@
/**
* \file ControlUrl.C
* 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
*/
#include <config.h>
#include "ControlUrl.h"
ControlUrl::ControlUrl(Dialog & d)
: ControlCommand(d, "url")
{}

View File

@ -1,27 +0,0 @@
// -*- C++ -*-
/**
* \file ControlUrl.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
*/
#ifndef CONTROLURL_H
#define CONTROLURL_H
#include "ControlCommand.h"
/** A controller for the Url Dialog.
*/
class ControlUrl : public ControlCommand
{
public:
///
ControlUrl(Dialog &);
};
#endif // CONTROLURL_H

View File

@ -37,6 +37,6 @@ void ControlWrap::clearParams()
void ControlWrap::dispatchParams()
{
string const lfun = InsetWrapMailer::params2string("wrap", params());
string const lfun = InsetWrapMailer::params2string(params());
kernel().dispatch(FuncRequest(LFUN_INSET_APPLY, lfun));
}

View File

@ -27,8 +27,6 @@ libcontrollers_la_SOURCES= \
ButtonPolicies.h \
ControlAboutlyx.C \
ControlAboutlyx.h \
ControlBibitem.C \
ControlBibitem.h \
ControlBibtex.C \
ControlBibtex.h \
ControlButtons.C \
@ -64,11 +62,7 @@ libcontrollers_la_SOURCES= \
ControlGraphics.h \
ControlInclude.C \
ControlInclude.h \
ControlIndex.C \
ControlIndex.h \
ControlInset.h \
ControlLabel.C \
ControlLabel.h \
ControlLog.C \
ControlLog.h \
ControlMath.C \
@ -103,8 +97,6 @@ libcontrollers_la_SOURCES= \
ControlThesaurus.h \
ControlToc.C \
ControlToc.h \
ControlUrl.C \
ControlUrl.h \
ControlVCLog.C \
ControlVCLog.h \
ControlWrap.C \

View File

@ -75,18 +75,6 @@ void gui_ShowMathPanel(Dialogs & d)
}
void gui_ShowMinipage(InsetMinipage * im, Dialogs & d)
{
d.showMinipage(im);
}
void gui_UpdateMinipage(InsetMinipage * im, Dialogs & d)
{
d.updateMinipage(im);
}
void gui_ShowParagraph(Dialogs & d)
{
d.showParagraph();

View File

@ -17,7 +17,6 @@
class Dialogs;
class InsetGraphics;
class InsetMinipage;
class InsetTabular;
extern "C" {
@ -33,8 +32,6 @@ void gui_ShowForks(Dialogs &);
void gui_ShowGraphics(InsetGraphics *, Dialogs &);
void gui_ShowLogFile(Dialogs &);
void gui_ShowMathPanel(Dialogs &);
void gui_ShowMinipage(InsetMinipage *, Dialogs &);
void gui_UpdateMinipage(InsetMinipage *, Dialogs &);
void gui_ShowParagraph(Dialogs &);
void gui_UpdateParagraph(Dialogs &);
void gui_ShowPreamble(Dialogs &);

View File

@ -1,3 +1,20 @@
2003-03-07 Angus Leeming <leeming@lyx.org>
* Dialogs.C:
* Dialogs2.C:
* Dialogs_impl.h: remove minipage dialog.
* Dialogs3.C: add minipage dialog. No longer use the bibitem, include,
label or url controllers; use ControlCommand instead.
* QBibitem.[Ch]:
* QIndex.[Ch]:
* QURL.[Ch]: changes due to use of ControlCommand, above
* QBibitemDialog.C: no need to include controller.
* QMinipage.[Ch]: changes to use the new Dialog-based scheme.
2003-03-06 Alfredo Braunstein <abraunst@libero.it>
* qscreen.C: use LyXText::top_y() instead of LyXText::first_y

View File

@ -33,7 +33,6 @@ Dialogs::Impl::Impl(LyXView & lv, Dialogs & d)
file(lv, d),
graphics(lv, d),
logfile(lv, d),
minipage(lv, d),
paragraph(lv, d),
prefs(lv, d),
print(lv, d),

View File

@ -76,18 +76,6 @@ void Dialogs::showMathPanel()
}
void Dialogs::showMinipage(InsetMinipage * im)
{
pimpl_->minipage.controller().showInset(im);
}
void Dialogs::updateMinipage(InsetMinipage * im)
{
pimpl_->minipage.controller().showInset(im);
}
void Dialogs::showParagraph()
{
pimpl_->paragraph.controller().show();

View File

@ -13,7 +13,6 @@
#include "Dialogs.h"
#include "Dialog.h"
#include "ControlBibitem.h"
#include "ControlBibtex.h"
#include "ControlCitation.h"
#include "ControlError.h"
@ -21,11 +20,9 @@
#include "ControlExternal.h"
#include "ControlFloat.h"
#include "ControlInclude.h"
#include "ControlIndex.h"
#include "ControlLabel.h"
#include "ControlMinipage.h"
#include "ControlRef.h"
#include "ControlToc.h"
#include "ControlUrl.h"
#include "ControlWrap.h"
#include "QBibitem.h"
@ -50,6 +47,8 @@
#include "QIncludeDialog.h"
#include "QIndex.h"
#include "QIndexDialog.h"
#include "QMinipage.h"
#include "QMinipageDialog.h"
#include "QRef.h"
#include "QRefDialog.h"
#include "QToc.h"
@ -80,8 +79,8 @@ namespace {
char const * const dialognames[] = { "bibitem", "bibtex", "citation",
"error", "ert", "external", "float",
"include", "index", "label", "ref",
"toc", "url", "wrap" };
"include", "index", "label", "minipage",
"ref", "toc", "url", "wrap" };
char const * const * const end_dialognames =
dialognames + (sizeof(dialognames) / sizeof(char *));
@ -114,7 +113,7 @@ Dialog * Dialogs::build(string const & name)
Dialog * dialog = new Dialog(lyxview_, name);
if (name == "bibitem") {
dialog->setController(new ControlBibitem(*dialog));
dialog->setController(new ControlCommand(*dialog, name));
dialog->setView(new QBibitem(*dialog));
dialog->setButtonController(new OkCancelReadOnlyBC);
} else if (name == "bibtex") {
@ -146,17 +145,21 @@ Dialog * Dialogs::build(string const & name)
dialog->setView(new QInclude(*dialog));
dialog->setButtonController(new OkApplyCancelReadOnlyBC);
} else if (name == "index") {
dialog->setController(new ControlIndex(*dialog));
dialog->setController(new ControlCommand(*dialog, name));
dialog->setView(new QIndex(*dialog,
qt_("LyX: Insert Index Entry"),
qt_("&Keyword")));
dialog->setButtonController(new NoRepeatedApplyReadOnlyBC);
} else if (name == "label") {
dialog->setController(new ControlLabel(*dialog));
dialog->setController(new ControlCommand(*dialog, name));
dialog->setView(new QIndex(*dialog,
qt_("LyX: Insert Label"),
qt_("&Label")));
dialog->setButtonController(new NoRepeatedApplyReadOnlyBC);
} else if (name == "minipage") {
dialog->setController(new ControlMinipage(*dialog));
dialog->setView(new QMinipage(*dialog));
dialog->setButtonController(new NoRepeatedApplyReadOnlyBC);
} else if (name == "ref") {
dialog->setController(new ControlRef(*dialog));
dialog->setView(new QRef(*dialog));
@ -166,7 +169,7 @@ Dialog * Dialogs::build(string const & name)
dialog->setView(new QToc(*dialog));
dialog->setButtonController(new OkCancelBC);
} else if (name == "url") {
dialog->setController(new ControlUrl(*dialog));
dialog->setController(new ControlCommand(*dialog, name));
dialog->setView(new QURL(*dialog));
dialog->setButtonController(new NoRepeatedApplyReadOnlyBC);
} else if (name == "wrap") {

View File

@ -22,7 +22,6 @@
#include "ControlGraphics.h"
#include "insets/insetgraphicsParams.h"
#include "ControlLog.h"
#include "ControlMinipage.h"
#include "ControlParagraph.h"
#include "ControlPrefs.h"
#include "ControlPrint.h"
@ -52,8 +51,6 @@
#include "QGraphicsDialog.h"
#include "QLog.h"
#include "QLogDialog.h"
#include "QMinipage.h"
#include "QMinipageDialog.h"
#include "QParagraph.h"
#include "QParagraphDialog.h"
#include "QPrefs.h"
@ -109,9 +106,6 @@ GraphicsDialog;
typedef GUI<ControlLog, QLog, OkCancelPolicy, Qt2BC>
LogFileDialog;
typedef GUI<ControlMinipage, QMinipage, NoRepeatedApplyReadOnlyPolicy, Qt2BC>
MinipageDialog;
typedef GUI<ControlParagraph, QParagraph, OkApplyCancelReadOnlyPolicy, Qt2BC>
ParagraphDialog;
@ -158,7 +152,6 @@ struct Dialogs::Impl {
FileDialog file;
GraphicsDialog graphics;
LogFileDialog logfile;
MinipageDialog minipage;
ParagraphDialog paragraph;
PrefsDialog prefs;
PrintDialog print;

View File

@ -13,7 +13,7 @@
#include "support/lstrings.h"
#include "ControlBibitem.h"
#include "ControlCommand.h"
#include "qt_helpers.h"
#include "debug.h"
@ -24,7 +24,7 @@
#include "QBibitem.h"
#include "Qt2BC.h"
typedef QController<ControlBibitem, QView<QBibitemDialog> > base_class;
typedef QController<ControlCommand, QView<QBibitemDialog> > base_class;
QBibitem::QBibitem(Dialog & parent)

View File

@ -15,11 +15,11 @@
#include "QDialogView.h"
class ControlBibitem;
class ControlCommand;
class QBibitemDialog;
class QBibitem
: public QController<ControlBibitem, QView<QBibitemDialog> >
: public QController<ControlCommand, QView<QBibitemDialog> >
{
public:
friend class QBibitemDialog;

View File

@ -10,9 +10,6 @@
#include <config.h>
#include "ControlBibitem.h"
#include <qpushbutton.h>
#include <qlineedit.h>

View File

@ -11,7 +11,7 @@
#include <config.h>
#include "ControlIndex.h"
#include "ControlCommand.h"
#include "qt_helpers.h"
#include "QIndexDialog.h"

View File

@ -26,11 +26,11 @@
#include <qcombobox.h>
#include <qlineedit.h>
typedef Qt2CB<ControlMinipage, Qt2DB<QMinipageDialog> > base_class;
typedef QController<ControlMinipage, QView<QMinipageDialog> > base_class;
QMinipage::QMinipage()
: base_class(qt_("LyX: Minipage Settings"))
QMinipage::QMinipage(Dialog & parent)
: base_class(parent, qt_("LyX: Minipage Settings"))
{
}
@ -57,9 +57,9 @@ void QMinipage::apply()
if (dialog_->widthED->text().isEmpty())
unit = LyXLength::UNIT_NONE;
MinipageParams & params = controller().params();
InsetMinipage::Params & params = controller().params();
params.pageWidth = LyXLength(value, unit);
params.width = LyXLength(value, unit);
switch (dialog_->valignCO->currentItem()) {
case 0:
@ -90,9 +90,9 @@ string const numtostr(double val)
void QMinipage::update_contents()
{
MinipageParams const & params = controller().params();
InsetMinipage::Params const & params = controller().params();
LyXLength len(params.pageWidth);
LyXLength len(params.width);
dialog_->widthED->setText(toqstr(numtostr(len.value())));
dialog_->unitsLC->setCurrentItem(len.unit());
lyxerr << "width " << numtostr(len.value())

View File

@ -13,20 +13,21 @@
#define QMINIPAGE_H
#include "Qt2Base.h"
#include "QDialogView.h"
class ControlMinipage;
class QMinipageDialog;
///
class QMinipage
: public Qt2CB<ControlMinipage, Qt2DB<QMinipageDialog> >
: public QController<ControlMinipage, QView<QMinipageDialog> >
{
public:
///
friend class QMinipageDialog;
///
QMinipage();
QMinipage(Dialog &);
private:
/// Apply changes
virtual void apply();

View File

@ -10,8 +10,7 @@
#include <config.h>
#include "ControlUrl.h"
#include "ControlCommand.h"
#include "debug.h"
#include "qt_helpers.h"
@ -23,8 +22,7 @@
#include <qpushbutton.h>
#include <qlineedit.h>
typedef QController<ControlUrl, QView<QURLDialog> > base_class;
typedef QController<ControlCommand, QView<QURLDialog> > base_class;
QURL::QURL(Dialog & parent)
: base_class(parent, qt_("LyX: Insert URL"))

View File

@ -15,12 +15,12 @@
#include "QDialogView.h"
class ControlUrl;
class ControlCommand;
class QURLDialog;
class QURL :
public QController<ControlUrl, QView<QURLDialog> >
public QController<ControlCommand, QView<QURLDialog> >
{
public:
friend class QURLDialog;

View File

@ -1,3 +1,18 @@
2003-03-07 Angus Leeming <leeming@lyx.org>
* Dialogs.C:
* Dialogs2.C:
* Dialogs_impl.h: remove minipage dialog.
* Dialogs3.C: add minipage dialog. No longer use the bibitem, include,
label or url controllers; use ControlCommand instead.
* FormBibitem.[Ch]:
* FormIndex.[Ch]: changes due to use of ControlCommand, above
* FormMinipage.[Ch]:
* forms/form_minipage.fd: changes to use the new Dialog-based scheme.
2003-03-06 Alfredo Braunstein <abraunst@libero.it>
* xscreen.C: use LyXText::top_y() instead of LyXText::first_y

View File

@ -35,7 +35,6 @@ Dialogs::Impl::Impl(LyXView & lv, Dialogs & d)
graphics(lv, d),
logfile(lv, d),
mathpanel(lv, d),
minipage(lv, d),
paragraph(lv, d),
preamble(lv, d),
preferences(lv, d),

View File

@ -75,18 +75,6 @@ void Dialogs::showMathPanel()
}
void Dialogs::showMinipage(InsetMinipage * im)
{
pimpl_->minipage.controller().showInset(im);
}
void Dialogs::updateMinipage(InsetMinipage * im)
{
pimpl_->minipage.controller().showInset(im);
}
void Dialogs::showParagraph()
{
pimpl_->paragraph.controller().show();

View File

@ -15,57 +15,45 @@
#include "Tooltips.h"
#include "ControlBibitem.h"
#include "ControlBibtex.h"
#include "ControlCitation.h"
#include "ControlCommand.h"
#include "ControlError.h"
#include "ControlERT.h"
#include "ControlExternal.h"
#include "ControlFloat.h"
#include "ControlInclude.h"
#include "ControlMinipage.h"
#include "ControlRef.h"
#include "ControlToc.h"
#include "ControlWrap.h"
#include "FormBibitem.h"
#include "forms/form_bibitem.h"
#include "ControlBibtex.h"
#include "FormBibtex.h"
#include "forms/form_bibtex.h"
#include "ControlCitation.h"
#include "FormCitation.h"
#include "forms/form_citation.h"
#include "ControlError.h"
#include "FormError.h"
#include "forms/form_error.h"
#include "ControlERT.h"
#include "FormERT.h"
#include "forms/form_ert.h"
#include "ControlExternal.h"
#include "FormExternal.h"
#include "forms/form_external.h"
#include "ControlFloat.h"
#include "FormFloat.h"
#include "forms/form_float.h"
#include "ControlInclude.h"
#include "FormInclude.h"
#include "forms/form_include.h"
#include "ControlIndex.h"
#include "ControlLabel.h"
#include "FormText.h"
#include "forms/form_text.h"
#include "ControlRef.h"
#include "FormMinipage.h"
#include "forms/form_minipage.h"
#include "FormRef.h"
#include "forms/form_ref.h"
#include "ControlToc.h"
#include "FormText.h"
#include "forms/form_text.h"
#include "FormToc.h"
#include "forms/form_toc.h"
#include "ControlUrl.h"
#include "FormUrl.h"
#include "forms/form_url.h"
#include "ControlWrap.h"
#include "FormWrap.h"
#include "forms/form_wrap.h"
@ -95,8 +83,8 @@ namespace {
// "url", "wrap" };
char const * const dialognames[] = { "bibitem", "bibtex", "citation",
"error", "ert", "external", "float",
"include", "index", "label", "ref",
"toc", "url", "wrap" };
"include", "index", "label", "minipage",
"ref", "toc", "url", "wrap" };
char const * const * const end_dialognames =
dialognames + (sizeof(dialognames) / sizeof(char *));
@ -129,7 +117,7 @@ Dialog * Dialogs::build(string const & name)
Dialog * dialog = new Dialog(lyxview_, name);
if (name == "bibitem") {
dialog->setController(new ControlBibitem(*dialog));
dialog->setController(new ControlCommand(*dialog, name));
dialog->setView(new FormBibitem(*dialog));
dialog->setButtonController(new OkCancelReadOnlyBC);
} else if (name == "bibtex") {
@ -161,15 +149,19 @@ Dialog * Dialogs::build(string const & name)
dialog->setView(new FormInclude(*dialog));
dialog->setButtonController(new OkApplyCancelReadOnlyBC);
} else if (name == "index") {
dialog->setController(new ControlIndex(*dialog));
dialog->setController(new ControlCommand(*dialog, name));
dialog->setView(new FormText(*dialog,
_("Index"), _("Keyword:|#K")));
dialog->setButtonController(new NoRepeatedApplyReadOnlyBC);
} else if (name == "label") {
dialog->setController(new ControlLabel(*dialog));
dialog->setController(new ControlCommand(*dialog, name));
dialog->setView(new FormText(*dialog,
_("Label"), _("Label:|#L")));
dialog->setButtonController(new NoRepeatedApplyReadOnlyBC);
} else if (name == "minipage") {
dialog->setController(new ControlMinipage(*dialog));
dialog->setView(new FormMinipage(*dialog));
dialog->setButtonController(new NoRepeatedApplyReadOnlyBC);
} else if (name == "ref") {
dialog->setController(new ControlRef(*dialog));
dialog->setView(new FormRef(*dialog));
@ -179,7 +171,7 @@ Dialog * Dialogs::build(string const & name)
dialog->setView(new FormToc(*dialog));
dialog->setButtonController(new OkCancelBC);
} else if (name == "url") {
dialog->setController(new ControlUrl(*dialog));
dialog->setController(new ControlCommand(*dialog, name));
dialog->setView(new FormUrl(*dialog));
dialog->setButtonController(new NoRepeatedApplyReadOnlyBC);
} else if (name == "wrap") {

View File

@ -55,10 +55,6 @@
#include "FormMathsPanel.h"
#include "forms/form_maths_panel.h"
#include "ControlMinipage.h"
#include "FormMinipage.h"
#include "forms/form_minipage.h"
#include "ControlParagraph.h"
#include "FormParagraph.h"
#include "forms/form_paragraph.h"
@ -135,9 +131,6 @@ LogFileDialog;
typedef GUI<ControlMath, FormMathsPanel, OkCancelReadOnlyPolicy, xformsBC>
MathPanelDialog;
typedef GUI<ControlMinipage, FormMinipage, NoRepeatedApplyReadOnlyPolicy, xformsBC>
MinipageDialog;
typedef GUI<ControlParagraph, FormParagraph, OkApplyCancelReadOnlyPolicy, xformsBC>
ParagraphDialog;
@ -188,7 +181,6 @@ struct Dialogs::Impl {
GraphicsDialog graphics;
LogFileDialog logfile;
MathPanelDialog mathpanel;
MinipageDialog minipage;
ParagraphDialog paragraph;
PreambleDialog preamble;
PreferencesDialog preferences;

View File

@ -12,7 +12,7 @@
#include <config.h>
#include "xformsBC.h"
#include "ControlBibitem.h"
#include "ControlCommand.h"
#include "FormBibitem.h"
#include "Tooltips.h"
#include "forms/form_bibitem.h"
@ -20,7 +20,7 @@
#include "gettext.h"
#include "support/lstrings.h" // compare
typedef FormController<ControlBibitem, FormView<FD_bibitem> > base_class;
typedef FormController<ControlCommand, FormView<FD_bibitem> > base_class;
FormBibitem::FormBibitem(Dialog & parent)
: base_class(parent, _("Bibliography Entry"))

View File

@ -16,13 +16,13 @@
#include "FormDialogView.h"
class ControlBibitem;
class ControlCommand;
struct FD_bibitem;
/**
* For bibliography entry editing
*/
class FormBibitem : public FormController<ControlBibitem, FormView<FD_bibitem> > {
class FormBibitem : public FormController<ControlCommand, FormView<FD_bibitem> > {
public:
///
FormBibitem(Dialog &);

View File

@ -21,10 +21,10 @@
#include "xforms_helpers.h"
#include FORMS_H_LOCATION
typedef FormCB<ControlMinipage, FormDB<FD_minipage> > base_class;
typedef FormController<ControlMinipage, FormView<FD_minipage> > base_class;
FormMinipage::FormMinipage()
: base_class(_("Minipage Options"))
FormMinipage::FormMinipage(Dialog & parent)
: base_class(parent, _("Minipage Options"))
{}
@ -57,7 +57,7 @@ void FormMinipage::build()
void FormMinipage::apply()
{
controller().params().pageWidth =
controller().params().width =
LyXLength(getLengthFromWidgets(dialog_->input_width,
dialog_->choice_width_units));
@ -72,7 +72,7 @@ void FormMinipage::apply()
void FormMinipage::update()
{
LyXLength len(controller().params().pageWidth);
LyXLength len(controller().params().width);
fl_set_input(dialog_->input_width, tostr(len.value()).c_str());
fl_set_choice(dialog_->choice_width_units, len.unit() + 1);

View File

@ -12,8 +12,7 @@
#ifndef FORMMINIPAGE_H
#define FORMMINIPAGE_H
#include "FormBase.h"
#include "FormDialogView.h"
class ControlMinipage;
struct FD_minipage;
@ -22,10 +21,10 @@ struct FD_minipage;
Dialog.
*/
class FormMinipage
: public FormCB<ControlMinipage, FormDB<FD_minipage> > {
: public FormController<ControlMinipage, FormView<FD_minipage> > {
public:
///
FormMinipage();
FormMinipage(Dialog &);
private:
/// Set the Params variable for the Controller.
virtual void apply();

View File

@ -13,12 +13,12 @@
#include "xformsBC.h"
#include "ControlUrl.h"
#include "ControlCommand.h"
#include "FormUrl.h"
#include "forms/form_url.h"
#include FORMS_H_LOCATION
typedef FormController<ControlUrl, FormView<FD_url> > base_class;
typedef FormController<ControlCommand, FormView<FD_url> > base_class;
FormUrl::FormUrl(Dialog & parent)
: base_class(parent, _("Url"))

View File

@ -15,12 +15,12 @@
#include "FormDialogView.h"
class ControlUrl;
class ControlCommand;
struct FD_url;
/** This class provides an XForms implementation of the Url Dialog.
*/
class FormUrl : public FormController<ControlUrl, FormView<FD_url> > {
class FormUrl : public FormController<ControlCommand, FormView<FD_url> > {
public:
///
FormUrl(Dialog &);

View File

@ -81,7 +81,7 @@ shortcut:
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: input_width
callback: C_FormBaseInputCB
callback: C_FormDialogView_InputCB
argument: 0
--------------------
@ -99,7 +99,7 @@ shortcut:
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: choice_width_units
callback: C_FormBaseInputCB
callback: C_FormDialogView_InputCB
argument: 0
--------------------
@ -135,7 +135,7 @@ shortcut:
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: radio_top
callback: C_FormBaseInputCB
callback: C_FormDialogView_InputCB
argument: 0
--------------------
@ -153,7 +153,7 @@ shortcut:
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: radio_middle
callback: C_FormBaseInputCB
callback: C_FormDialogView_InputCB
argument: 0
--------------------
@ -171,7 +171,7 @@ shortcut:
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: radio_bottom
callback: C_FormBaseInputCB
callback: C_FormDialogView_InputCB
argument: 0
--------------------
@ -207,7 +207,7 @@ shortcut:
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: button_close
callback: C_FormBaseCancelCB
callback: C_FormDialogView_CancelCB
argument: 0
--------------------
@ -225,7 +225,7 @@ shortcut:
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: button_apply
callback: C_FormBaseApplyCB
callback: C_FormDialogView_ApplyCB
argument: 0
--------------------
@ -243,7 +243,7 @@ shortcut: ^M
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: button_ok
callback: C_FormBaseOKCB
callback: C_FormDialogView_OKCB
argument: 0
--------------------
@ -261,7 +261,7 @@ shortcut:
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: button_restore
callback: C_FormBaseRestoreCB
callback: C_FormDialogView_RestoreCB
argument: 0
--------------------

View File

@ -1,3 +1,20 @@
2003-03-07 Angus Leeming <leeming@lyx.org>
* insetcommand.C (string2params):
* insetexternal.C (string2params):
* insetfloat.C (string2params):
* insetinclude.C (string2params):
* insetwrap.C (string2params): use LyXLeX more.
* insetert.[Ch]:
* insetexternal.[Ch]:
* insetfloat.[Ch]:
* insetinclude.[Ch]:
* insetwrap.[Ch]: change Mailer::name_ to be static.
* insetminipage.[Ch]: define a new class InsetMinipageMailer and use
it to communicate with the frontend dialogs.
2003-03-06 Alfredo Braunstein <abraunst@libero.it>
* insettext.C:

View File

@ -101,16 +101,15 @@ void InsetCommandMailer::string2params(string const & in,
params.setContents(string());
params.setOptions(string());
string name;
string body = split(in, name, ' ');
if (body.empty())
return;
istringstream data(body);
istringstream data(in);
LyXLex lex(0,0);
lex.setStream(data);
if (lex.isOK()) {
lex.next();
string const name = lex.getString();
}
params.read(lex);
}

View File

@ -740,14 +740,16 @@ void InsetERT::update(BufferView * bv, LyXFont const & font,
}
string const InsetERTMailer::name_("ert");
InsetERTMailer::InsetERTMailer(InsetERT & inset)
: name_("ert"), inset_(inset)
: inset_(inset)
{}
string const InsetERTMailer::inset2string() const
{
return params2string(name(), inset_.status());
return params2string(inset_.status());
}
@ -767,7 +769,7 @@ void InsetERTMailer::string2params(string const & in,
string const
InsetERTMailer::params2string(string const & name, InsetERT::ERTStatus status)
InsetERTMailer::params2string(InsetERT::ERTStatus status)
{
return name + ' ' + tostr(status);
return name_ + ' ' + tostr(status);
}

View File

@ -167,11 +167,10 @@ public:
///
static void string2params(string const &, InsetERT::ERTStatus &);
///
static string const params2string(string const & name,
InsetERT::ERTStatus);
static string const params2string(InsetERT::ERTStatus);
private:
///
string const name_;
static string const name_;
///
InsetERT & inset_;
};

View File

@ -360,15 +360,16 @@ bool operator!=(InsetExternal::Params const & left,
}
string const InsetExternalMailer::name_("external");
InsetExternalMailer::InsetExternalMailer(InsetExternal & inset)
: name_("external"), inset_(inset)
: inset_(inset)
{}
string const InsetExternalMailer::inset2string() const
{
return params2string(name(), inset_.params());
return params2string(inset_.params());
}
@ -377,21 +378,25 @@ void InsetExternalMailer::string2params(string const & in,
{
params = InsetExternal::Params();
string name;
string body = split(in, name, ' ');
istringstream data(in);
LyXLex lex(0,0);
lex.setStream(data);
if (name != "external" || body.empty())
return;
if (lex.isOK()) {
lex.next();
string const token = lex.getString();
if (token != name_)
return;
}
// This is part of the inset proper that is usually swallowed
// by Buffer::readInset
body = split(body, name, ' ');
if (name != "External")
return;
istringstream data(body);
LyXLex lex(0,0);
lex.setStream(data);
if (lex.isOK()) {
lex.next();
string const token = lex.getString();
if (token != "External")
return;
}
InsetExternal inset;
inset.read(0, lex);
@ -400,13 +405,12 @@ void InsetExternalMailer::string2params(string const & in,
string const
InsetExternalMailer::params2string(string const & name,
InsetExternal::Params const & params)
InsetExternalMailer::params2string(InsetExternal::Params const & params)
{
InsetExternal inset;
inset.setFromParams(params);
ostringstream data;
data << name << ' ';
data << name_ << ' ';
inset.write(0, data);
data << "\\end_inset\n";

View File

@ -143,11 +143,10 @@ public:
///
static void string2params(string const &, InsetExternal::Params &);
///
static string const params2string(string const & name,
InsetExternal::Params const &);
static string const params2string(InsetExternal::Params const &);
private:
///
string const name_;
static string const name_;
///
InsetExternal & inset_;
};

View File

@ -395,14 +395,16 @@ void InsetFloat::addToToc(toc::TocList & toclist, Buffer const * buf) const
}
string const InsetFloatMailer::name_("float");
InsetFloatMailer::InsetFloatMailer(InsetFloat & inset)
: name_("float"), inset_(inset)
: inset_(inset)
{}
string const InsetFloatMailer::inset2string() const
{
return params2string(name(), inset_.params());
return params2string(inset_.params());
}
@ -411,32 +413,35 @@ void InsetFloatMailer::string2params(string const & in,
{
params = InsetFloatParams();
string name;
string body = split(in, name, ' ');
istringstream data(in);
LyXLex lex(0,0);
lex.setStream(data);
if (name != "float" || body.empty())
return;
if (lex.isOK()) {
lex.next();
string const token = lex.getString();
if (token != name_)
return;
}
// This is part of the inset proper that is usually swallowed
// by Buffer::readInset
body = split(body, name, '\n');
if (!prefixIs(name, "Float "))
return;
istringstream data(body);
LyXLex lex(0,0);
lex.setStream(data);
if (lex.isOK()) {
lex.next();
string const token = lex.getString();
if (token != "Float" || !lex.eatLine())
return;
}
params.read(lex);
}
string const
InsetFloatMailer::params2string(string const & name,
InsetFloatParams const & params)
InsetFloatMailer::params2string(InsetFloatParams const & params)
{
ostringstream data;
data << name << ' ';
data << name_ << ' ';
params.write(data);
return data.str();

View File

@ -108,11 +108,10 @@ public:
///
static void string2params(string const &, InsetFloatParams &);
///
static string const params2string(string const & name,
InsetFloatParams const &);
static string const params2string(InsetFloatParams const &);
private:
///
string const name_;
static string const name_;
///
InsetFloat & inset_;
};

View File

@ -610,14 +610,16 @@ void InsetInclude::PreviewImpl::restartLoading()
}
string const InsetIncludeMailer::name_("include");
InsetIncludeMailer::InsetIncludeMailer(InsetInclude & inset)
: name_("include"), inset_(inset)
: inset_(inset)
{}
string const InsetIncludeMailer::inset2string() const
{
return params2string(name(), inset_.params());
return params2string(inset_.params());
}
@ -626,21 +628,25 @@ void InsetIncludeMailer::string2params(string const & in,
{
params = InsetInclude::Params();
string name;
string body = split(in, name, ' ');
istringstream data(in);
LyXLex lex(0,0);
lex.setStream(data);
if (name != "include" || body.empty())
return;
if (lex.isOK()) {
lex.next();
string const token = lex.getString();
if (token != name_)
return;
}
// This is part of the inset proper that is usually swallowed
// by Buffer::readInset
body = split(body, name, ' ');
if (name != "Include")
return;
istringstream data(body);
LyXLex lex(0,0);
lex.setStream(data);
if (lex.isOK()) {
lex.next();
string const token = lex.getString();
if (token != "Include")
return;
}
InsetInclude inset(params);
inset.read(0, lex);
@ -649,13 +655,12 @@ void InsetIncludeMailer::string2params(string const & in,
string const
InsetIncludeMailer::params2string(string const & name,
InsetInclude::Params const & params)
InsetIncludeMailer::params2string(InsetInclude::Params const & params)
{
InsetInclude inset(params);
inset.set(params);
ostringstream data;
data << name << ' ';
data << name_ << ' ';
inset.write(0, data);
data << "\\end_inset\n";

View File

@ -164,11 +164,10 @@ public:
///
static void string2params(string const &, InsetInclude::Params &);
///
static string const params2string(string const & name,
InsetInclude::Params const &);
static string const params2string(InsetInclude::Params const &);
private:
///
string const name_;
static string const name_;
///
InsetInclude & inset_;
};

View File

@ -13,18 +13,21 @@
#include "insetminipage.h"
#include "insettext.h"
#include "BufferView.h"
#include "debug.h"
#include "funcrequest.h"
#include "gettext.h"
#include "lyxfont.h"
#include "BufferView.h"
#include "lyxlex.h"
#include "lyxtext.h"
#include "frontends/LyXView.h"
#include "frontends/Dialogs.h"
#include "lyxtext.h"
#include "insets/insettext.h"
#include "support/LOstream.h"
#include "support/lstrings.h"
#include "debug.h"
#include "gettext.h"
#include "lyxlex.h"
using std::ostream;
using std::endl;
@ -59,8 +62,7 @@ using std::endl;
// (Lgb)
InsetMinipage::InsetMinipage(BufferParams const & bp)
: InsetCollapsable(bp), pos_(center),
inner_pos_(inner_center), width_(100, LyXLength::PCW)
: InsetCollapsable(bp)
{
setLabel(_("minipage"));
LyXFont font(LyXFont::ALL_SANE);
@ -86,9 +88,7 @@ InsetMinipage::InsetMinipage(BufferParams const & bp)
InsetMinipage::InsetMinipage(InsetMinipage const & in, bool same_id)
: InsetCollapsable(in, same_id),
pos_(in.pos_), inner_pos_(in.inner_pos_),
height_(in.height_), width_(in.width_)
: InsetCollapsable(in, same_id), params_(in.params_)
{}
@ -100,29 +100,53 @@ Inset * InsetMinipage::clone(Buffer const &, bool same_id) const
InsetMinipage::~InsetMinipage()
{
hideDialog();
InsetMinipageMailer mailer(*this);
mailer.hideDialog();
}
void InsetMinipage::write(Buffer const * buf, ostream & os) const
dispatch_result InsetMinipage::localDispatch(FuncRequest const & cmd)
{
os << getInsetName() << '\n'
<< "position " << pos_ << '\n'
<< "inner_position " << inner_pos_ << '\n'
<< "height \"" << height_.asString() << "\"\n"
<< "width \"" << width_.asString() << "\"\n";
InsetCollapsable::write(buf, os);
Inset::RESULT result = UNDISPATCHED;
switch (cmd.action) {
case LFUN_INSET_MODIFY: {
InsetMinipage::Params params;
InsetMinipageMailer::string2params(cmd.argument, params);
params_.pos = params.pos;
params_.width = params.width;
cmd.view()->updateInset(this, true);
result = DISPATCHED;
}
break;
default:
result = InsetCollapsable::localDispatch(cmd);
}
return result;
}
void InsetMinipage::read(Buffer const * buf, LyXLex & lex)
void InsetMinipage::Params::write(ostream & os) const
{
os << "Minipage" << '\n'
<< "position " << pos << '\n'
<< "inner_position " << inner_pos << '\n'
<< "height \"" << height.asString() << "\"\n"
<< "width \"" << width.asString() << "\"\n";
}
void InsetMinipage::Params::read(LyXLex & lex)
{
if (lex.isOK()) {
lex.next();
string const token = lex.getString();
if (token == "position") {
lex.next();
pos_ = static_cast<Position>(lex.getInteger());
pos = static_cast<Position>(lex.getInteger());
} else {
lyxerr << "InsetMinipage::Read: Missing 'position'-tag!"
<< endl;
@ -135,7 +159,7 @@ void InsetMinipage::read(Buffer const * buf, LyXLex & lex)
string const token = lex.getString();
if (token == "inner_position") {
lex.next();
inner_pos_ = static_cast<InnerPosition>(lex.getInteger());
inner_pos = static_cast<InnerPosition>(lex.getInteger());
} else {
lyxerr << "InsetMinipage::Read: Missing 'inner_position'-tag!"
<< endl;
@ -148,7 +172,7 @@ void InsetMinipage::read(Buffer const * buf, LyXLex & lex)
string const token = lex.getString();
if (token == "height") {
lex.next();
height_ = LyXLength(lex.getString());
height = LyXLength(lex.getString());
} else {
lyxerr << "InsetMinipage::Read: Missing 'height'-tag!"
<< endl;
@ -161,7 +185,7 @@ void InsetMinipage::read(Buffer const * buf, LyXLex & lex)
string const token = lex.getString();
if (token == "width") {
lex.next();
width_ = LyXLength(lex.getString());
width = LyXLength(lex.getString());
} else {
lyxerr << "InsetMinipage::Read: Missing 'width'-tag!"
<< endl;
@ -169,6 +193,19 @@ void InsetMinipage::read(Buffer const * buf, LyXLex & lex)
lex.pushToken(token);
}
}
}
void InsetMinipage::write(Buffer const * buf, ostream & os) const
{
params_.write(os);
InsetCollapsable::write(buf, os);
}
void InsetMinipage::read(Buffer const * buf, LyXLex & lex)
{
params_.read(lex);
InsetCollapsable::read(buf, lex);
}
@ -180,7 +217,7 @@ int InsetMinipage::ascent(BufferView * bv, LyXFont const & font) const
else {
// Take placement into account.
int i = 0;
switch (pos_) {
switch (params_.pos) {
case top:
i = InsetCollapsable::ascent(bv, font);
break;
@ -204,7 +241,7 @@ int InsetMinipage::descent(BufferView * bv, LyXFont const & font) const
else {
// Take placement into account.
int i = 0;
switch (pos_) {
switch (params_.pos) {
case top:
i = InsetCollapsable::descent(bv, font);
break;
@ -231,7 +268,7 @@ int InsetMinipage::latex(Buffer const * buf,
ostream & os, bool fragile, bool fp) const
{
string s_pos;
switch (pos_) {
switch (params_.pos) {
case top:
s_pos += 't';
break;
@ -243,7 +280,7 @@ int InsetMinipage::latex(Buffer const * buf,
break;
}
os << "\\begin{minipage}[" << s_pos << "]{"
<< width_.asLatexString() << "}%\n";
<< params_.width.asLatexString() << "}%\n";
int i = inset.latex(buf, os, fragile, fp);
@ -263,14 +300,14 @@ bool InsetMinipage::insetAllowed(Inset::Code code) const
InsetMinipage::Position InsetMinipage::pos() const
{
return pos_;
return params_.pos;
}
void InsetMinipage::pos(InsetMinipage::Position p)
{
if (pos_ != p) {
pos_ = p;
if (params_.pos != p) {
params_.pos = p;
need_update = FULL;
}
}
@ -278,26 +315,26 @@ void InsetMinipage::pos(InsetMinipage::Position p)
InsetMinipage::InnerPosition InsetMinipage::innerPos() const
{
return inner_pos_;
return params_.inner_pos;
}
void InsetMinipage::innerPos(InsetMinipage::InnerPosition ip)
{
inner_pos_ = ip;
params_.inner_pos = ip;
}
LyXLength const & InsetMinipage::pageHeight() const
{
return height_;
return params_.height;
}
void InsetMinipage::pageHeight(LyXLength const & ll)
{
if (height_ != ll) {
height_ = ll;
if (params_.height != ll) {
params_.height = ll;
need_update = FULL;
}
}
@ -305,14 +342,14 @@ void InsetMinipage::pageHeight(LyXLength const & ll)
LyXLength const & InsetMinipage::pageWidth() const
{
return width_;
return params_.width;
}
void InsetMinipage::pageWidth(LyXLength const & ll)
{
if (ll != width_) {
width_ = ll;
if (ll != params_.width) {
params_.width = ll;
need_update = FULL;
}
}
@ -320,8 +357,12 @@ void InsetMinipage::pageWidth(LyXLength const & ll)
bool InsetMinipage::showInsetDialog(BufferView * bv) const
{
if (!inset.showInsetDialog(bv))
bv->owner()->getDialogs().showMinipage(const_cast<InsetMinipage *>(this));
if (!inset.showInsetDialog(bv)) {
InsetMinipage * tmp = const_cast<InsetMinipage *>(this);
InsetMinipageMailer mailer(*tmp);
mailer.showDialog();
}
return true;
}
@ -333,7 +374,7 @@ int InsetMinipage::getMaxWidth(BufferView * bv, UpdatableInset const * inset)
static_cast<UpdatableInset*>(owner())->getMaxWidth(bv, inset) < 0) {
return -1;
}
if (!width_.zero()) {
if (!params_.width.zero()) {
int ww1 = latexTextWidth(bv);
int ww2 = InsetCollapsable::getMaxWidth(bv, inset);
if (ww2 > 0 && ww2 < ww1) {
@ -348,5 +389,65 @@ int InsetMinipage::getMaxWidth(BufferView * bv, UpdatableInset const * inset)
int InsetMinipage::latexTextWidth(BufferView * bv) const
{
return width_.inPixels(InsetCollapsable::latexTextWidth(bv));
return params_.width.inPixels(InsetCollapsable::latexTextWidth(bv));
}
InsetMinipage::Params::Params()
: pos(center),
inner_pos(inner_center),
width(100, LyXLength::PCW)
{}
string const InsetMinipageMailer:: name_("minipage");
InsetMinipageMailer::InsetMinipageMailer(InsetMinipage & inset)
: inset_(inset)
{}
string const InsetMinipageMailer::inset2string() const
{
return params2string(inset_.params());
}
void InsetMinipageMailer::string2params(string const & in,
InsetMinipage::Params & params)
{
params = InsetMinipage::Params();
istringstream data(in);
LyXLex lex(0,0);
lex.setStream(data);
if (lex.isOK()) {
lex.next();
string const token = lex.getString();
if (token != "minipage")
return;
}
// This is part of the inset proper that is usually swallowed
// by Buffer::readInset
if (lex.isOK()) {
lex.next();
string const token = lex.getString();
if (token != "Minipage")
return;
}
params.read(lex);
}
string const
InsetMinipageMailer::params2string(InsetMinipage::Params const & params)
{
ostringstream data;
data << name_ << ' ';
params.write(data);
return data.str();
}

View File

@ -17,8 +17,6 @@
#include "insetcollapsable.h"
#include "lyxlength.h"
#include <boost/signals/signal0.hpp>
/** The minipage inset
*/
@ -37,6 +35,25 @@ public:
inner_bottom,
inner_stretch
};
///
struct Params {
///
Params();
///
Position pos;
///
InnerPosition inner_pos;
///
LyXLength height;
///
LyXLength width;
///
void write(std::ostream & os) const;
///
void read(LyXLex & lex);
};
///
InsetMinipage(BufferParams const &);
///
@ -44,6 +61,8 @@ public:
///
~InsetMinipage();
///
virtual dispatch_result localDispatch(FuncRequest const & cmd);
///
void write(Buffer const * buf, std::ostream & os) const;
///
void read(Buffer const * buf, LyXLex & lex);
@ -78,8 +97,6 @@ public:
///
void pageWidth(LyXLength const &);
///
boost::signal0<void> hideDialog;
///
int getMaxWidth(BufferView *, UpdatableInset const *) const;
///
bool needFullRow() const { return false; }
@ -91,16 +108,38 @@ public:
bool showInsetDialog(BufferView *) const;
///
int latexTextWidth(BufferView *) const;
///
void params(Params const & p) { params_ = p; }
///
Params const & params() const { return params_; }
private:
///
Position pos_;
Params params_;
};
#include "mailinset.h"
class InsetMinipageMailer : public MailInset {
public:
///
InnerPosition inner_pos_;
InsetMinipageMailer(InsetMinipage & inset);
///
LyXLength height_;
virtual Inset & inset() const { return inset_; }
///
LyXLength width_;
virtual string const & name() const { return name_; }
///
virtual string const inset2string() const;
///
static void string2params(string const &, InsetMinipage::Params &);
///
static string const params2string(InsetMinipage::Params const &);
private:
///
static string const name_;
///
InsetMinipage & inset_;
};
#endif

View File

@ -310,14 +310,16 @@ void InsetWrap::addToToc(toc::TocList & toclist, Buffer const * buf) const
}
string const InsetWrapMailer::name_("wrap");
InsetWrapMailer::InsetWrapMailer(InsetWrap & inset)
: name_("wrap"), inset_(inset)
: inset_(inset)
{}
string const InsetWrapMailer::inset2string() const
{
return params2string(name(), inset_.params());
return params2string(inset_.params());
}
@ -326,32 +328,35 @@ void InsetWrapMailer::string2params(string const & in,
{
params = InsetWrapParams();
string name;
string body = split(in, name, ' ');
istringstream data(in);
LyXLex lex(0,0);
lex.setStream(data);
if (name != "wrap" || body.empty())
return;
if (lex.isOK()) {
lex.next();
string const token = lex.getString();
if (token != name_)
return;
}
// This is part of the inset proper that is usually swallowed
// by Buffer::readInset
body = split(body, name, '\n');
if (!prefixIs(name, "Wrap "))
return;
istringstream data(body);
LyXLex lex(0,0);
lex.setStream(data);
if (lex.isOK()) {
lex.next();
string const token = lex.getString();
if (token != "Wrap" || !lex.eatLine())
return;
}
params.read(lex);
}
string const
InsetWrapMailer::params2string(string const & name,
InsetWrapParams const & params)
InsetWrapMailer::params2string(InsetWrapParams const & params)
{
ostringstream data;
data << name << ' ';
data << name_ << ' ';
params.write(data);
return data.str();

View File

@ -105,11 +105,10 @@ public:
///
static void string2params(string const &, InsetWrapParams &);
///
static string const params2string(string const & name,
InsetWrapParams const &);
static string const params2string(InsetWrapParams const &);
private:
///
string const name_;
static string const name_;
///
InsetWrap & inset_;
};

View File

@ -1350,6 +1350,7 @@ void LyXFunc::dispatch(FuncRequest const & ev, bool verbose)
string data;
if (name == "bibitem" ||
name == "bibtex" ||
name == "include" ||
name == "index" ||
name == "ref" ||
name == "toc" ||
@ -1359,9 +1360,6 @@ void LyXFunc::dispatch(FuncRequest const & ev, bool verbose)
} else if (name == "citation") {
InsetCommandParams p("cite");
data = InsetCommandMailer::params2string(name, p);
} else if (name == "ert") {
data = InsetERTMailer::params2string(name,
InsetERT::Open);
}
owner->getDialogs().show(name, data, 0);
}