From ded76b4ff4618ba2f2171451596840041a782fd2 Mon Sep 17 00:00:00 2001 From: Angus Leeming Date: Sun, 9 Mar 2003 18:11:57 +0000 Subject: [PATCH] Port the tabular dialog to the new scheme based on class Dialog. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6401 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/ChangeLog | 5 + src/frontends/Dialogs.h | 8 +- src/frontends/controllers/ChangeLog | 4 + src/frontends/controllers/ControlTabular.C | 126 ++++--------------- src/frontends/controllers/ControlTabular.h | 55 +++------ src/frontends/guiapi.C | 12 -- src/frontends/guiapi.h | 3 - src/frontends/qt2/ChangeLog | 10 ++ src/frontends/qt2/Dialogs.C | 1 - src/frontends/qt2/Dialogs2.C | 12 -- src/frontends/qt2/Dialogs3.C | 10 +- src/frontends/qt2/Dialogs_impl.h | 7 -- src/frontends/qt2/QDialogView.C | 1 - src/frontends/qt2/QTabular.C | 6 +- src/frontends/qt2/QTabular.h | 7 +- src/frontends/xforms/ChangeLog | 11 ++ src/frontends/xforms/Dialogs.C | 1 - src/frontends/xforms/Dialogs2.C | 12 -- src/frontends/xforms/Dialogs3.C | 10 +- src/frontends/xforms/Dialogs_impl.h | 8 -- src/frontends/xforms/FormTabular.C | 8 +- src/frontends/xforms/FormTabular.h | 9 +- src/frontends/xforms/forms/form_tabular.fd | 108 ++++++++--------- src/insets/ChangeLog | 8 ++ src/insets/insettabular.C | 135 +++++++++++++++++++-- src/insets/insettabular.h | 36 +++++- src/insets/mailinset.C | 4 +- 27 files changed, 323 insertions(+), 294 deletions(-) diff --git a/src/frontends/ChangeLog b/src/frontends/ChangeLog index 20e43e7198..372ca64262 100644 --- a/src/frontends/ChangeLog +++ b/src/frontends/ChangeLog @@ -1,3 +1,8 @@ +2003-03-09 Angus Leeming + + * Dialogs.h: remove showTabular, updateTabular. + * guiapi.[Ch]: remove gui_updateTabular, gui_updateTabular. + 2003-03-07 Angus Leeming * Dialogs.h: remove showGraphics. diff --git a/src/frontends/Dialogs.h b/src/frontends/Dialogs.h index 73e90d5c19..457b32ec87 100644 --- a/src/frontends/Dialogs.h +++ b/src/frontends/Dialogs.h @@ -23,9 +23,7 @@ class Dialog; class InsetBase; class LyXView; -class InsetInfo; class Paragraph; -class InsetTabular; /** Container of all dialogs and signals a LyXView needs or uses to access them The list of dialog signals isn't comprehensive but should be a good guide @@ -108,10 +106,6 @@ public: /// bring up the spellchecker void showSpellchecker(); /// - void showTabular(InsetTabular *); - /// - void updateTabular(InsetTabular *); - /// void showTabularCreate(); /// show the TexInfo void showTexinfo(); @@ -134,7 +128,7 @@ public: */ void update(string const & name, string const & data); /// - void Dialogs::hide(string const & name); + void hide(string const & name); /// void disconnect(string const & name); /// diff --git a/src/frontends/controllers/ChangeLog b/src/frontends/controllers/ChangeLog index 326d6c5ec0..4068d19295 100644 --- a/src/frontends/controllers/ChangeLog +++ b/src/frontends/controllers/ChangeLog @@ -1,3 +1,7 @@ +2003-03-09 Angus Leeming + + * ControlTabular.[Ch]: rewrite to use the Dialog-based scheme. + 2003-03-09 Angus Leeming * ControlTabular.[Ch]: minimise the interface in preparation for diff --git a/src/frontends/controllers/ControlTabular.C b/src/frontends/controllers/ControlTabular.C index 126bfa7c3d..9986113b93 100644 --- a/src/frontends/controllers/ControlTabular.C +++ b/src/frontends/controllers/ControlTabular.C @@ -9,132 +9,59 @@ * Full author contact details are available in file CREDITS */ -#include "ControlTabular.h" - -#include "ButtonControllerBase.h" -#include "ViewBase.h" -#include "support/LAssert.h" +#include -#include "frontends/LyXView.h" -#include "BufferView.h" -#include "buffer.h" +#include "ControlTabular.h" +#include "funcrequest.h" #include "lyxrc.h" #include "insets/insettabular.h" +#include "support/LAssert.h" -#include -ControlTabular::ControlTabular(LyXView & lv, Dialogs & d) - : ControlConnectBD(lv, d), - inset_(0), dialog_built_(false) +ControlTabular::ControlTabular(Dialog & parent) + : Dialog::Controller(parent), active_cell_(-1) {} -void ControlTabular::showInset(InsetTabular * inset) -{ - lyx::Assert(inset); - - connectInset(inset); - show(inset); - - // The widgets may not be valid, so refresh the button controller - // FIXME: needed ? - bc().refresh(); -} - - -void ControlTabular::updateInset(InsetTabular * inset) +void ControlTabular::initialiseParams(string const & data) { - if (!view().isVisible()) + Buffer * buffer = kernel().buffer(); + if (!buffer) return; - lyx::Assert(inset); - connectInset(inset); - update(); -} - - -void ControlTabular::show(InsetTabular * inset) -{ - inset_ = inset; - - if (emergency_exit_) { - hide(); - return; - } - if (!dialog_built_) { - view().build(); - dialog_built_ = true; + InsetTabular tmp(*buffer); + int cell = InsetTabularMailer::string2params(data, tmp); + if (cell != -1) { + params_.reset(new LyXTabular(*tmp.tabular.get())); + active_cell_ = cell; } - - bc().readOnly(bufferIsReadonly()); - view().show(); } -void ControlTabular::update() +void ControlTabular::clearParams() { - if (emergency_exit_) { - hide(); - return; - } - - bc().readOnly(bufferIsReadonly()); - view().update(); - - // The widgets may not be valid, so refresh the button controller - // FIXME: needed ? - bc().refresh(); -} - - -void ControlTabular::hide() -{ - emergency_exit_ = false; - inset_ = 0; - - ih_.disconnect(); - disconnect(); - view().hide(); -} - - -void ControlTabular::updateSlot(bool switched) -{ - if (switched) - hide(); - else - update(); + params_.reset(); + active_cell_ = -1; } -void ControlTabular::connectInset(InsetTabular * inset) +int ControlTabular::getActiveCell() const { - // If connected to another inset, disconnect from it. - if (inset_) { - ih_.disconnect(); - inset_ = 0; - } - - if (inset) { - inset_ = inset; - ih_ = inset->hideDialog.connect( - boost::bind(&ControlTabular::hide, this)); - } - connect(); + return active_cell_; } LyXTabular const & ControlTabular::tabular() const { - lyx::Assert(inset_); - return *inset_->tabular.get(); + lyx::Assert(params_.get()); + return *params_.get(); } void ControlTabular::set(LyXTabular::Feature f, string const & arg) { - lyx::Assert(inset_); - inset_->tabularFeatures(lv_.view().get(), f, arg); + string const data = featureAsString(f) + ' ' + arg; + kernel().dispatch(FuncRequest(LFUN_TABULAR_FEATURE, data)); } @@ -142,10 +69,3 @@ bool ControlTabular::useMetricUnits() const { return lyxrc.default_papersize > BufferParams::PAPER_EXECUTIVEPAPER; } - - -int ControlTabular::getActiveCell() const -{ - lyx::Assert(inset_); - return inset_->getActCell(); -} diff --git a/src/frontends/controllers/ControlTabular.h b/src/frontends/controllers/ControlTabular.h index 962e805c11..2301133b74 100644 --- a/src/frontends/controllers/ControlTabular.h +++ b/src/frontends/controllers/ControlTabular.h @@ -16,62 +16,37 @@ #ifndef CONTROLTABULAR_H #define CONTROLTABULAR_H -#include "ControlConnections.h" -#include "LString.h" +#include "Dialog.h" #include "tabular.h" -#include -class InsetTabular; - -class ControlTabular : public ControlConnectBD { +class ControlTabular : public Dialog::Controller { public: - ControlTabular(LyXView &, Dialogs &); + ControlTabular(Dialog &); + /// + virtual void initialiseParams(string const & data); + /// clean-up on hide. + virtual void clearParams(); + /// We use set() instead. + virtual void dispatchParams() {}; + /// + virtual bool isBufferDependent() const { return true; } /// int getActiveCell() const; - /// get the contained tabular LyXTabular const & tabular() const; - /// return true if units should default to metric bool useMetricUnits() const; - /// set a parameter void set(LyXTabular::Feature, string const & arg = string()); - /// slot launching dialog to an existing inset. - void showInset(InsetTabular *); - - /// update inset - void updateInset(InsetTabular *); - private: - - /// we can't do this ... - virtual void apply() {}; - /// disconnect signals and hide View. - virtual void hide(); - /// update the dialog. - virtual void update(); - - /** Instantiation of ControlConnectBD private virtual method. - Slot connected to update signal. */ - virtual void updateSlot(bool); - - /// show the dialog. - void show(InsetTabular *); - /// connect signals - void connectInset(InsetTabular *); - - /// pointer to the inset passed through connectInset - InsetTabular * inset_; - /// inset::hide connection. - boost::signals::connection ih_; - - /// is the dialog built ? - bool dialog_built_; + /// + int active_cell_; + /// + boost::scoped_ptr params_; }; #endif // CONTROLTABULAR_H diff --git a/src/frontends/guiapi.C b/src/frontends/guiapi.C index 0c1e8d9bee..c053b57f6d 100644 --- a/src/frontends/guiapi.C +++ b/src/frontends/guiapi.C @@ -117,18 +117,6 @@ void gui_ShowSpellchecker(Dialogs & d) } -void gui_ShowTabular(InsetTabular * it, Dialogs & d) -{ - d.showTabular(it); -} - - -void gui_UpdateTabular(InsetTabular * it, Dialogs & d) -{ - d.updateTabular(it); -} - - void gui_ShowTabularCreate(Dialogs & d) { d.showTabularCreate(); diff --git a/src/frontends/guiapi.h b/src/frontends/guiapi.h index 71049dda34..7cb0f666eb 100644 --- a/src/frontends/guiapi.h +++ b/src/frontends/guiapi.h @@ -16,7 +16,6 @@ #include "LString.h" class Dialogs; -class InsetTabular; extern "C" { @@ -38,8 +37,6 @@ void gui_ShowPrint(Dialogs &); void gui_ShowSearch(Dialogs &); void gui_ShowSendto(Dialogs &); void gui_ShowSpellchecker(Dialogs &); -void gui_ShowTabular(InsetTabular *, Dialogs &); -void gui_UpdateTabular(InsetTabular *, Dialogs &); void gui_ShowTabularCreate(Dialogs &); void gui_ShowTexinfo(Dialogs &); void gui_ShowThesaurus(string const &, Dialogs &); diff --git a/src/frontends/qt2/ChangeLog b/src/frontends/qt2/ChangeLog index 69b5153671..25791e3e13 100644 --- a/src/frontends/qt2/ChangeLog +++ b/src/frontends/qt2/ChangeLog @@ -1,3 +1,13 @@ +2003-03-09 Angus Leeming + + * Dialogs.C: + * Dialogs2.C: + * Dialogs_impl.h: remove tabular dialog. + + * Dialogs3.C: add tabular dialog. + + * QTabular.[Ch]: changes to use the new Dialog-based scheme. + 2003-03-09 Angus Leeming * QDialogView.h: make controller methods of QController public to diff --git a/src/frontends/qt2/Dialogs.C b/src/frontends/qt2/Dialogs.C index 05caf4c106..4e8a3600dc 100644 --- a/src/frontends/qt2/Dialogs.C +++ b/src/frontends/qt2/Dialogs.C @@ -39,7 +39,6 @@ Dialogs::Impl::Impl(LyXView & lv, Dialogs & d) sendto(lv, d), spellchecker(lv, d), tabularcreate(lv, d), - tabular(lv, d), texinfo(lv, d), #ifdef HAVE_LIBAIKSAURUS diff --git a/src/frontends/qt2/Dialogs2.C b/src/frontends/qt2/Dialogs2.C index dfcab7707b..c5f35361a7 100644 --- a/src/frontends/qt2/Dialogs2.C +++ b/src/frontends/qt2/Dialogs2.C @@ -118,18 +118,6 @@ void Dialogs::showSpellchecker() } -void Dialogs::showTabular(InsetTabular * it) -{ - pimpl_->tabular.controller().showInset(it); -} - - -void Dialogs::updateTabular(InsetTabular * it) -{ - pimpl_->tabular.controller().updateInset(it); -} - - void Dialogs::showTabularCreate() { pimpl_->tabularcreate.controller().show(); diff --git a/src/frontends/qt2/Dialogs3.C b/src/frontends/qt2/Dialogs3.C index 8c5445ee33..d1800c31c4 100644 --- a/src/frontends/qt2/Dialogs3.C +++ b/src/frontends/qt2/Dialogs3.C @@ -23,6 +23,7 @@ #include "ControlInclude.h" #include "ControlMinipage.h" #include "ControlRef.h" +#include "ControlTabular.h" #include "ControlToc.h" #include "ControlWrap.h" @@ -54,6 +55,8 @@ #include "QMinipageDialog.h" #include "QRef.h" #include "QRefDialog.h" +#include "QTabular.h" +#include "QTabularDialog.h" #include "QToc.h" #include "QTocDialog.h" #include "QURL.h" @@ -83,7 +86,8 @@ namespace { char const * const dialognames[] = { "bibitem", "bibtex", "citation", "error", "ert", "external", "float", "graphics", "include", "index", "label", - "minipage", "ref", "toc", "url", "wrap" }; + "minipage", "ref", "tabular", "toc", + "url", "wrap" }; char const * const * const end_dialognames = dialognames + (sizeof(dialognames) / sizeof(char *)); @@ -171,6 +175,10 @@ Dialog * Dialogs::build(string const & name) dialog->setController(new ControlRef(*dialog)); dialog->setView(new QRef(*dialog)); dialog->setButtonController(new NoRepeatedApplyReadOnlyBC); + } else if (name == "tabular") { + dialog->setController(new ControlTabular(*dialog)); + dialog->setView(new QTabular(*dialog)); + dialog->setButtonController(new NoRepeatedApplyReadOnlyBC); } else if (name == "toc") { dialog->setController(new ControlToc(*dialog)); dialog->setView(new QToc(*dialog)); diff --git a/src/frontends/qt2/Dialogs_impl.h b/src/frontends/qt2/Dialogs_impl.h index 3cc47d5ce7..ab2301f0fb 100644 --- a/src/frontends/qt2/Dialogs_impl.h +++ b/src/frontends/qt2/Dialogs_impl.h @@ -28,7 +28,6 @@ #include "ControlShowFile.h" #include "ControlSpellchecker.h" #include "ControlTabularCreate.h" -#include "ControlTabular.h" #include "ControlTexinfo.h" #include "ControlVCLog.h" @@ -63,8 +62,6 @@ #include "QSpellcheckerDialog.h" #include "QTabularCreate.h" #include "QTabularCreateDialog.h" -#include "QTabular.h" -#include "QTabularDialog.h" #include "QTexinfo.h" #include "QTexinfoDialog.h" @@ -120,9 +117,6 @@ SpellcheckerDialog; typedef GUI TabularCreateDialog; -typedef GUI -TabularDialog; - typedef GUI TexinfoDialog; @@ -151,7 +145,6 @@ struct Dialogs::Impl { SendtoDialog sendto; SpellcheckerDialog spellchecker; TabularCreateDialog tabularcreate; - TabularDialog tabular; TexinfoDialog texinfo; #ifdef HAVE_LIBAIKSAURUS diff --git a/src/frontends/qt2/QDialogView.C b/src/frontends/qt2/QDialogView.C index d683273b3d..90de427ecb 100644 --- a/src/frontends/qt2/QDialogView.C +++ b/src/frontends/qt2/QDialogView.C @@ -16,7 +16,6 @@ #include "debug.h" #include "QtLyXView.h" -#include "Dialogs.h" #include "QDialogView.h" #include "Qt2BC.h" #include "support/LAssert.h" diff --git a/src/frontends/qt2/QTabular.C b/src/frontends/qt2/QTabular.C index bacfe2439d..da61f1aa31 100644 --- a/src/frontends/qt2/QTabular.C +++ b/src/frontends/qt2/QTabular.C @@ -29,10 +29,10 @@ #include "lengthcombo.h" #include "qsetborder.h" -typedef Qt2CB > base_class; +typedef QController > base_class; -QTabular::QTabular() - : base_class(qt_("LyX: Table Settings")) +QTabular::QTabular(Dialog & parent) + : base_class(parent, qt_("LyX: Table Settings")) { } diff --git a/src/frontends/qt2/QTabular.h b/src/frontends/qt2/QTabular.h index 54e1002f59..154731acbe 100644 --- a/src/frontends/qt2/QTabular.h +++ b/src/frontends/qt2/QTabular.h @@ -16,19 +16,20 @@ #define QTABULAR_H -#include "Qt2Base.h" +#include "QDialogView.h" + class ControlTabular; class QTabularDialog; class QTabular : - public Qt2CB > + public QController > { public: friend class QTabularDialog; - QTabular(); + QTabular(Dialog &); protected: virtual bool isValid(); diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index 2882d5b63c..ac4eed0b24 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -1,3 +1,14 @@ +2003-03-09 Angus Leeming + + * Dialogs.C: + * Dialogs2.C: + * Dialogs_impl.h: remove tabular dialog. + + * Dialogs3.C: add tabular dialog. + + * FormTabular.[Ch]: + * forms/form_tabular.fd: changes to use the new Dialog-based scheme. + 2003-03-09 Angus Leeming * FormTabular.C: changes due to the changed ControlTabular diff --git a/src/frontends/xforms/Dialogs.C b/src/frontends/xforms/Dialogs.C index 8ed62635b2..61e7f7a868 100644 --- a/src/frontends/xforms/Dialogs.C +++ b/src/frontends/xforms/Dialogs.C @@ -41,7 +41,6 @@ Dialogs::Impl::Impl(LyXView & lv, Dialogs & d) search(lv, d), sendto(lv, d), spellchecker(lv, d), - tabular(lv, d), tabularcreate(lv, d), texinfo(lv, d), diff --git a/src/frontends/xforms/Dialogs2.C b/src/frontends/xforms/Dialogs2.C index b54b6ec09a..3914284c3f 100644 --- a/src/frontends/xforms/Dialogs2.C +++ b/src/frontends/xforms/Dialogs2.C @@ -117,18 +117,6 @@ void Dialogs::showSpellchecker() } -void Dialogs::showTabular(InsetTabular * it) -{ - pimpl_->tabular.controller().showInset(it); -} - - -void Dialogs::updateTabular(InsetTabular * it) -{ - pimpl_->tabular.controller().updateInset(it); -} - - void Dialogs::showTabularCreate() { pimpl_->tabularcreate.controller().show(); diff --git a/src/frontends/xforms/Dialogs3.C b/src/frontends/xforms/Dialogs3.C index aa46ffec7f..2c242db161 100644 --- a/src/frontends/xforms/Dialogs3.C +++ b/src/frontends/xforms/Dialogs3.C @@ -26,6 +26,7 @@ #include "ControlInclude.h" #include "ControlMinipage.h" #include "ControlRef.h" +#include "ControlTabular.h" #include "ControlToc.h" #include "ControlWrap.h" @@ -51,6 +52,8 @@ #include "forms/form_minipage.h" #include "FormRef.h" #include "forms/form_ref.h" +#include "FormTabular.h" +#include "forms/form_tabular.h" #include "FormText.h" #include "forms/form_text.h" #include "FormToc.h" @@ -82,7 +85,8 @@ namespace { char const * const dialognames[] = { "bibitem", "bibtex", "citation", "error", "ert", "external", "float", "graphics", "include", "index", "label", - "minipage", "ref", "toc", "url", "wrap" }; + "minipage", "ref", "tabular", "toc", + "url", "wrap" }; char const * const * const end_dialognames = @@ -169,6 +173,10 @@ Dialog * Dialogs::build(string const & name) dialog->setController(new ControlRef(*dialog)); dialog->setView(new FormRef(*dialog)); dialog->setButtonController(new NoRepeatedApplyReadOnlyBC); + } else if (name == "tabular") { + dialog->setController(new ControlTabular(*dialog)); + dialog->setView(new FormTabular(*dialog)); + dialog->setButtonController(new NoRepeatedApplyReadOnlyBC); } else if (name == "toc") { dialog->setController(new ControlToc(*dialog)); dialog->setView(new FormToc(*dialog)); diff --git a/src/frontends/xforms/Dialogs_impl.h b/src/frontends/xforms/Dialogs_impl.h index 2dc7c7a851..a1dd5f82d6 100644 --- a/src/frontends/xforms/Dialogs_impl.h +++ b/src/frontends/xforms/Dialogs_impl.h @@ -79,10 +79,6 @@ #include "FormSpellchecker.h" #include "forms/form_spellchecker.h" -#include "ControlTabular.h" -#include "FormTabular.h" -#include "forms/form_tabular.h" - #include "ControlTabularCreate.h" #include "FormTabularCreate.h" #include "forms/form_tabular_create.h" @@ -145,9 +141,6 @@ SendtoDialog; typedef GUI SpellcheckerDialog; -typedef GUI -TabularDialog; - typedef GUI TabularCreateDialog; @@ -180,7 +173,6 @@ struct Dialogs::Impl { SearchDialog search; SendtoDialog sendto; SpellcheckerDialog spellchecker; - TabularDialog tabular; TabularCreateDialog tabularcreate; TexinfoDialog texinfo; diff --git a/src/frontends/xforms/FormTabular.C b/src/frontends/xforms/FormTabular.C index ade140b4a3..0cc61409c1 100644 --- a/src/frontends/xforms/FormTabular.C +++ b/src/frontends/xforms/FormTabular.C @@ -34,10 +34,10 @@ using std::vector; using std::bind2nd; -typedef FormCB > base_class; +typedef FormController > base_class; -FormTabular::FormTabular() - : base_class(_("Edit table settings")), +FormTabular::FormTabular(Dialog & parent) + : base_class(parent, _("Edit table settings")), closing_(false), actCell_(-1) { } @@ -507,7 +507,7 @@ ButtonPolicy::SMInput FormTabular::input(FL_OBJECT * ob, long) input(cell_options_->input_special_multialign, 0); closing_ = false; - controller().OKButton(); + dialog().OKButton(); return ButtonPolicy::SMI_VALID; } diff --git a/src/frontends/xforms/FormTabular.h b/src/frontends/xforms/FormTabular.h index 68babe3c72..6ae27a26c1 100644 --- a/src/frontends/xforms/FormTabular.h +++ b/src/frontends/xforms/FormTabular.h @@ -13,11 +13,9 @@ #ifndef FORMTABULAR_H #define FORMTABULAR_H +#include "FormDialogView.h" #include - -#include "FormBase.h" - class InsetTabular; class ControlTabular; struct FD_tabular; @@ -29,10 +27,11 @@ struct FD_tabular_longtable; /** This class provides an XForms implementation of the FormTabular Dialog. The tabular dialog allows users to set/save their tabular. */ -class FormTabular : public FormCB > { +class FormTabular + : public FormController > { public: - FormTabular(); + FormTabular(Dialog &); private: /** Redraw the form (on receipt of a Signal indicating, for example, diff --git a/src/frontends/xforms/forms/form_tabular.fd b/src/frontends/xforms/forms/form_tabular.fd index a0d178198d..d50daa0eb7 100644 --- a/src/frontends/xforms/forms/form_tabular.fd +++ b/src/frontends/xforms/forms/form_tabular.fd @@ -64,7 +64,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: button_close -callback: C_FormBaseInputCB +callback: C_FormDialogView_InputCB argument: 0 -------------------- @@ -160,7 +160,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: button_append_column -callback: C_FormBaseInputCB +callback: C_FormDialogView_InputCB argument: 0 -------------------- @@ -178,7 +178,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: button_delete_column -callback: C_FormBaseInputCB +callback: C_FormDialogView_InputCB argument: 0 -------------------- @@ -196,7 +196,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: button_append_row -callback: C_FormBaseInputCB +callback: C_FormDialogView_InputCB argument: 0 -------------------- @@ -214,7 +214,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: button_delete_row -callback: C_FormBaseInputCB +callback: C_FormDialogView_InputCB argument: 0 -------------------- @@ -232,7 +232,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: button_set_borders -callback: C_FormBaseInputCB +callback: C_FormDialogView_InputCB argument: 0 -------------------- @@ -250,7 +250,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: button_unset_borders -callback: C_FormBaseInputCB +callback: C_FormDialogView_InputCB argument: 0 -------------------- @@ -268,7 +268,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: check_longtable -callback: C_FormBaseInputCB +callback: C_FormDialogView_InputCB argument: 0 -------------------- @@ -286,7 +286,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: check_rotate_tabular -callback: C_FormBaseInputCB +callback: C_FormDialogView_InputCB argument: 0 -------------------- @@ -418,7 +418,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: input_column_width -callback: C_FormBaseInputCB +callback: C_FormDialogView_InputCB argument: 0 -------------------- @@ -436,7 +436,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: check_border_top -callback: C_FormBaseInputCB +callback: C_FormDialogView_InputCB argument: 0 -------------------- @@ -454,7 +454,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: check_border_bottom -callback: C_FormBaseInputCB +callback: C_FormDialogView_InputCB argument: 0 -------------------- @@ -472,7 +472,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: check_border_left -callback: C_FormBaseInputCB +callback: C_FormDialogView_InputCB argument: 0 -------------------- @@ -490,7 +490,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: check_border_right -callback: C_FormBaseInputCB +callback: C_FormDialogView_InputCB argument: 0 -------------------- @@ -526,7 +526,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: radio_align_left -callback: C_FormBaseInputCB +callback: C_FormDialogView_InputCB argument: 0 value: 1 @@ -545,7 +545,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: radio_align_right -callback: C_FormBaseInputCB +callback: C_FormDialogView_InputCB argument: 0 -------------------- @@ -563,7 +563,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: radio_align_center -callback: C_FormBaseInputCB +callback: C_FormDialogView_InputCB argument: 0 -------------------- @@ -617,7 +617,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: radio_valign_top -callback: C_FormBaseInputCB +callback: C_FormDialogView_InputCB argument: 0 value: 1 @@ -636,7 +636,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: radio_valign_center -callback: C_FormBaseInputCB +callback: C_FormDialogView_InputCB argument: 0 -------------------- @@ -654,7 +654,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: radio_valign_bottom -callback: C_FormBaseInputCB +callback: C_FormDialogView_InputCB argument: 0 -------------------- @@ -690,7 +690,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: input_special_alignment -callback: C_FormBaseInputCB +callback: C_FormDialogView_InputCB argument: 0 -------------------- @@ -708,7 +708,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: choice_value_column_width -callback: C_FormBaseInputCB +callback: C_FormDialogView_InputCB argument: 0 -------------------- @@ -744,7 +744,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: radio_align_block -callback: C_FormBaseInputCB +callback: C_FormDialogView_InputCB argument: 0 =============== FORM =============== @@ -876,7 +876,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: check_border_top -callback: C_FormBaseInputCB +callback: C_FormDialogView_InputCB argument: 0 -------------------- @@ -894,7 +894,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: check_border_bottom -callback: C_FormBaseInputCB +callback: C_FormDialogView_InputCB argument: 0 -------------------- @@ -912,7 +912,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: check_border_left -callback: C_FormBaseInputCB +callback: C_FormDialogView_InputCB argument: 0 -------------------- @@ -930,7 +930,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: check_border_right -callback: C_FormBaseInputCB +callback: C_FormDialogView_InputCB argument: 0 -------------------- @@ -966,7 +966,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: radio_align_left -callback: C_FormBaseInputCB +callback: C_FormDialogView_InputCB argument: 0 value: 1 @@ -985,7 +985,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: radio_align_right -callback: C_FormBaseInputCB +callback: C_FormDialogView_InputCB argument: 0 -------------------- @@ -1003,7 +1003,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: radio_align_center -callback: C_FormBaseInputCB +callback: C_FormDialogView_InputCB argument: 0 -------------------- @@ -1057,7 +1057,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: radio_valign_top -callback: C_FormBaseInputCB +callback: C_FormDialogView_InputCB argument: 0 value: 1 @@ -1076,7 +1076,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: radio_valign_center -callback: C_FormBaseInputCB +callback: C_FormDialogView_InputCB argument: 0 -------------------- @@ -1094,7 +1094,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: radio_valign_bottom -callback: C_FormBaseInputCB +callback: C_FormDialogView_InputCB argument: 0 -------------------- @@ -1130,7 +1130,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: input_mcolumn_width -callback: C_FormBaseInputCB +callback: C_FormDialogView_InputCB argument: 0 -------------------- @@ -1148,7 +1148,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: input_special_multialign -callback: C_FormBaseInputCB +callback: C_FormDialogView_InputCB argument: 0 -------------------- @@ -1166,7 +1166,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: check_multicolumn -callback: C_FormBaseInputCB +callback: C_FormDialogView_InputCB argument: 0 -------------------- @@ -1184,7 +1184,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: check_useminipage -callback: C_FormBaseInputCB +callback: C_FormDialogView_InputCB argument: 0 -------------------- @@ -1202,7 +1202,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: check_rotate_cell -callback: C_FormBaseInputCB +callback: C_FormDialogView_InputCB argument: 0 -------------------- @@ -1220,7 +1220,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: choice_value_mcolumn_width -callback: C_FormBaseInputCB +callback: C_FormDialogView_InputCB argument: 0 -------------------- @@ -1370,7 +1370,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: check_lt_firsthead -callback: C_FormBaseInputCB +callback: C_FormDialogView_InputCB argument: 0 -------------------- @@ -1388,7 +1388,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: check_lt_head -callback: C_FormBaseInputCB +callback: C_FormDialogView_InputCB argument: 0 -------------------- @@ -1406,7 +1406,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: check_lt_foot -callback: C_FormBaseInputCB +callback: C_FormDialogView_InputCB argument: 0 -------------------- @@ -1424,7 +1424,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: check_lt_lastfoot -callback: C_FormBaseInputCB +callback: C_FormDialogView_InputCB argument: 0 -------------------- @@ -1442,7 +1442,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: check_lt_newpage -callback: C_FormBaseInputCB +callback: C_FormDialogView_InputCB argument: 0 -------------------- @@ -1460,7 +1460,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: check_head_2border_above -callback: C_FormBaseInputCB +callback: C_FormDialogView_InputCB argument: 0 -------------------- @@ -1478,7 +1478,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: check_head_2border_below -callback: C_FormBaseInputCB +callback: C_FormDialogView_InputCB argument: 0 -------------------- @@ -1568,7 +1568,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: check_1head_2border_above -callback: C_FormBaseInputCB +callback: C_FormDialogView_InputCB argument: 0 -------------------- @@ -1586,7 +1586,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: check_foot_2border_above -callback: C_FormBaseInputCB +callback: C_FormDialogView_InputCB argument: 0 -------------------- @@ -1604,7 +1604,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: check_lastfoot_2border_above -callback: C_FormBaseInputCB +callback: C_FormDialogView_InputCB argument: 0 -------------------- @@ -1622,7 +1622,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: check_1head_2border_below -callback: C_FormBaseInputCB +callback: C_FormDialogView_InputCB argument: 0 -------------------- @@ -1640,7 +1640,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: check_foot_2border_below -callback: C_FormBaseInputCB +callback: C_FormDialogView_InputCB argument: 0 -------------------- @@ -1658,7 +1658,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: check_lastfoot_2border_below -callback: C_FormBaseInputCB +callback: C_FormDialogView_InputCB argument: 0 -------------------- @@ -1676,7 +1676,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: check_1head_empty -callback: C_FormBaseInputCB +callback: C_FormDialogView_InputCB argument: 0 -------------------- @@ -1694,7 +1694,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity name: check_lastfoot_empty -callback: C_FormBaseInputCB +callback: C_FormDialogView_InputCB argument: 0 -------------------- diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index 68607647d1..c817811036 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,11 @@ +2003-03-09 Angus Leeming + + * insettabular.[Ch]: define a new class InsetTabularMailer and use + it to communicate with the frontend dialogs. + + * mailinset.C (hideDialog): only hide the dialog if it is showing the + contents of this inset! + 2003-03-07 Angus Leeming * inseterror.C (localDispatch): new method; calls edit() on diff --git a/src/insets/insettabular.C b/src/insets/insettabular.C index 9a729f0878..edfdcfad6e 100644 --- a/src/insets/insettabular.C +++ b/src/insets/insettabular.C @@ -119,9 +119,29 @@ TabularFeature tabularFeature[] = { LyXTabular::LAST_ACTION, "" } }; +struct FindFeature { + FindFeature(LyXTabular::Feature feature) : feature_(feature) {} + bool operator()(TabularFeature & tf) + { + return tf.action == feature_; + } +private: + LyXTabular::Feature feature_; +}; + } // namespace anon +string const featureAsString(LyXTabular::Feature feature) +{ + TabularFeature * it = tabularFeature; + TabularFeature * end = it + + sizeof(tabularFeature) / sizeof(TabularFeature); + it = std::find_if(it, end, FindFeature(feature)); + return (it == end) ? string() : it->feature; +} + + bool InsetTabular::hasPasteBuffer() const { return (paste_tabular != 0); @@ -174,7 +194,8 @@ InsetTabular::InsetTabular(InsetTabular const & tab, Buffer const & buf, InsetTabular::~InsetTabular() { - hideDialog(); + InsetTabularMailer mailer(*this); + mailer.hideDialog(); } @@ -184,6 +205,12 @@ Inset * InsetTabular::clone(Buffer const & buf, bool same_id) const } +BufferView * InsetTabular::view() const +{ + return buffer->getUser(); +} + + void InsetTabular::write(Buffer const * buf, ostream & os) const { os << " Tabular" << endl; @@ -708,7 +735,8 @@ bool InsetTabular::unlockInsetInInset(BufferView * bv, UpdatableInset * inset, if (the_locking_inset->unlockInsetInInset(bv, inset, lr)) { if (inset->lyxCode() == TABULAR_CODE && !the_locking_inset->getFirstLockingInsetOfType(TABULAR_CODE)) { - bv->owner()->getDialogs().updateTabular(this); + InsetTabularMailer mailer(*this); + mailer.updateDialog(); oldcell = actcell; } return true; @@ -855,7 +883,8 @@ bool InsetTabular::lfunMouseRelease(FuncRequest const & cmd) ret = the_locking_inset->localDispatch(cmd1); } if (cmd.button() == mouse_button::button3 && !ret) { - cmd.view()->owner()->getDialogs().showTabular(this); + InsetTabularMailer mailer(*this); + mailer.showDialog(); return true; } return ret; @@ -1139,9 +1168,16 @@ Inset::RESULT InsetTabular::localDispatch(FuncRequest const & cmd) case LFUN_ENDBUF: case LFUN_ENDBUFSEL: break; - case LFUN_LAYOUT_TABULAR: - bv->owner()->getDialogs().showTabular(this); + case LFUN_LAYOUT_TABULAR: { + InsetTabularMailer mailer(*this); + mailer.showDialog(); + break; + } + case LFUN_INSET_DIALOG_UPDATE: { + InsetTabularMailer mailer(*this); + mailer.updateDialog(); break; + } case LFUN_TABULAR_FEATURE: if (!tabularFeatures(bv, arg)) result = UNDISPATCHED; @@ -1630,7 +1666,8 @@ void InsetTabular::resetPos(BufferView * bv) const !the_locking_inset->getFirstLockingInsetOfType(TABULAR_CODE)) && actcell != oldcell) { InsetTabular * inset = const_cast(this); - bv->owner()->getDialogs().updateTabular(inset); + InsetTabularMailer mailer(*inset); + mailer.updateDialog(); oldcell = actcell; } in_reset_pos = 0; @@ -2314,9 +2351,11 @@ LyXText * InsetTabular::getLyXText(BufferView const * bv, bool InsetTabular::showInsetDialog(BufferView * bv) const { - if (!the_locking_inset || !the_locking_inset->showInsetDialog(bv)) - bv->owner()->getDialogs(). - showTabular(const_cast(this)); + if (!the_locking_inset || !the_locking_inset->showInsetDialog(bv)) { + InsetTabular * tmp = const_cast(this); + InsetTabularMailer mailer(*tmp); + mailer.showDialog(); + } return true; } @@ -2331,8 +2370,9 @@ void InsetTabular::openLayoutDialog(BufferView * bv) const return; } } - bv->owner()->getDialogs().showTabular( - const_cast(this)); + InsetTabular * tmp = const_cast(this); + InsetTabularMailer mailer(*tmp); + mailer.showDialog(); } @@ -2998,3 +3038,76 @@ void InsetTabular::addPreview(grfx::PreviewLoader & loader) const } } } + + +string const InsetTabularMailer:: name_("tabular"); + +InsetTabularMailer::InsetTabularMailer(InsetTabular & inset) + : inset_(inset) +{} + + +string const InsetTabularMailer::inset2string() const +{ + return params2string(inset_); +} + + +int InsetTabularMailer::string2params(string const & in, InsetTabular & inset) +{ + istringstream data(in); + LyXLex lex(0,0); + lex.setStream(data); + + if (lex.isOK()) { + lex.next(); + string const token = lex.getString(); + if (token != name_) + return -1; + } + + int cell = -1; + if (lex.isOK()) { + lex.next(); + string const token = lex.getString(); + if (token != "active_cell") + return -1; + lex.next(); + cell = lex.getInteger(); + } + + // 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 != "Tabular") + return -1; + } + + BufferView * const bv = inset.view(); + Buffer const * const buffer = bv ? bv->buffer() : 0; + if (buffer) + inset.read(buffer, lex); + + // We can't set the active cell, but we can tell the frontend + // what it is. + return cell; +} + + +string const +InsetTabularMailer::params2string(InsetTabular const & inset) +{ + BufferView * const bv = inset.view(); + Buffer const * const buffer = bv ? bv->buffer() : 0; + if (!buffer) + return string(); + + ostringstream data; + data << name_ << " active_cell " << inset.getActCell() << '\n'; + inset.write(buffer, data); + data << "\\end_inset\n"; + + return data.str(); +} diff --git a/src/insets/insettabular.h b/src/insets/insettabular.h index 99da476657..ffb6c4d236 100644 --- a/src/insets/insettabular.h +++ b/src/insets/insettabular.h @@ -53,8 +53,7 @@ #include "FuncStatus.h" #include - -#include +#include class LyXLex; class Painter; @@ -234,13 +233,14 @@ public: // Public structures and variables /// boost::scoped_ptr tabular; - /// - boost::signal0 hideDialog; /// are some cells selected ? bool hasSelection() const { return has_selection; } + + /// + virtual BufferView * view() const; private: /// void lfunMousePress(FuncRequest const &); @@ -367,4 +367,32 @@ private: /// mutable int in_reset_pos; }; + + +#include "mailinset.h" + + +class InsetTabularMailer : public MailInset { +public: + /// + InsetTabularMailer(InsetTabular & inset); + /// + virtual Inset & inset() const { return inset_; } + /// + virtual string const & name() const { return name_; } + /// + virtual string const inset2string() const; + /// Returns the active cell if successful, else -1. + static int string2params(string const &, InsetTabular &); + /// + static string const params2string(InsetTabular const &); +private: + /// + static string const name_; + /// + InsetTabular & inset_; +}; + +string const featureAsString(LyXTabular::Feature feature); + #endif diff --git a/src/insets/mailinset.C b/src/insets/mailinset.C index 725ca45baf..a23a5417ae 100644 --- a/src/insets/mailinset.C +++ b/src/insets/mailinset.C @@ -45,5 +45,7 @@ void MailInset::hideDialog() const if (!bv) return; - bv->owner()->getDialogs().hide(name()); + InsetBase * cmp = bv->owner()->getDialogs().getOpenInset(name()); + if (cmp == &inset()) + bv->owner()->getDialogs().hide(name()); } -- 2.39.2