diff --git a/src/ChangeLog b/src/ChangeLog index 2029bfbc43..b2a9bc3c6d 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2003-03-07 Angus Leeming + + * lyxfunc.C (dispatch): add "include" to LFUN_SHOW_NEW_INSET and + remove "ert". + 2003-03-06 Lars Gullik Bjønnes * ParagraphList.C (front): new function diff --git a/src/frontends/ChangeLog b/src/frontends/ChangeLog index abc2473199..29f3bb1357 100644 --- a/src/frontends/ChangeLog +++ b/src/frontends/ChangeLog @@ -1,3 +1,8 @@ +2003-03-07 Angus Leeming + + * Dialogs.h: remove showMinipage, updateMinipage. + * guiapi.[Ch]: remove gui_showMinipage, gui_updateMinipage. + 2003-03-06 Alfredo Braunstein * screen.C: use LyXText::top_y() instead of LyXText::first_y diff --git a/src/frontends/Dialogs.h b/src/frontends/Dialogs.h index c3971ffda7..745bdc13a7 100644 --- a/src/frontends/Dialogs.h +++ b/src/frontends/Dialogs.h @@ -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(); diff --git a/src/frontends/controllers/ChangeLog b/src/frontends/controllers/ChangeLog index b7bec49a68..ce6179f0bd 100644 --- a/src/frontends/controllers/ChangeLog +++ b/src/frontends/controllers/ChangeLog @@ -1,3 +1,21 @@ +2003-03-07 Angus Leeming + + * 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 * ControlWrap.[Ch]: rewrite to use the Dialog-based scheme. diff --git a/src/frontends/controllers/ControlBibitem.C b/src/frontends/controllers/ControlBibitem.C deleted file mode 100644 index cc14a6bed5..0000000000 --- a/src/frontends/controllers/ControlBibitem.C +++ /dev/null @@ -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 - -#include "ControlBibitem.h" - - -ControlBibitem::ControlBibitem(Dialog & d) - : ControlCommand(d, "bibitem") -{} diff --git a/src/frontends/controllers/ControlBibitem.h b/src/frontends/controllers/ControlBibitem.h deleted file mode 100644 index 226466a27f..0000000000 --- a/src/frontends/controllers/ControlBibitem.h +++ /dev/null @@ -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 diff --git a/src/frontends/controllers/ControlERT.C b/src/frontends/controllers/ControlERT.C index 65e05a801d..64ec796d1f 100644 --- a/src/frontends/controllers/ControlERT.C +++ b/src/frontends/controllers/ControlERT.C @@ -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)); } diff --git a/src/frontends/controllers/ControlExternal.C b/src/frontends/controllers/ControlExternal.C index 7c5ee9fd48..6006044938 100644 --- a/src/frontends/controllers/ControlExternal.C +++ b/src/frontends/controllers/ControlExternal.C @@ -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)); } diff --git a/src/frontends/controllers/ControlFloat.C b/src/frontends/controllers/ControlFloat.C index 52744e622f..3817f7f888 100644 --- a/src/frontends/controllers/ControlFloat.C +++ b/src/frontends/controllers/ControlFloat.C @@ -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)); } diff --git a/src/frontends/controllers/ControlInclude.C b/src/frontends/controllers/ControlInclude.C index aa9695f363..24fc60b552 100644 --- a/src/frontends/controllers/ControlInclude.C +++ b/src/frontends/controllers/ControlInclude.C @@ -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)); } diff --git a/src/frontends/controllers/ControlIndex.C b/src/frontends/controllers/ControlIndex.C deleted file mode 100644 index 1b1a652c0c..0000000000 --- a/src/frontends/controllers/ControlIndex.C +++ /dev/null @@ -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 - - -#include "ControlIndex.h" - - -ControlIndex::ControlIndex(Dialog & d) - : ControlCommand(d, "index") -{} diff --git a/src/frontends/controllers/ControlIndex.h b/src/frontends/controllers/ControlIndex.h deleted file mode 100644 index 48cc37a780..0000000000 --- a/src/frontends/controllers/ControlIndex.h +++ /dev/null @@ -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 diff --git a/src/frontends/controllers/ControlLabel.C b/src/frontends/controllers/ControlLabel.C deleted file mode 100644 index ba842e17b4..0000000000 --- a/src/frontends/controllers/ControlLabel.C +++ /dev/null @@ -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 - - -#include "ControlLabel.h" - - -ControlLabel::ControlLabel(Dialog & d) - : ControlCommand(d, "label") -{} diff --git a/src/frontends/controllers/ControlLabel.h b/src/frontends/controllers/ControlLabel.h deleted file mode 100644 index bd0657804c..0000000000 --- a/src/frontends/controllers/ControlLabel.h +++ /dev/null @@ -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 diff --git a/src/frontends/controllers/ControlMinipage.C b/src/frontends/controllers/ControlMinipage.C index 42d0afd684..49d305ce6d 100644 --- a/src/frontends/controllers/ControlMinipage.C +++ b/src/frontends/controllers/ControlMinipage.C @@ -11,53 +11,31 @@ #include - #include "ControlMinipage.h" -#include "BufferView.h" +#include "funcrequest.h" -ControlMinipage::ControlMinipage(LyXView & lv, Dialogs & d) - : ControlInset(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)); } diff --git a/src/frontends/controllers/ControlMinipage.h b/src/frontends/controllers/ControlMinipage.h index dd355769c9..dd938db0ad 100644 --- a/src/frontends/controllers/ControlMinipage.h +++ b/src/frontends/controllers/ControlMinipage.h @@ -13,49 +13,28 @@ #ifndef CONTROLMINIPAGE_H #define CONTROLMINIPAGE_H -#include +#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 { +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 params_; }; #endif diff --git a/src/frontends/controllers/ControlUrl.C b/src/frontends/controllers/ControlUrl.C deleted file mode 100644 index 7dfe02e98e..0000000000 --- a/src/frontends/controllers/ControlUrl.C +++ /dev/null @@ -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 - - -#include "ControlUrl.h" - - -ControlUrl::ControlUrl(Dialog & d) - : ControlCommand(d, "url") -{} diff --git a/src/frontends/controllers/ControlUrl.h b/src/frontends/controllers/ControlUrl.h deleted file mode 100644 index 923860f2cf..0000000000 --- a/src/frontends/controllers/ControlUrl.h +++ /dev/null @@ -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 diff --git a/src/frontends/controllers/ControlWrap.C b/src/frontends/controllers/ControlWrap.C index fee4b5c624..1d5ce0e333 100644 --- a/src/frontends/controllers/ControlWrap.C +++ b/src/frontends/controllers/ControlWrap.C @@ -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)); } diff --git a/src/frontends/controllers/Makefile.am b/src/frontends/controllers/Makefile.am index 073eb54a63..6751859cdd 100644 --- a/src/frontends/controllers/Makefile.am +++ b/src/frontends/controllers/Makefile.am @@ -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 \ diff --git a/src/frontends/guiapi.C b/src/frontends/guiapi.C index 88bfa5918e..de4d649120 100644 --- a/src/frontends/guiapi.C +++ b/src/frontends/guiapi.C @@ -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(); diff --git a/src/frontends/guiapi.h b/src/frontends/guiapi.h index 703e8d4ae1..6e7a522f74 100644 --- a/src/frontends/guiapi.h +++ b/src/frontends/guiapi.h @@ -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 &); diff --git a/src/frontends/qt2/ChangeLog b/src/frontends/qt2/ChangeLog index 5ac87ba107..7e754e8900 100644 --- a/src/frontends/qt2/ChangeLog +++ b/src/frontends/qt2/ChangeLog @@ -1,3 +1,20 @@ +2003-03-07 Angus Leeming + + * 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 * qscreen.C: use LyXText::top_y() instead of LyXText::first_y diff --git a/src/frontends/qt2/Dialogs.C b/src/frontends/qt2/Dialogs.C index 6beaf4fcf9..58f3987104 100644 --- a/src/frontends/qt2/Dialogs.C +++ b/src/frontends/qt2/Dialogs.C @@ -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), diff --git a/src/frontends/qt2/Dialogs2.C b/src/frontends/qt2/Dialogs2.C index e06691eb0a..45ad0bdee4 100644 --- a/src/frontends/qt2/Dialogs2.C +++ b/src/frontends/qt2/Dialogs2.C @@ -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(); diff --git a/src/frontends/qt2/Dialogs3.C b/src/frontends/qt2/Dialogs3.C index d524dca92d..a919a66945 100644 --- a/src/frontends/qt2/Dialogs3.C +++ b/src/frontends/qt2/Dialogs3.C @@ -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") { diff --git a/src/frontends/qt2/Dialogs_impl.h b/src/frontends/qt2/Dialogs_impl.h index 0fc882c9d0..ad6339edbd 100644 --- a/src/frontends/qt2/Dialogs_impl.h +++ b/src/frontends/qt2/Dialogs_impl.h @@ -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 LogFileDialog; -typedef GUI -MinipageDialog; - typedef GUI ParagraphDialog; @@ -158,7 +152,6 @@ struct Dialogs::Impl { FileDialog file; GraphicsDialog graphics; LogFileDialog logfile; - MinipageDialog minipage; ParagraphDialog paragraph; PrefsDialog prefs; PrintDialog print; diff --git a/src/frontends/qt2/QBibitem.C b/src/frontends/qt2/QBibitem.C index 2a86aa04a0..cb8c61cc6e 100644 --- a/src/frontends/qt2/QBibitem.C +++ b/src/frontends/qt2/QBibitem.C @@ -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 > base_class; +typedef QController > base_class; QBibitem::QBibitem(Dialog & parent) diff --git a/src/frontends/qt2/QBibitem.h b/src/frontends/qt2/QBibitem.h index 12dd72bfc4..a07b12f9f8 100644 --- a/src/frontends/qt2/QBibitem.h +++ b/src/frontends/qt2/QBibitem.h @@ -15,11 +15,11 @@ #include "QDialogView.h" -class ControlBibitem; +class ControlCommand; class QBibitemDialog; class QBibitem - : public QController > + : public QController > { public: friend class QBibitemDialog; diff --git a/src/frontends/qt2/QBibitemDialog.C b/src/frontends/qt2/QBibitemDialog.C index aa5dbe53c5..50b7c67d67 100644 --- a/src/frontends/qt2/QBibitemDialog.C +++ b/src/frontends/qt2/QBibitemDialog.C @@ -10,9 +10,6 @@ #include - -#include "ControlBibitem.h" - #include #include diff --git a/src/frontends/qt2/QIndex.C b/src/frontends/qt2/QIndex.C index 97cce54613..2eceecf783 100644 --- a/src/frontends/qt2/QIndex.C +++ b/src/frontends/qt2/QIndex.C @@ -11,7 +11,7 @@ #include -#include "ControlIndex.h" +#include "ControlCommand.h" #include "qt_helpers.h" #include "QIndexDialog.h" diff --git a/src/frontends/qt2/QMinipage.C b/src/frontends/qt2/QMinipage.C index 04f7505484..7ab69fcfac 100644 --- a/src/frontends/qt2/QMinipage.C +++ b/src/frontends/qt2/QMinipage.C @@ -26,11 +26,11 @@ #include #include -typedef Qt2CB > base_class; +typedef QController > 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()) diff --git a/src/frontends/qt2/QMinipage.h b/src/frontends/qt2/QMinipage.h index 27805c7911..d39474a7ce 100644 --- a/src/frontends/qt2/QMinipage.h +++ b/src/frontends/qt2/QMinipage.h @@ -13,20 +13,21 @@ #define QMINIPAGE_H -#include "Qt2Base.h" +#include "QDialogView.h" + class ControlMinipage; class QMinipageDialog; /// class QMinipage - : public Qt2CB > + : public QController > { public: /// friend class QMinipageDialog; /// - QMinipage(); + QMinipage(Dialog &); private: /// Apply changes virtual void apply(); diff --git a/src/frontends/qt2/QURL.C b/src/frontends/qt2/QURL.C index 1c4b77fb91..4201e4a82e 100644 --- a/src/frontends/qt2/QURL.C +++ b/src/frontends/qt2/QURL.C @@ -10,8 +10,7 @@ #include - -#include "ControlUrl.h" +#include "ControlCommand.h" #include "debug.h" #include "qt_helpers.h" @@ -23,8 +22,7 @@ #include #include -typedef QController > base_class; - +typedef QController > base_class; QURL::QURL(Dialog & parent) : base_class(parent, qt_("LyX: Insert URL")) diff --git a/src/frontends/qt2/QURL.h b/src/frontends/qt2/QURL.h index 4a61ce9ca7..5a6c289598 100644 --- a/src/frontends/qt2/QURL.h +++ b/src/frontends/qt2/QURL.h @@ -15,12 +15,12 @@ #include "QDialogView.h" -class ControlUrl; +class ControlCommand; class QURLDialog; class QURL : - public QController > + public QController > { public: friend class QURLDialog; diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index e2b18b5d34..85e6838cc5 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -1,3 +1,18 @@ +2003-03-07 Angus Leeming + + * 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 * xscreen.C: use LyXText::top_y() instead of LyXText::first_y diff --git a/src/frontends/xforms/Dialogs.C b/src/frontends/xforms/Dialogs.C index e5f6843a57..7c900ac5b0 100644 --- a/src/frontends/xforms/Dialogs.C +++ b/src/frontends/xforms/Dialogs.C @@ -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), diff --git a/src/frontends/xforms/Dialogs2.C b/src/frontends/xforms/Dialogs2.C index d911e5d276..2b0913266a 100644 --- a/src/frontends/xforms/Dialogs2.C +++ b/src/frontends/xforms/Dialogs2.C @@ -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(); diff --git a/src/frontends/xforms/Dialogs3.C b/src/frontends/xforms/Dialogs3.C index 482c995139..d77daafb03 100644 --- a/src/frontends/xforms/Dialogs3.C +++ b/src/frontends/xforms/Dialogs3.C @@ -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") { diff --git a/src/frontends/xforms/Dialogs_impl.h b/src/frontends/xforms/Dialogs_impl.h index 5871881734..553a04ab3c 100644 --- a/src/frontends/xforms/Dialogs_impl.h +++ b/src/frontends/xforms/Dialogs_impl.h @@ -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 MathPanelDialog; -typedef GUI -MinipageDialog; - typedef GUI ParagraphDialog; @@ -188,7 +181,6 @@ struct Dialogs::Impl { GraphicsDialog graphics; LogFileDialog logfile; MathPanelDialog mathpanel; - MinipageDialog minipage; ParagraphDialog paragraph; PreambleDialog preamble; PreferencesDialog preferences; diff --git a/src/frontends/xforms/FormBibitem.C b/src/frontends/xforms/FormBibitem.C index 791687a0c3..cff49ed92a 100644 --- a/src/frontends/xforms/FormBibitem.C +++ b/src/frontends/xforms/FormBibitem.C @@ -12,7 +12,7 @@ #include #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 > base_class; +typedef FormController > base_class; FormBibitem::FormBibitem(Dialog & parent) : base_class(parent, _("Bibliography Entry")) diff --git a/src/frontends/xforms/FormBibitem.h b/src/frontends/xforms/FormBibitem.h index 9206642d90..e83de9aa44 100644 --- a/src/frontends/xforms/FormBibitem.h +++ b/src/frontends/xforms/FormBibitem.h @@ -16,13 +16,13 @@ #include "FormDialogView.h" -class ControlBibitem; +class ControlCommand; struct FD_bibitem; /** * For bibliography entry editing */ -class FormBibitem : public FormController > { +class FormBibitem : public FormController > { public: /// FormBibitem(Dialog &); diff --git a/src/frontends/xforms/FormMinipage.C b/src/frontends/xforms/FormMinipage.C index d22872bacd..a9716d091d 100644 --- a/src/frontends/xforms/FormMinipage.C +++ b/src/frontends/xforms/FormMinipage.C @@ -21,10 +21,10 @@ #include "xforms_helpers.h" #include FORMS_H_LOCATION -typedef FormCB > base_class; +typedef FormController > 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); diff --git a/src/frontends/xforms/FormMinipage.h b/src/frontends/xforms/FormMinipage.h index 4378b7a614..cef758199c 100644 --- a/src/frontends/xforms/FormMinipage.h +++ b/src/frontends/xforms/FormMinipage.h @@ -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 > { + : public FormController > { public: /// - FormMinipage(); + FormMinipage(Dialog &); private: /// Set the Params variable for the Controller. virtual void apply(); diff --git a/src/frontends/xforms/FormUrl.C b/src/frontends/xforms/FormUrl.C index 3426122bc8..49c098ab0d 100644 --- a/src/frontends/xforms/FormUrl.C +++ b/src/frontends/xforms/FormUrl.C @@ -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 > base_class; +typedef FormController > base_class; FormUrl::FormUrl(Dialog & parent) : base_class(parent, _("Url")) diff --git a/src/frontends/xforms/FormUrl.h b/src/frontends/xforms/FormUrl.h index 417440dbbb..56d85aa2e5 100644 --- a/src/frontends/xforms/FormUrl.h +++ b/src/frontends/xforms/FormUrl.h @@ -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 > { +class FormUrl : public FormController > { public: /// FormUrl(Dialog &); diff --git a/src/frontends/xforms/forms/form_minipage.fd b/src/frontends/xforms/forms/form_minipage.fd index 2cb49aee5e..05736ff3df 100644 --- a/src/frontends/xforms/forms/form_minipage.fd +++ b/src/frontends/xforms/forms/form_minipage.fd @@ -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 -------------------- diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index 68147b9466..707254bd9f 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,20 @@ +2003-03-07 Angus Leeming + + * 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 * insettext.C: diff --git a/src/insets/insetcommand.C b/src/insets/insetcommand.C index b0be308fea..d1d51ece82 100644 --- a/src/insets/insetcommand.C +++ b/src/insets/insetcommand.C @@ -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); } diff --git a/src/insets/insetert.C b/src/insets/insetert.C index ae0eda8f9f..a4807b046f 100644 --- a/src/insets/insetert.C +++ b/src/insets/insetert.C @@ -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); } diff --git a/src/insets/insetert.h b/src/insets/insetert.h index 4d874eaf7b..1a1cc59c0d 100644 --- a/src/insets/insetert.h +++ b/src/insets/insetert.h @@ -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_; }; diff --git a/src/insets/insetexternal.C b/src/insets/insetexternal.C index a58941e7b3..02e94a059d 100644 --- a/src/insets/insetexternal.C +++ b/src/insets/insetexternal.C @@ -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"; diff --git a/src/insets/insetexternal.h b/src/insets/insetexternal.h index a2665ec1e6..31e3a8275c 100644 --- a/src/insets/insetexternal.h +++ b/src/insets/insetexternal.h @@ -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_; }; diff --git a/src/insets/insetfloat.C b/src/insets/insetfloat.C index 0293a80327..2eddcad779 100644 --- a/src/insets/insetfloat.C +++ b/src/insets/insetfloat.C @@ -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(); diff --git a/src/insets/insetfloat.h b/src/insets/insetfloat.h index 944f59e2fa..38fc1284af 100644 --- a/src/insets/insetfloat.h +++ b/src/insets/insetfloat.h @@ -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_; }; diff --git a/src/insets/insetinclude.C b/src/insets/insetinclude.C index 9cafae74d5..30ba271416 100644 --- a/src/insets/insetinclude.C +++ b/src/insets/insetinclude.C @@ -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"; diff --git a/src/insets/insetinclude.h b/src/insets/insetinclude.h index 4c26ce7693..8a57c739fb 100644 --- a/src/insets/insetinclude.h +++ b/src/insets/insetinclude.h @@ -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_; }; diff --git a/src/insets/insetminipage.C b/src/insets/insetminipage.C index f2a439e180..026c8f40d3 100644 --- a/src/insets/insetminipage.C +++ b/src/insets/insetminipage.C @@ -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(lex.getInteger()); + pos = static_cast(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(lex.getInteger()); + inner_pos = static_cast(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(this)); + if (!inset.showInsetDialog(bv)) { + InsetMinipage * tmp = const_cast(this); + InsetMinipageMailer mailer(*tmp); + mailer.showDialog(); + } + return true; } @@ -333,7 +374,7 @@ int InsetMinipage::getMaxWidth(BufferView * bv, UpdatableInset const * inset) static_cast(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(); } diff --git a/src/insets/insetminipage.h b/src/insets/insetminipage.h index 142068e2a0..f5f5cafada 100644 --- a/src/insets/insetminipage.h +++ b/src/insets/insetminipage.h @@ -17,8 +17,6 @@ #include "insetcollapsable.h" #include "lyxlength.h" -#include - /** 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 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 diff --git a/src/insets/insetwrap.C b/src/insets/insetwrap.C index 92bd136ea0..e54e1fa629 100644 --- a/src/insets/insetwrap.C +++ b/src/insets/insetwrap.C @@ -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(); diff --git a/src/insets/insetwrap.h b/src/insets/insetwrap.h index b4525707f0..a35b782b0b 100644 --- a/src/insets/insetwrap.h +++ b/src/insets/insetwrap.h @@ -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_; }; diff --git a/src/lyxfunc.C b/src/lyxfunc.C index b6e957f01a..2af31604b0 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -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); }