From 071d35750a7834d019b33b64de40afc6334ff231 Mon Sep 17 00:00:00 2001 From: Angus Leeming Date: Fri, 30 Mar 2001 19:24:28 +0000 Subject: [PATCH] controller-view split for TOC popup. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1863 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/ChangeLog | 5 + src/frontends/controllers/ChangeLog | 7 + src/frontends/controllers/ControlToc.C | 113 +++++++++++++ src/frontends/controllers/ControlToc.h | 50 ++++++ src/frontends/controllers/GUI.h | 14 ++ src/frontends/controllers/Makefile.am | 2 + src/frontends/xforms/ChangeLog | 9 + src/frontends/xforms/Dialogs.C | 6 +- src/frontends/xforms/FormCitation.C | 2 +- src/frontends/xforms/FormCitation.h | 4 +- src/frontends/xforms/FormMathsPanel.C | 4 +- src/frontends/xforms/FormToc.C | 226 +++++++------------------ src/frontends/xforms/FormToc.h | 49 +++--- src/frontends/xforms/form_toc.C | 8 +- src/frontends/xforms/form_toc.h | 4 +- src/frontends/xforms/forms/form_toc.fd | 8 +- src/lyxfunc.C | 2 + 17 files changed, 299 insertions(+), 214 deletions(-) create mode 100644 src/frontends/controllers/ControlToc.C create mode 100644 src/frontends/controllers/ControlToc.h diff --git a/src/ChangeLog b/src/ChangeLog index fce7eaf50c..4268394534 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2001-03-30 Angus Leeming + + * lyxfunc.C (Dispatch): prevent crash in LFUN_GOTO_PARAGRAPH when + the LyXParagraph * is 0. + 2001-03-29 Juergen Vigna * vspace.C: added support for %, c%, p%, l%. diff --git a/src/frontends/controllers/ChangeLog b/src/frontends/controllers/ChangeLog index d0f779f39f..9d2c68d849 100644 --- a/src/frontends/controllers/ChangeLog +++ b/src/frontends/controllers/ChangeLog @@ -1,3 +1,10 @@ +2001-03-30 Angus Leeming + + * ControlToc.[Ch]: new files; a controller for the TOC popup. + + * GUI.h: + * Makefile.am: associated changes with all of the above. + 2001-03-30 Angus Leeming * ControlExternal.C: bug fixes. Can now apply changes to the inset diff --git a/src/frontends/controllers/ControlToc.C b/src/frontends/controllers/ControlToc.C new file mode 100644 index 0000000000..0f46bded1f --- /dev/null +++ b/src/frontends/controllers/ControlToc.C @@ -0,0 +1,113 @@ +/* This file is part of + * ====================================================== + * + * LyX, The Document Processor + * + * Copyright 2001 The LyX Team. + * + * ====================================================== + * + * \file ControlToc.C + * \author Angus Leeming + */ + +#include + +#ifdef __GNUG__ +#pragma implementation +#endif + +#include "ControlToc.h" +#include "buffer.h" +#include "Dialogs.h" +#include "LyXView.h" +#include "lyxfunc.h" +#include "support/lstrings.h" // tostr + +using std::vector; +using SigC::slot; + +ControlToc::ControlToc(LyXView & lv, Dialogs & d) + : ControlCommand(lv, d, LFUN_TOC_INSERT) +{ + d_.showTOC.connect(slot(this, &ControlToc::showInset)); + d_.createTOC.connect(slot(this, &ControlToc::createInset)); +} + + +void ControlToc::Goto(int const & id) const +{ + string const tmp = tostr(id); + lv_.getLyXFunc()->Dispatch(LFUN_GOTO_PARAGRAPH, tmp); +} + + +vector const ControlToc::getTypes() const +{ + vector types; + + Buffer::Lists const tmp = lv_.view()->buffer()->getLists(); + + Buffer::Lists::const_iterator cit = tmp.begin(); + Buffer::Lists::const_iterator end = tmp.end(); + + for (; cit != end; ++cit) { + types.push_back(cit->first.c_str()); + } + + return types; +} + + +Buffer::SingleList const ControlToc::getContents(string const & type) const +{ + Buffer::SingleList contents; + + Buffer::TocItem noContent(0, 0, string()); + + // This shouldn't be possible... + if (!lv_.view()->available()) { + noContent.str = _("*** No Document ***"); + contents.push_back(noContent); + return contents; + } + + Buffer::Lists tmp = lv_.view()->buffer()->getLists(); + + Buffer::Lists::iterator it = tmp.find(type); + + if (it == tmp.end()) { + noContent.str = _("*** No Lists ***"); + contents.push_back(noContent); + return contents; + } + + return it->second; +} + + +namespace toc +{ + +string getType(string const & cmdName) +{ + string type; + + // It would be nice to have a map to extract this info. + // Does one already exist, Lars? + if (cmdName == "tableofcontents" ) + type = "TOC"; + + else if (cmdName == "listofalgorithms" ) + type = "algorithm"; + + else if (cmdName == "listoffigures" ) + type = "figure"; + + else + type = "table"; + + return type; +} + +} // namespace toc diff --git a/src/frontends/controllers/ControlToc.h b/src/frontends/controllers/ControlToc.h new file mode 100644 index 0000000000..cc06c42e81 --- /dev/null +++ b/src/frontends/controllers/ControlToc.h @@ -0,0 +1,50 @@ +/* This file is part of + * ====================================================== + * + * LyX, The Document Processor + * + * Copyright 2001 The LyX Team. + * + * ====================================================== + * + * \file ControlToc.h + * \author Angus Leeming + */ + +#ifndef CONTROLTOC_H +#define CONTROLTOC_H + +#ifdef __GNUG__ +#pragma interface +#endif + +#include "ControlCommand.h" +#include "buffer.h" // Buffer::SingleList + +/** A controller for TOC dialogs. + */ +class ControlToc : public ControlCommand +{ +public: + /// + ControlToc(LyXView &, Dialogs &); + + /// Goto this paragraph id + void Goto(int const & id) const; + + /// Returns a vector of list types in the document + std::vector const getTypes() const; + + /// Given a type, returns the contents + Buffer::SingleList const getContents(string const & type) const; +}; + +namespace toc +{ + /** Given the cmdName of the TOC param, returns the type used + by ControlToc::getContents() */ + string getType(string const & cmdName); + +} // namespace toc + +#endif // CONTROLTOC_H diff --git a/src/frontends/controllers/GUI.h b/src/frontends/controllers/GUI.h index cc66e2dc58..7f95c4eb7b 100644 --- a/src/frontends/controllers/GUI.h +++ b/src/frontends/controllers/GUI.h @@ -294,6 +294,20 @@ public: }; +/** Specialization for Toc dialog + */ +class ControlToc; + +template +class GUIToc : + public GUI { +public: + /// + GUIToc(LyXView & lv, Dialogs & d) + : GUI(lv, d) {} +}; + + /** Specialization for TabularCreate dialog */ class ControlTabularCreate; diff --git a/src/frontends/controllers/Makefile.am b/src/frontends/controllers/Makefile.am index 69636dd8d5..ec940ff01f 100644 --- a/src/frontends/controllers/Makefile.am +++ b/src/frontends/controllers/Makefile.am @@ -65,6 +65,8 @@ libcontrollers_la_SOURCES=\ ControlSplash.h \ ControlTabularCreate.C \ ControlTabularCreate.h \ + ControlToc.C \ + ControlToc.h \ ControlUrl.C \ ControlUrl.h \ ControlVCLog.C \ diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index d2d8bd097a..f8485fb51e 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -1,3 +1,12 @@ +2001-03-30 Angus Leeming + + * FormMathsPanel.C (c-tor): set button controller cancel label to close. + + * FormToc.[Ch]: + * forms/form_toc.fd: implemented controller-view split. + + * Dialogs.C: associated changes. + 2001-03-30 Angus Leeming * FormCitation.C: diff --git a/src/frontends/xforms/Dialogs.C b/src/frontends/xforms/Dialogs.C index 2783a4cc2a..0bb03c43c0 100644 --- a/src/frontends/xforms/Dialogs.C +++ b/src/frontends/xforms/Dialogs.C @@ -38,6 +38,7 @@ #include "ControlSearch.h" #include "ControlSplash.h" #include "ControlTabularCreate.h" +#include "ControlToc.h" #include "ControlUrl.h" #include "ControlVCLog.h" @@ -63,6 +64,7 @@ #include "form_search.h" #include "form_splash.h" #include "form_tabular_create.h" +#include "form_toc.h" #include "form_url.h" #include "FormBibitem.h" @@ -84,6 +86,7 @@ #include "FormSearch.h" #include "FormSplash.h" #include "FormTabularCreate.h" +#include "FormToc.h" #include "FormUrl.h" #include "FormVCLog.h" @@ -92,7 +95,6 @@ #include "FormParagraph.h" #include "FormPreferences.h" #include "FormTabular.h" -#include "FormToc.h" // Signal enabling all visible popups to be redrawn if so desired. // E.g., when the GUI colours have been remapped. @@ -120,6 +122,7 @@ Dialogs::Dialogs(LyXView * lv) add(new GUIRef(*lv, *this)); add(new GUISearch(*lv, *this)); add(new GUITabularCreate(*lv, *this)); + add(new GUIToc(*lv, *this)); add(new GUIUrl(*lv, *this)); add(new GUIVCLog(*lv, *this)); @@ -128,7 +131,6 @@ Dialogs::Dialogs(LyXView * lv) add(new FormParagraph(lv, this)); add(new FormPreferences(lv, this)); add(new FormTabular(lv, this)); - add(new FormToc(lv, this)); // reduce the number of connections needed in // dialogs by a simple connection here. diff --git a/src/frontends/xforms/FormCitation.C b/src/frontends/xforms/FormCitation.C index 415387cf35..8f235a759d 100644 --- a/src/frontends/xforms/FormCitation.C +++ b/src/frontends/xforms/FormCitation.C @@ -3,7 +3,7 @@ * * LyX, The Document Processor * - * Copyright 2000 The LyX Team. + * Copyright 2000-2001 The LyX Team. * * ====================================================== * diff --git a/src/frontends/xforms/FormCitation.h b/src/frontends/xforms/FormCitation.h index a353636ecd..b40c33c57e 100644 --- a/src/frontends/xforms/FormCitation.h +++ b/src/frontends/xforms/FormCitation.h @@ -1,13 +1,13 @@ -// -*- C++ -*- /* This file is part of * ====================================================== * * LyX, The Document Processor * - * Copyright 2000 The LyX Team. + * Copyright 2000-2001 The LyX Team. * * ====================================================== * + * \file FormCitation.h * \author Angus Leeming */ diff --git a/src/frontends/xforms/FormMathsPanel.C b/src/frontends/xforms/FormMathsPanel.C index a1581e7f62..0f206660f8 100644 --- a/src/frontends/xforms/FormMathsPanel.C +++ b/src/frontends/xforms/FormMathsPanel.C @@ -55,7 +55,7 @@ using SigC::slot; FormMathsPanel::FormMathsPanel(LyXView * lv, Dialogs * d) : FormBaseBD(lv, d, _("Maths Panel")), - active_(0) + active_(0), bc_("Close") { deco_.reset( new FormMathsDeco( lv, d, *this)); delim_.reset( new FormMathsDelim( lv, d, *this)); @@ -263,7 +263,7 @@ void FormMathsPanel::mathDisplay() const FormMathsSub::FormMathsSub(LyXView * lv, Dialogs * d, FormMathsPanel const & p, string const & t) - : FormBaseBD(lv, d, t), parent_(p) + : FormBaseBD(lv, d, t), parent_(p), bc_("Close") {} diff --git a/src/frontends/xforms/FormToc.C b/src/frontends/xforms/FormToc.C index f69f633e7c..d818a07078 100644 --- a/src/frontends/xforms/FormToc.C +++ b/src/frontends/xforms/FormToc.C @@ -1,81 +1,45 @@ -// -*- C++ -*- /* This file is part of * ====================================================== * * LyX, The Document Processor * - * Copyright 2000 The LyX Team. + * Copyright 2000-2001 The LyX Team. * * ====================================================== + * + * \file FormToc.C + * \author Angus Leeming, a.leeming@ic.ac.uk */ #include #include -#include FORMS_H_LOCATION - #ifdef __GNUG__ #pragma implementation #endif - -#include "Dialogs.h" +#include "xformsBC.h" +#include "ControlToc.h" #include "FormToc.h" -#include "LyXView.h" #include "form_toc.h" -#include "lyxtext.h" -#include "lyxfunc.h" -#include "support/lstrings.h" - -using std::vector; -using SigC::slot; - -// The current code uses the apply() for handling the Update button and the -// type-of-table selection and cancel() for the close button. This is a little -// confusing to the button controller so I've made an IgnorantPolicy to cover -// this situation since the dialog doesn't care about buttons. ARRae 20001013 -FormToc::FormToc(LyXView * lv, Dialogs * d) - : FormCommand(lv, d, _("Table of Contents")), - dialog_(0) -{ - // let the dialog be shown - // These are permanent connections so we won't bother - // storing a copy because we won't be disconnecting. - d->showTOC.connect(slot(this, &FormToc::showInset)); - d->createTOC.connect(slot(this, &FormToc::createInset)); -} +#include "helper_funcs.h" // getStringFromVector +#include "support/lstrings.h" // frontStrip, strip -FL_FORM * FormToc::form() const -{ - if (dialog_.get()) - return dialog_->form; - return 0; -} +typedef FormCB > base_class; - -void FormToc::disconnect() -{ - toclist.clear(); - FormCommand::disconnect(); -} +FormToc::FormToc(ControlToc & c) + : base_class(c, _("Table of Contents")) +{} void FormToc::build() { dialog_.reset(build_toc()); -#if 0 - fl_addto_choice(dialog_->choice_toc_type, - _(" TOC | LOF | LOT | LOA ")); -#else - Buffer::Lists const tmp = lv_->view()->buffer()->getLists(); - Buffer::Lists::const_iterator cit = tmp.begin(); - Buffer::Lists::const_iterator end = tmp.end(); - for (; cit != end; ++cit) { - fl_addto_choice(dialog_->choice_toc_type, cit->first.c_str()); - } -#endif + string const choice = + " " + getStringFromVector(controller().getTypes(), " | ") + " "; + fl_addto_choice(dialog_->choice_toc_type, choice.c_str()); // Manage the cancel/close button bc().setCancel(dialog_->button_cancel); @@ -85,122 +49,65 @@ void FormToc::build() void FormToc::update() { -#if 0 - Buffer::TocType type; - - if (params.getCmdName() == "tableofcontents" ) - type = Buffer::TOC_TOC; - - else if (params.getCmdName() == "listofalgorithms" ) - type = Buffer::TOC_LOA; - - else if (params.getCmdName() == "listoffigures" ) - type = Buffer::TOC_LOF; - - else - type = Buffer::TOC_LOT; - - fl_set_choice( dialog_->choice_toc_type, type+1 ); -#else -#warning Reimplement (Lgb) -#endif - updateToc(); + updateType(); + updateContents(); } -void FormToc::updateToc() +ButtonPolicy::SMInput FormToc::input(FL_OBJECT *, long) { -#if 0 - if (!lv_->view()->available()) { - toclist.clear(); - fl_clear_browser( dialog_->browser_toc ); - fl_add_browser_line( dialog_->browser_toc, - _("*** No Document ***")); - return; + updateContents(); + + unsigned int const choice = fl_get_browser( dialog_->browser_toc ); + if (0 < choice && choice - 1 < toclist_.size()) { + controller().Goto(toclist_[choice-1].par->id()); } - vector > tmp = - lv_->view()->buffer()->getTocList(); - int type = fl_get_choice( dialog_->choice_toc_type ) - 1; + return ButtonPolicy::SMI_VALID; +} + + +void FormToc::updateType() +{ + string const type = toc::getType(controller().params().getCmdName()); + + fl_set_choice(dialog_->choice_toc_type, 1); + for (int i = 1; + i <= fl_get_choice_maxitems(dialog_->choice_toc_type); ++i) { + string const choice = + fl_get_choice_item_text(dialog_->choice_toc_type, i); + + if (choice == type) { + fl_set_choice(dialog_->choice_toc_type, i); + break; + } + } +} + + +void FormToc::updateContents() +{ + string const type = + frontStrip(strip(fl_get_choice_text(dialog_->choice_toc_type))); + + Buffer::SingleList const contents = controller().getContents(type); // Check if all elements are the same. - if (toclist.size() == tmp[type].size()) { - unsigned int i = 0; - for (; i < toclist.size(); ++i) { - if (toclist[i] != tmp[type][i]) - break; - } - if (i >= toclist.size()) return; - } - - // List has changed. Update browser - toclist = tmp[type]; - - static Buffer * buffer = 0; - int topline = 0; - int line = 0; - if (buffer == lv_->view()->buffer()) { - topline = fl_get_browser_topline( dialog_->browser_toc ); - line = fl_get_browser( dialog_->browser_toc ); - } else - buffer = lv_->view()->buffer(); - - fl_clear_browser( dialog_->browser_toc ); - - for (vector::const_iterator it = toclist.begin(); - it != toclist.end(); ++it) - fl_add_browser_line( dialog_->browser_toc, - (string(4 * (*it).depth, ' ') - + (*it).str).c_str()); - - fl_set_browser_topline( dialog_->browser_toc, topline ); - fl_select_browser_line( dialog_->browser_toc, line ); -#else -#warning Fix Me! (Lgb) - if (!lv_->view()->available()) { - toclist.clear(); - fl_clear_browser( dialog_->browser_toc ); - fl_add_browser_line( dialog_->browser_toc, - _("*** No Document ***")); - return; - } - - Buffer::Lists tmp = lv_->view()->buffer()->getLists(); - string const type = - fl_get_choice_item_text(dialog_->choice_toc_type, - fl_get_choice(dialog_->choice_toc_type)); - - Buffer::Lists::iterator it = tmp.find(type); - - if (it != tmp.end()) { - // Check if all elements are the same. - if (toclist == it->second) { - return; - } - } else if (it == tmp.end()) { - toclist.clear(); - fl_clear_browser(dialog_->browser_toc); - fl_add_browser_line(dialog_->browser_toc, - _("*** No Lists ***")); + if (toclist_ == contents) { return; } // List has changed. Update browser - toclist = it->second; + toclist_ = contents; - static Buffer * buffer = 0; - int topline = 0; - int line = 0; - if (buffer == lv_->view()->buffer()) { - topline = fl_get_browser_topline(dialog_->browser_toc); - line = fl_get_browser( dialog_->browser_toc ); - } else - buffer = lv_->view()->buffer(); + unsigned int const topline = + fl_get_browser_topline(dialog_->browser_toc); + unsigned int const line = fl_get_browser(dialog_->browser_toc); - fl_clear_browser(dialog_->browser_toc); + fl_clear_browser( dialog_->browser_toc ); - Buffer::SingleList::const_iterator cit = toclist.begin(); - Buffer::SingleList::const_iterator end = toclist.end(); + Buffer::SingleList::const_iterator cit = toclist_.begin(); + Buffer::SingleList::const_iterator end = toclist_.end(); for (; cit != end; ++cit) { string const line = string(4 * cit->depth, ' ') + cit->str; @@ -209,19 +116,4 @@ void FormToc::updateToc() fl_set_browser_topline(dialog_->browser_toc, topline); fl_select_browser_line(dialog_->browser_toc, line); -#endif -} - - -bool FormToc::input(FL_OBJECT *, long) -{ - updateToc(); - - unsigned int const choice = fl_get_browser( dialog_->browser_toc ); - if (0 < choice && choice - 1 < toclist.size()) { - string const tmp = tostr(toclist[choice-1].par->id()); - lv_->getLyXFunc()->Dispatch(LFUN_GOTO_PARAGRAPH, tmp); - } - - return true; } diff --git a/src/frontends/xforms/FormToc.h b/src/frontends/xforms/FormToc.h index ad7ec136bf..215b0c1a7a 100644 --- a/src/frontends/xforms/FormToc.h +++ b/src/frontends/xforms/FormToc.h @@ -1,67 +1,56 @@ -// -*- C++ -*- /* This file is part of * ====================================================== * * LyX, The Document Processor * - * Copyright 2000 The LyX Team. + * Copyright 2000-2001 The LyX Team. * * ====================================================== + * + * \file FormToc.h + * \author Angus Leeming */ #ifndef FORMTOC_H #define FORMTOC_H -#include - #ifdef __GNUG__ #pragma interface #endif -#include "FormInset.h" +#include "FormBase.h" #include "buffer.h" +class ControlToc; struct FD_form_toc; /** This class provides an XForms implementation of the FormToc Dialog. */ -class FormToc : public FormCommand { +class FormToc : public FormCB > { public: /// - FormToc(LyXView *, Dialogs *); -private: - /// Pointer to the actual instantiation of the ButtonController. - virtual xformsBC & bc(); - /// Disconnect signals. Also perform any necessary housekeeping. - virtual void disconnect(); + FormToc(ControlToc &); +private: + /// not needed + virtual void apply() {} /// Build the dialog virtual void build(); - /// bool indicates if a buffer switch took place - virtual void updateSlot(bool) { update(); } /// Update dialog before showing it virtual void update(); /// Filter the inputs on callback from xforms - virtual bool input( FL_OBJECT *, long); - /// Pointer to the actual instantiation of the xforms form - virtual FL_FORM * form() const; + virtual ButtonPolicy::SMInput input(FL_OBJECT *, long); + /// - void updateToc(); + void updateType(); /// + void updateContents(); + + /// Fdesign generated method FD_form_toc * build_toc(); /// - Buffer::SingleList toclist; - /// Real GUI implementation. - boost::scoped_ptr dialog_; - /// The ButtonController - ButtonController bc_; + Buffer::SingleList toclist_; }; - -inline -xformsBC & FormToc::bc() -{ - return bc_; -} -#endif +#endif // FORMTOC_H diff --git a/src/frontends/xforms/form_toc.C b/src/frontends/xforms/form_toc.C index 61869625b5..46538a0e38 100644 --- a/src/frontends/xforms/form_toc.C +++ b/src/frontends/xforms/form_toc.C @@ -27,7 +27,7 @@ FD_form_toc * FormToc::build_toc() obj = fl_add_box(FL_UP_BOX, 0, 0, 420, 340, ""); fdui->browser_toc = obj = fl_add_browser(FL_HOLD_BROWSER, 10, 10, 400, 280, ""); fl_set_object_gravity(obj, FL_NorthWest, FL_SouthEast); - fl_set_object_callback(obj, C_FormBaseDeprecatedInputCB, 0); + fl_set_object_callback(obj, C_FormBaseInputCB, 0); { char const * const dummy = N_("Update|#U"); fdui->button_update = obj = fl_add_button(FL_NORMAL_BUTTON, 200, 300, 100, 30, idex(_(dummy))); @@ -35,7 +35,7 @@ FD_form_toc * FormToc::build_toc() } fl_set_object_lsize(obj, FL_NORMAL_SIZE); fl_set_object_gravity(obj, FL_SouthEast, FL_SouthEast); - fl_set_object_callback(obj, C_FormBaseDeprecatedInputCB, 0); + fl_set_object_callback(obj, C_FormBaseInputCB, 0); { char const * const dummy = N_("Type|#T"); fdui->choice_toc_type = obj = fl_add_choice(FL_NORMAL_CHOICE, 60, 300, 130, 30, idex(_(dummy))); @@ -43,7 +43,7 @@ FD_form_toc * FormToc::build_toc() } fl_set_object_boxtype(obj, FL_FRAME_BOX); fl_set_object_gravity(obj, FL_SouthEast, FL_SouthEast); - fl_set_object_callback(obj, C_FormBaseDeprecatedInputCB, 0); + fl_set_object_callback(obj, C_FormBaseInputCB, 0); { char const * const dummy = N_("Close|^[^M"); fdui->button_cancel = obj = fl_add_button(FL_RETURN_BUTTON, 310, 300, 100, 30, idex(_(dummy))); @@ -51,7 +51,7 @@ FD_form_toc * FormToc::build_toc() } fl_set_object_lsize(obj, FL_NORMAL_SIZE); fl_set_object_gravity(obj, FL_SouthEast, FL_SouthEast); - fl_set_object_callback(obj, C_FormBaseDeprecatedCancelCB, 0); + fl_set_object_callback(obj, C_FormBaseCancelCB, 0); fl_end_form(); fdui->form->fdui = fdui; diff --git a/src/frontends/xforms/form_toc.h b/src/frontends/xforms/form_toc.h index 0e0780902a..38556cf0b2 100644 --- a/src/frontends/xforms/form_toc.h +++ b/src/frontends/xforms/form_toc.h @@ -5,8 +5,8 @@ #define FD_form_toc_h_ /** Callbacks, globals and object handlers **/ -extern "C" void C_FormBaseDeprecatedInputCB(FL_OBJECT *, long); -extern "C" void C_FormBaseDeprecatedCancelCB(FL_OBJECT *, long); +extern "C" void C_FormBaseInputCB(FL_OBJECT *, long); +extern "C" void C_FormBaseCancelCB(FL_OBJECT *, long); /**** Forms and Objects ****/ diff --git a/src/frontends/xforms/forms/form_toc.fd b/src/frontends/xforms/forms/form_toc.fd index 8b38ad414e..75624447cd 100644 --- a/src/frontends/xforms/forms/form_toc.fd +++ b/src/frontends/xforms/forms/form_toc.fd @@ -45,7 +45,7 @@ shortcut: resize: FL_RESIZE_ALL gravity: FL_NorthWest FL_SouthEast name: browser_toc -callback: C_FormBaseDeprecatedInputCB +callback: C_FormBaseInputCB argument: 0 -------------------- @@ -63,7 +63,7 @@ shortcut: resize: FL_RESIZE_NONE gravity: FL_SouthEast FL_SouthEast name: button_update -callback: C_FormBaseDeprecatedInputCB +callback: C_FormBaseInputCB argument: 0 -------------------- @@ -81,7 +81,7 @@ shortcut: resize: FL_RESIZE_NONE gravity: FL_SouthEast FL_SouthEast name: choice_toc_type -callback: C_FormBaseDeprecatedInputCB +callback: C_FormBaseInputCB argument: 0 -------------------- @@ -99,7 +99,7 @@ shortcut: resize: FL_RESIZE_NONE gravity: FL_SouthEast FL_SouthEast name: button_cancel -callback: C_FormBaseDeprecatedCancelCB +callback: C_FormBaseCancelCB argument: 0 ============================== diff --git a/src/lyxfunc.C b/src/lyxfunc.C index 32816df661..d1843badfc 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -1227,6 +1227,8 @@ string const LyXFunc::Dispatch(int ac, int id; istr >> id; LyXParagraph * par = TEXT()->GetParFromID(id); + if (par == 0) + break; // Set the cursor TEXT()->SetCursor(owner->view(), par, 0);