From 2bff4a6c861ee277c336340e5940c57d92ad3cce Mon Sep 17 00:00:00 2001 From: Angus Leeming Date: Wed, 31 Mar 2004 19:51:55 +0000 Subject: [PATCH] Convert the spellchecker dialog to the Dialog-based scheme. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8575 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/ChangeLog | 5 + src/frontends/ChangeLog | 5 + src/frontends/Dialogs.h | 2 - src/frontends/controllers/ChangeLog | 8 ++ .../controllers/ControlSpellchecker.C | 116 ++++++------------ .../controllers/ControlSpellchecker.h | 31 ++--- src/frontends/controllers/Dialog.C | 3 +- src/frontends/gtk/ChangeLog | 4 + src/frontends/gtk/Dialogs.C | 10 +- src/frontends/guiapi.C | 7 -- src/frontends/guiapi.h | 1 - src/frontends/qt2/ChangeLog | 7 ++ src/frontends/qt2/Dialogs.C | 10 +- src/frontends/qt2/Dialogs2.C | 20 +-- src/frontends/qt2/QSpellchecker.C | 19 ++- src/frontends/qt2/QSpellchecker.h | 11 +- src/frontends/xforms/ChangeLog | 8 ++ src/frontends/xforms/Dialogs.C | 10 +- src/frontends/xforms/Dialogs2.C | 19 +-- src/frontends/xforms/FormSpellchecker.C | 17 ++- src/frontends/xforms/FormSpellchecker.h | 11 +- .../xforms/forms/form_spellchecker.fd | 16 +-- src/lyxfunc.C | 2 - 23 files changed, 156 insertions(+), 186 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 51a08ccb6d..b3ff5e756e 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2004-03-31 Angus Leeming + + * lyxfunc.C (dispatch): Fall through to the generic + Dialogs::show("spellchecker"). + 2004-03-31 Angus Leeming * lyxfunc.C (getStatus, dispatch): changed invocation of the diff --git a/src/frontends/ChangeLog b/src/frontends/ChangeLog index 286af7a6be..0602df73fb 100644 --- a/src/frontends/ChangeLog +++ b/src/frontends/ChangeLog @@ -1,3 +1,8 @@ +2004-03-31 Angus Leeming + + * Dialogs.h (showSpellchecker): + * guiapi.[Ch] (gui_Spellchecker): removed. + 2004-03-31 Angus Leeming * Dialogs.h (showPreferences): diff --git a/src/frontends/Dialogs.h b/src/frontends/Dialogs.h index ef6c781507..26479c02c1 100644 --- a/src/frontends/Dialogs.h +++ b/src/frontends/Dialogs.h @@ -67,8 +67,6 @@ public: //@{ /// void showPreamble(); - /// bring up the spellchecker - void showSpellchecker(); //@} /** \param name == "about" etc; an identifier used to diff --git a/src/frontends/controllers/ChangeLog b/src/frontends/controllers/ChangeLog index 1761867027..39400f2b15 100644 --- a/src/frontends/controllers/ChangeLog +++ b/src/frontends/controllers/ChangeLog @@ -1,3 +1,11 @@ +2004-03-31 Angus Leeming + + * ControlSpellchecker.C: converted to the dialog-based scheme. + Cleaned-up the program structure so that it behaves in similar manner + to all the other dialogs. There is still far too much of the core + in here though... + + * Dialog.C (update): more generic error message. 2004-03-31 Alfredo Braunstein diff --git a/src/frontends/controllers/ControlSpellchecker.C b/src/frontends/controllers/ControlSpellchecker.C index 67fe27771e..0592fc7bc7 100644 --- a/src/frontends/controllers/ControlSpellchecker.C +++ b/src/frontends/controllers/ControlSpellchecker.C @@ -11,7 +11,6 @@ #include #include "ControlSpellchecker.h" -#include "ViewBase.h" #include "buffer.h" #include "bufferparams.h" @@ -37,7 +36,6 @@ #include "frontends/Alert.h" - using lyx::support::bformat; using std::advance; @@ -46,8 +44,8 @@ using std::endl; using std::string; -ControlSpellchecker::ControlSpellchecker(LyXView & lv, Dialogs & d) - : ControlDialogBD(lv, d), +ControlSpellchecker::ControlSpellchecker(Dialog & parent) + : Dialog::Controller(parent), oldval_(0), newvalue_(0), count_(0) {} @@ -56,23 +54,8 @@ ControlSpellchecker::~ControlSpellchecker() {} -void ControlSpellchecker::setParams() -{ - lyxerr[Debug::GUI] << "spell setParams" << endl; - startSession(); -} - - -void ControlSpellchecker::clearParams() -{ - lyxerr[Debug::GUI] << "spell clearParams" << endl; - endSession(); -} - - namespace { - SpellBase * getSpeller(BufferParams const & bp) { string lang = (lyxrc.isp_use_alt_lang) @@ -94,55 +77,35 @@ SpellBase * getSpeller(BufferParams const & bp) return new ISpell(bp, lang); } -} +} // namespace anon -void ControlSpellchecker::startSession() +bool ControlSpellchecker::initialiseParams(std::string const &) { - lyxerr[Debug::GUI] << "spell startSession" << endl; + lyxerr[Debug::GUI] << "Spellchecker::initialiseParams" << endl; - if (speller_.get()) { - lyxerr[Debug::GUI] << "startSession: speller exists" << endl; - speller_.reset(0); - return; - } - - speller_.reset(getSpeller(buffer()->params())); + speller_.reset(getSpeller(kernel().buffer().params())); // reset values to initial oldval_ = 0; newvalue_ = 0; count_ = 0; - emergency_exit_ = false; - // start off the check - if (speller_->error().empty()) { - check(); - return; - } + bool const success = speller_->error().empty(); - emergency_exit_ = true; - string message = speller_->error(); - if (message.empty()) - message = _("The spell-checker could not be started.\n" - "Maybe it is mis-configured."); + if (!success) { + Alert::error(_("The spell-checker could not be started"), + speller_->error()); + speller_.reset(0); + } - Alert::error(_("The spell-checker has failed"), message); - speller_.reset(0); + return success; } -void ControlSpellchecker::endSession() +void ControlSpellchecker::clearParams() { - lyxerr[Debug::GUI] << "spell endSession" << endl; - - emergency_exit_ = true; - - if (!speller_.get()) { - lyxerr[Debug::GUI] << "endSession with no speller" << endl; - return; - } - + lyxerr[Debug::GUI] << "Spellchecker::clearParams" << endl; speller_.reset(0); } @@ -193,14 +156,10 @@ void ControlSpellchecker::check() SpellBase::Result res = SpellBase::OK; - DocIterator cur = bufferview()->cursor(); - - // a rough estimate should be sufficient: - //DocIterator::difference_type start = distance(beg, cur); - //DocIterator::difference_type const total = start + distance(cur, end); + DocIterator cur = kernel().bufferview()->cursor(); ptrdiff_t start = 0, total = 0; - DocIterator it = DocIterator(buffer()->inset()); + DocIterator it = DocIterator(kernel().buffer().inset()); for (start = 0; it != cur; it.forwardPos()) ++start; @@ -210,11 +169,13 @@ void ControlSpellchecker::check() for (; cur && isLetter(cur); cur.forwardPos()) ++start; + BufferParams & bufferparams = kernel().buffer().params(); + while (res == SpellBase::OK || res == SpellBase::IGNORE) { - word_ = nextWord(cur, start, buffer()->params()); + word_ = nextWord(cur, start, bufferparams); // end of document - if (word_.word().empty()) + if (getWord().empty()) break; ++count_; @@ -226,7 +187,7 @@ void ControlSpellchecker::check() lyxerr[Debug::GUI] << "Updating spell progress." << endl; oldval_ = newvalue_; // set progress bar - view().partialUpdate(SPELL_PROGRESSED); + dialog().view().partialUpdate(SPELL_PROGRESSED); } // speller might be dead ... @@ -240,27 +201,20 @@ void ControlSpellchecker::check() return; } - lyxerr[Debug::GUI] << "Found word \"" << word_.word() << "\"" << endl; + lyxerr[Debug::GUI] << "Found word \"" << getWord() << "\"" << endl; - if (word_.word().empty()) { + if (getWord().empty()) { showSummary(); - endSession(); return; } - int const size = word_.word().size(); -#if 0 - advance(cur, -size); - bufferview()->putSelectionAt(cur, size, false); - advance(cur, size); -#else - bufferview()->putSelectionAt(cur, size, true); -#endif + int const size = getWord().size(); + kernel().bufferview()->putSelectionAt(cur, size, true); // set suggestions if (res != SpellBase::OK && res != SpellBase::IGNORE) { lyxerr[Debug::GUI] << "Found a word needing checking." << endl; - view().partialUpdate(SPELL_FOUND_WORD); + dialog().view().partialUpdate(SPELL_FOUND_WORD); } } @@ -275,8 +229,7 @@ bool ControlSpellchecker::checkAlive() message = _("The spell-checker has died for some reason.\n" "Maybe it has been killed."); - view().hide(); - speller_.reset(0); + dialog().CancelButton(); Alert::error(_("The spell-checker has failed"), message); return false; @@ -286,7 +239,7 @@ bool ControlSpellchecker::checkAlive() void ControlSpellchecker::showSummary() { if (!checkAlive() || count_ == 0) { - view().hide(); + dialog().CancelButton(); return; } @@ -296,16 +249,19 @@ void ControlSpellchecker::showSummary() else message = _("One word checked."); - view().hide(); + dialog().CancelButton(); Alert::information(_("Spell-checking is complete"), message); } void ControlSpellchecker::replace(string const & replacement) { - lyx::cap::replaceWord(bufferview()->cursor(), replacement); - bufferview()->buffer()->markDirty(); - bufferview()->update(); + lyxerr << "ControlSpellchecker::replace(" + << replacement << ")" << std::endl; + BufferView & bufferview = *kernel().bufferview(); + lyx::cap::replaceWord(bufferview.cursor(), replacement); + kernel().buffer().markDirty(); + bufferview.update(); // fix up the count --count_; check(); diff --git a/src/frontends/controllers/ControlSpellchecker.h b/src/frontends/controllers/ControlSpellchecker.h index 19c24d3271..3dcd2c9252 100644 --- a/src/frontends/controllers/ControlSpellchecker.h +++ b/src/frontends/controllers/ControlSpellchecker.h @@ -12,25 +12,32 @@ #ifndef CONTROLSPELLCHECKER_H #define CONTROLSPELLCHECKER_H +#include "Dialog.h" +#include "WordLangTuple.h" #include -#include "ControlDialog_impl.h" -#include "WordLangTuple.h" class SpellBase; /** A controller for Spellchecker dialogs. */ -class ControlSpellchecker : public ControlDialogBD { +class ControlSpellchecker : public Dialog::Controller { public: enum State { SPELL_PROGRESSED, //< update progress bar SPELL_FOUND_WORD //< found a bad word }; - ControlSpellchecker(LyXView &, Dialogs &); - + ControlSpellchecker(Dialog &); ~ControlSpellchecker(); + /// + virtual bool initialiseParams(std::string const & data); + /// + virtual void clearParams(); + /// Not needed here + virtual void dispatchParams() {} + /// + virtual bool isBufferDependent() const { return true; } /// replace word with replacement void replace(std::string const &); @@ -64,23 +71,9 @@ private: /// give error message is spellchecker dies bool checkAlive(); - /// start a spell-checking session - void startSession(); - - /// end a spell-checking session - void endSession(); - /// show count of checked words at normal exit void showSummary(); - /// set the params before show or update - void setParams(); - /// clean-up on hide. - void clearParams(); - - /// not needed. - virtual void apply() {} - /// current word being checked and lang code WordLangTuple word_; diff --git a/src/frontends/controllers/Dialog.C b/src/frontends/controllers/Dialog.C index ea236111dd..dfdb58a2f8 100644 --- a/src/frontends/controllers/Dialog.C +++ b/src/frontends/controllers/Dialog.C @@ -90,8 +90,7 @@ void Dialog::update(string const & data) if (!controller().initialiseParams(data)) { lyxerr << "Dialog \"" << name_ - << "\" failed to translate the data " - "string passed to update()" << std::endl; + << "\" could not be initialized" << std::endl; return; } diff --git a/src/frontends/gtk/ChangeLog b/src/frontends/gtk/ChangeLog index 0d5ae83587..5c5420ed67 100644 --- a/src/frontends/gtk/ChangeLog +++ b/src/frontends/gtk/ChangeLog @@ -1,3 +1,7 @@ +2004-03-31 Angus Leeming + + * Dialogs.C (build): added spellchecker dialog. + 2004-03-31 Angus Leeming * Dialogs.C (build): added preferences dialog. diff --git a/src/frontends/gtk/Dialogs.C b/src/frontends/gtk/Dialogs.C index 2e13676406..2a7b030d0c 100644 --- a/src/frontends/gtk/Dialogs.C +++ b/src/frontends/gtk/Dialogs.C @@ -40,6 +40,7 @@ #include "ControlSearch.h" #include "ControlSendto.h" #include "ControlShowFile.h" +#include "ControlSpellchecker.h" #include "ControlTabular.h" #include "ControlTabularCreate.h" #include "ControlTexinfo.h" @@ -80,6 +81,7 @@ #include "FormTabular.h" #include "FormTexinfo.h" #include "FormShowFile.h" +#include "FormSpellchecker.h" #include "GTableCreate.h" #include "FormToc.h" #include "GUrl.h" @@ -132,8 +134,8 @@ char const * const dialognames[] = { "mathgreek", "mathmisc", "mathdots", "mathbigoperators", "mathamsmisc", "mathamsarrows", "mathamsrelations", "mathamsnegatedrelations", "mathamsoperators", "mathdelimiter", "mathmatrix", "mathspace", "mathstyle", -"note", "paragraph", "prefs", "print", "ref", "sendto", "tabular", -"tabularcreate", "texinfo", +"note", "paragraph", "prefs", "print", "ref", "sendto", "spellchecker", +"tabular", "tabularcreate", "texinfo", #ifdef HAVE_LIBAIKSAURUS "thesaurus", @@ -464,6 +466,10 @@ Dialog * Dialogs::build(string const & name) dialog->setController(new ControlSendto(*dialog)); dialog->setView(new FormSendto(*dialog)); dialog->bc().bp(new OkApplyCancelPolicy); + } else if (name == "spellchecker") { + dialog->setController(new ControlSpellchecker(*dialog)); + dialog->setView(new FormSpellchecker(*dialog)); + dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy); } else if (name == "tabular") { dialog->setController(new ControlTabular(*dialog)); dialog->setView(new FormTabular(*dialog)); diff --git a/src/frontends/guiapi.C b/src/frontends/guiapi.C index 4a9fdb93cc..6b9abb108d 100644 --- a/src/frontends/guiapi.C +++ b/src/frontends/guiapi.C @@ -27,11 +27,4 @@ void gui_ShowPreamble(Dialogs & d) d.showPreamble(); } - -void gui_ShowSpellchecker(Dialogs & d) -{ - d.showSpellchecker(); -} - - } // extern "C" diff --git a/src/frontends/guiapi.h b/src/frontends/guiapi.h index 47ea0b9382..adfd97d9c2 100644 --- a/src/frontends/guiapi.h +++ b/src/frontends/guiapi.h @@ -21,7 +21,6 @@ extern "C" { void gui_show_dialog(Dialogs *, char const * name, char const * data); void gui_ShowPreamble(Dialogs &); -void gui_ShowSpellchecker(Dialogs &); } // extern "C" diff --git a/src/frontends/qt2/ChangeLog b/src/frontends/qt2/ChangeLog index 4d3965b968..d42806daca 100644 --- a/src/frontends/qt2/ChangeLog +++ b/src/frontends/qt2/ChangeLog @@ -1,3 +1,10 @@ +2004-03-31 Angus Leeming + + * Dialogs.C (build): added spellchecker dialog. + * Dialogs2.C (showSpellchecker): removed. + + * QSpellchecker.[Ch]: converted to the Dialog-based scheme. + 2004-03-31 Angus Leeming * Dialogs.C (build): added preferences dialog. diff --git a/src/frontends/qt2/Dialogs.C b/src/frontends/qt2/Dialogs.C index a0eddcbfc9..ea168b867e 100644 --- a/src/frontends/qt2/Dialogs.C +++ b/src/frontends/qt2/Dialogs.C @@ -36,6 +36,7 @@ #include "ControlSearch.h" #include "ControlSendto.h" #include "ControlShowFile.h" +#include "ControlSpellchecker.h" #include "ControlTabular.h" #include "ControlTabularCreate.h" #include "ControlToc.h" @@ -74,6 +75,7 @@ #include "QSearch.h" #include "QSendto.h" #include "QShowFile.h" +#include "QSpellchecker.h" #include "QTabular.h" #include "QTabularCreate.h" #include "QTexinfo.h" @@ -99,13 +101,13 @@ char const * const dialognames[] = { "citation", "document", "error", "errorlist", "ert", "external", "file", "findreplace", "float", "graphics", "include", "index", "label", "log", "mathpanel", "mathdelimiter", "mathmatrix", "note", "paragraph", "prefs", -"print", "ref", "sendto", "tabular", "tabularcreate", "texinfo", +"print", "ref", "sendto", "spellchecker","tabular", "tabularcreate", #ifdef HAVE_LIBAIKSAURUS "thesaurus", #endif -"toc", "url", "vspace", "wrap" }; +"texinfo", "toc", "url", "vspace", "wrap" }; char const * const * const end_dialognames = dialognames + (sizeof(dialognames) / sizeof(char *)); @@ -258,6 +260,10 @@ Dialog * Dialogs::build(string const & name) dialog->setController(new ControlSendto(*dialog)); dialog->setView(new QSendto(*dialog)); dialog->bc().bp(new OkApplyCancelPolicy); + } else if (name == "spellchecker") { + dialog->setController(new ControlSpellchecker(*dialog)); + dialog->setView(new QSpellchecker(*dialog)); + dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy); } else if (name == "tabular") { dialog->setController(new ControlTabular(*dialog)); dialog->setView(new QTabular(*dialog)); diff --git a/src/frontends/qt2/Dialogs2.C b/src/frontends/qt2/Dialogs2.C index af2d29702f..21d18500d2 100644 --- a/src/frontends/qt2/Dialogs2.C +++ b/src/frontends/qt2/Dialogs2.C @@ -19,30 +19,18 @@ #include "Qt2BC.h" -#include "ControlSpellchecker.h" - // Here would be an appropriate point to lecture on the evils // of the Qt headers, those most fucked up of disgusting ratholes. // But I won't. #undef signals -#include "QSpellchecker.h" -#include "QSpellcheckerDialog.h" - - -typedef GUI -SpellcheckerDialog; - struct Dialogs::Impl { Impl(LyXView & lv, Dialogs & d); - - SpellcheckerDialog spellchecker; }; -Dialogs::Impl::Impl(LyXView & lv, Dialogs & d) - : spellchecker(lv, d) +Dialogs::Impl::Impl(LyXView &, Dialogs &) {} @@ -64,9 +52,3 @@ void Dialogs::showPreamble() // Oh Angus, won't you help a poor child ? //pimpl_->document.view()->showPreamble(); } - - -void Dialogs::showSpellchecker() -{ - pimpl_->spellchecker.controller().show(); -} diff --git a/src/frontends/qt2/QSpellchecker.C b/src/frontends/qt2/QSpellchecker.C index 81d6a80669..ad09f5e848 100644 --- a/src/frontends/qt2/QSpellchecker.C +++ b/src/frontends/qt2/QSpellchecker.C @@ -11,7 +11,9 @@ #include #include "debug.h" -#include "ControlSpellchecker.h" + +#include "controllers/ControlSpellchecker.h" + #include "QSpellcheckerDialog.h" #include "QSpellchecker.h" #include "Qt2BC.h" @@ -25,13 +27,12 @@ using std::string; -typedef Qt2CB > base_class; +typedef QController > base_class; -QSpellchecker::QSpellchecker() - : base_class(_("LyX: Spell-check Document")) -{ -} +QSpellchecker::QSpellchecker(Dialog & parent) + : base_class(parent, _("LyX: Spell-check Document")) +{} void QSpellchecker::build_dialog() @@ -43,6 +44,12 @@ void QSpellchecker::build_dialog() } +void QSpellchecker::update_contents() +{ + controller().check(); +} + + void QSpellchecker::accept() { controller().ignoreAll(); diff --git a/src/frontends/qt2/QSpellchecker.h b/src/frontends/qt2/QSpellchecker.h index 7fef6de58e..2c961f1bdc 100644 --- a/src/frontends/qt2/QSpellchecker.h +++ b/src/frontends/qt2/QSpellchecker.h @@ -13,20 +13,19 @@ #ifndef QSPELLCHECKER_H #define QSPELLCHECKER_H - -#include "Qt2Base.h" +#include "QDialogView.h" class ControlSpellchecker; class QSpellcheckerDialog; class QSpellchecker - : public Qt2CB > + : public QController > { public: friend class QSpellcheckerDialog; - QSpellchecker(); + QSpellchecker(Dialog &); /// update from controller void partialUpdate(int id); @@ -38,8 +37,8 @@ private: /// Apply changes virtual void apply() {} - /// not needed - virtual void update_contents() {} + /// + virtual void update_contents(); /// build the dialog virtual void build_dialog(); }; diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index cb32131fd1..88fd766b94 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -1,3 +1,11 @@ +2004-03-31 Angus Leeming + + * Dialogs.C (build): added spellchecker dialog. + * Dialogs2.C (showSpellchecker): removed. + + * FormSpellchecker.[Ch]: + * forms/form_spellchecker.fd: converted to the Dialog-based scheme. + 2004-03-31 Angus Leeming * Dialogs.C (build): added preferences dialog. diff --git a/src/frontends/xforms/Dialogs.C b/src/frontends/xforms/Dialogs.C index 6192cb1bb9..202af2b8b7 100644 --- a/src/frontends/xforms/Dialogs.C +++ b/src/frontends/xforms/Dialogs.C @@ -37,6 +37,7 @@ #include "ControlSearch.h" #include "ControlSendto.h" #include "ControlShowFile.h" +#include "ControlSpellchecker.h" #include "ControlTabular.h" #include "ControlTabularCreate.h" #include "ControlToc.h" @@ -75,6 +76,7 @@ #include "FormSearch.h" #include "FormSendto.h" #include "FormShowFile.h" +#include "FormSpellchecker.h" #include "FormTabularCreate.h" #include "FormText.h" #include "FormToc.h" @@ -127,8 +129,8 @@ char const * const dialognames[] = { "mathgreek", "mathmisc", "mathdots", "mathbigoperators", "mathamsmisc", "mathamsarrows", "mathamsrelations", "mathamsnegatedrelations", "mathamsoperators", "mathdelimiter", "mathmatrix", "mathspace", "mathstyle", -"note", "paragraph", "prefs", "print", "ref", "sendto", "tabular", -"tabularcreate", "texinfo", +"note", "paragraph", "prefs", "print", "ref", "sendto", "spellchecker", +"tabular", "tabularcreate", "texinfo", #ifdef HAVE_LIBAIKSAURUS "thesaurus", @@ -454,6 +456,10 @@ Dialog * Dialogs::build(string const & name) dialog->setController(new ControlSendto(*dialog)); dialog->setView(new FormSendto(*dialog)); dialog->bc().bp(new OkApplyCancelPolicy); + } else if (name == "spellchecker") { + dialog->setController(new ControlSpellchecker(*dialog)); + dialog->setView(new FormSpellchecker(*dialog)); + dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy); } else if (name == "tabular") { dialog->setController(new ControlTabular(*dialog)); dialog->setView(new FormTabular(*dialog)); diff --git a/src/frontends/xforms/Dialogs2.C b/src/frontends/xforms/Dialogs2.C index 67b6b7e363..adf60ee062 100644 --- a/src/frontends/xforms/Dialogs2.C +++ b/src/frontends/xforms/Dialogs2.C @@ -22,28 +22,19 @@ #include "FormPreamble.h" #include "forms/form_preamble.h" -#include "ControlSpellchecker.h" -#include "FormSpellchecker.h" -#include "forms/form_spellchecker.h" - typedef GUI PreambleDialog; -typedef GUI -SpellcheckerDialog; - struct Dialogs::Impl { Impl(LyXView & lv, Dialogs & d); - PreambleDialog preamble; - SpellcheckerDialog spellchecker; + PreambleDialog preamble; }; Dialogs::Impl::Impl(LyXView & lv, Dialogs & d) - : preamble(lv, d), - spellchecker(lv, d) + : preamble(lv, d) {} @@ -63,9 +54,3 @@ void Dialogs::showPreamble() { pimpl_->preamble.controller().show(); } - - -void Dialogs::showSpellchecker() -{ - pimpl_->spellchecker.controller().show(); -} diff --git a/src/frontends/xforms/FormSpellchecker.C b/src/frontends/xforms/FormSpellchecker.C index b47713bb15..3a4bccbdfb 100644 --- a/src/frontends/xforms/FormSpellchecker.C +++ b/src/frontends/xforms/FormSpellchecker.C @@ -11,9 +11,10 @@ #include #include "FormSpellchecker.h" -#include "ControlSpellchecker.h" #include "forms/form_spellchecker.h" +#include "controllers/ControlSpellchecker.h" + #include "Tooltips.h" #include "xforms_helpers.h" #include "xformsBC.h" @@ -26,10 +27,10 @@ using std::string; -typedef FormCB > base_class; +typedef FormController > base_class; -FormSpellchecker::FormSpellchecker() - : base_class(_("Spell-check Document")) +FormSpellchecker::FormSpellchecker(Dialog & parent) + : base_class(parent, _("Spell-check document")) {} @@ -50,7 +51,7 @@ void FormSpellchecker::build() // callback for double click in browser fl_set_browser_dblclick_callback(dialog_->browser_suggestions, - C_FormBaseInputCB, 2); + C_FormDialogView_InputCB, 2); // do not allow setting of slider by the mouse fl_deactivate_object(dialog_->slider_progress); @@ -76,6 +77,12 @@ void FormSpellchecker::build() } +void FormSpellchecker::update() +{ + controller().check(); +} + + void FormSpellchecker::partialUpdate(int s) { ControlSpellchecker::State const state = diff --git a/src/frontends/xforms/FormSpellchecker.h b/src/frontends/xforms/FormSpellchecker.h index f5fc7058fe..5a3f036e4f 100644 --- a/src/frontends/xforms/FormSpellchecker.h +++ b/src/frontends/xforms/FormSpellchecker.h @@ -12,8 +12,7 @@ #ifndef FORMSPELLCHECKER_H #define FORMSPELLCHECKER_H - -#include "FormBase.h" +#include "FormDialogView.h" class ControlSpellchecker; struct FD_spellchecker; @@ -21,17 +20,17 @@ struct FD_spellchecker; /** This class provides an XForms implementation of the FormSpellchecker Dialog. */ class FormSpellchecker - : public FormCB > { + : public FormController > { public: /// - FormSpellchecker(); + FormSpellchecker(Dialog &); private: /// not needed. virtual void apply() {} /// Build the dialog virtual void build(); - /// not needed. - virtual void update() {} + /// + virtual void update(); /// set suggestions and exit message virtual void partialUpdate(int); diff --git a/src/frontends/xforms/forms/form_spellchecker.fd b/src/frontends/xforms/forms/form_spellchecker.fd index bd499f3fd2..b3bf82a281 100644 --- a/src/frontends/xforms/forms/form_spellchecker.fd +++ b/src/frontends/xforms/forms/form_spellchecker.fd @@ -82,7 +82,7 @@ shortcut: resize: FL_RESIZE_X gravity: FL_NorthWest FL_NorthEast name: text_unknown -callback: C_FormBaseInputCB +callback: C_FormDialogView_InputCB argument: 0 -------------------- @@ -100,7 +100,7 @@ shortcut: resize: FL_RESIZE_X gravity: FL_NorthWest FL_NorthEast name: input_replacement -callback: C_FormBaseInputCB +callback: C_FormDialogView_InputCB argument: 0 -------------------- @@ -118,7 +118,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NorthWest FL_SouthEast name: browser_suggestions -callback: C_FormBaseInputCB +callback: C_FormDialogView_InputCB argument: 0 -------------------- @@ -136,7 +136,7 @@ shortcut: resize: FL_RESIZE_NONE gravity: FL_NorthEast FL_NorthEast name: button_add -callback: C_FormBaseInputCB +callback: C_FormDialogView_InputCB argument: 0 -------------------- @@ -154,7 +154,7 @@ shortcut: resize: FL_RESIZE_X gravity: FL_NorthEast FL_NorthEast name: button_ignore -callback: C_FormBaseInputCB +callback: C_FormDialogView_InputCB argument: 0 -------------------- @@ -172,7 +172,7 @@ shortcut: resize: FL_RESIZE_X gravity: FL_NorthEast FL_NorthEast name: button_accept -callback: C_FormBaseInputCB +callback: C_FormDialogView_InputCB argument: 0 -------------------- @@ -190,7 +190,7 @@ shortcut: resize: FL_RESIZE_NONE gravity: FL_SouthEast FL_SouthEast name: button_close -callback: C_FormBaseCancelCB +callback: C_FormDialogView_CancelCB argument: 0 -------------------- @@ -208,7 +208,7 @@ shortcut: resize: FL_RESIZE_NONE gravity: FL_NorthEast FL_NorthEast name: button_replace -callback: C_FormBaseInputCB +callback: C_FormDialogView_InputCB argument: 0 -------------------- diff --git a/src/lyxfunc.C b/src/lyxfunc.C index 5a316ad6d4..7a99816e91 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -1051,8 +1051,6 @@ void LyXFunc::dispatch(FuncRequest const & cmd, bool verbose) } else if (name == "preamble") owner->getDialogs().showPreamble(); - else if (name == "spellchecker") - owner->getDialogs().showSpellchecker(); else if (name == "latexlog") { pair const logfile = -- 2.39.2