From: Jean-Marc Lasgouttes Date: Thu, 3 Aug 2000 12:56:25 +0000 (+0000) Subject: Angus insetindex patch + protect patch from Dekel X-Git-Tag: 1.6.10~22057 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=046b5d824c622204e90fffa690d43008fadaaa2a;p=features.git Angus insetindex patch + protect patch from Dekel git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@950 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/ChangeLog b/ChangeLog index 503fd4ec51..d165bb87ef 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,33 @@ +2000-08-03 Angus Leeming + + * src/commandtags.h: renamed, created some flags for citation + and index + + * src/lyx_gui_misc.C: stripped out old FD_index_form code + + * src/lyxfunc.C (dispatch): use signals to insert index entry + + * src/frontends/Dialogs.h: new signal createIndex + + * src/frontends/xforms/FormCommand.[Ch], + src/frontends/xforms/FormCitation.[Ch], + src/frontends/xforms/FormToc.[Ch], + src/frontends/xforms/FormUrl.[Ch]: clean up and comment better + + * src/insets/insetindex.[Ch]: GUI-independent + + * src/frontends/xforms/FormIndex.[Ch], + * src/frontends/xforms/forms/form_index.fd: xforms implementation + of the Index dialog + + 2000-08-02 Lars Gullik Bjønnes + + * src/insets/insetref.C (Latex): rewrite so that there is now +2000-08-01 Dekel Tsur + + * src/mathed/math_write.C (MathDecorationInset::Write) Put \protect + before \overbrace, \underbrace, \overleftarrow, or \overrightarrow. + 2000-08-02 Lars Gullik Bjønnes * src/insets/insetref.C (Latex): rewrite so that there is now diff --git a/lib/ui/default.ui b/lib/ui/default.ui index 16d00dd0c2..fcdf304165 100644 --- a/lib/ui/default.ui +++ b/lib/ui/default.ui @@ -72,7 +72,7 @@ Menuset OptItem "as LinuxDoc|L" "buffer-export linuxdoc" OptItem "as DocBook|B" "buffer-export docbook" Item "as DVI|D" "buffer-export dvi" - Item "as Postscript|P" "buffer-export postscript" +# Item "as Postscript|P" "buffer-export postscript" Item "as Ascii|A" "buffer-export ascii" Item "as HTML|H" "buffer-export html" OptItem "Custom...|C" "buffer-export custom" diff --git a/po/POTFILES.in b/po/POTFILES.in index 8e277b5b4c..5c8546de1a 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -32,6 +32,8 @@ src/frontends/xforms/FormCopyright.C src/frontends/xforms/form_copyright.C src/frontends/xforms/FormGraphics.C src/frontends/xforms/form_graphics.C +src/frontends/xforms/FormIndex.C +src/frontends/xforms/form_index.C src/frontends/xforms/FormPreferences.C src/frontends/xforms/form_preferences.C src/frontends/xforms/FormPrint.C diff --git a/src/LyXAction.C b/src/LyXAction.C index b27dcbe828..6c52cc6923 100644 --- a/src/LyXAction.C +++ b/src/LyXAction.C @@ -164,7 +164,7 @@ void LyXAction::init() ReadOnly }, { LFUN_RIGHT, "char-forward", N_("Go one char forward"), ReadOnly }, - { LFUN_CREATE_CITATION, "citation-insert", + { LFUN_CITATION_CREATE, "citation-insert", N_("Insert citation"), Noop }, { LFUN_EXEC_COMMAND, "command-execute", "", NoBuffer }, { LFUN_PREFIX, "command-prefix", @@ -247,9 +247,9 @@ void LyXAction::init() { LFUN_HTMLURL, "html-insert", "", Noop }, { LFUN_HYPHENATION, "hyphenation-point-insert", N_("Insert hyphenation point"), Noop }, - { LFUN_INDEX_INSERT, "index-insert", + { LFUN_INDEX_CREATE, "index-insert", N_("Insert index item"), Noop }, - { LFUN_INDEX_INSERT_LAST, "index-insert-last", + { LFUN_INDEX_CREATE_LAST, "index-insert-last", N_("Insert last index item"), Noop }, { LFUN_INDEX_PRINT, "index-print", N_("Insert index list"), Noop }, diff --git a/src/buffer.C b/src/buffer.C index 51d923fc03..9284be47bd 100644 --- a/src/buffer.C +++ b/src/buffer.C @@ -962,7 +962,7 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par, } else if (inscmd.getCmdName() == "BibTeX") { inset = new InsetBibtex(inscmd.getContents(), inscmd.getOptions(), this); } else if (inscmd.getCmdName() == "index") { - inset = new InsetIndex(inscmd.getContents()); + inset = new InsetIndex(inscmd.params()); } else if (inscmd.getCmdName() == "include") { inset = new InsetInclude(inscmd.getContents(), this); } else if (inscmd.getCmdName() == "label") { @@ -984,7 +984,7 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par, || inscmd.getCmdName() == "listoftables") { inset = new InsetTOC(inscmd.params()); } else if (inscmd.getCmdName() == "printindex") { - inset = new InsetPrintIndex(this); + inset = new InsetPrintIndex(inscmd.params()); } else if (inscmd.getCmdName() == "lyxparent") { inset = new InsetParent(inscmd.getContents(), this); } @@ -1193,7 +1193,7 @@ void Buffer::readInset(LyXLex & lex, LyXParagraph *& par, inset = new InsetBibtex(inscmd.getContents(), inscmd.getOptions(), this); } else if (inscmd.getCmdName() == "index") { - inset = new InsetIndex(inscmd.getContents()); + inset = new InsetIndex(inscmd.params()); } else if (inscmd.getCmdName() == "include") { inset = new InsetInclude(inscmd.getContents(), this); } else if (inscmd.getCmdName() == "label") { @@ -1216,7 +1216,7 @@ void Buffer::readInset(LyXLex & lex, LyXParagraph *& par, || inscmd.getCmdName() == "listoftables") { inset = new InsetTOC(inscmd.params()); } else if (inscmd.getCmdName() == "printindex") { - inset = new InsetPrintIndex(this); + inset = new InsetPrintIndex(inscmd.params()); } else if (inscmd.getCmdName() == "lyxparent") { inset = new InsetParent(inscmd.getContents(), this); } diff --git a/src/commandtags.h b/src/commandtags.h index 61cfebcf00..902f2ab7f9 100644 --- a/src/commandtags.h +++ b/src/commandtags.h @@ -196,10 +196,10 @@ enum kb_action { LFUN_MENURELOAD, // Asger 1997-02-02 LFUN_FAX, // Asger 1997-02-10 LFUN_RECONFIGURE, // Asger 1997-02-14 - LFUN_INSERT_CITATION, // AAS 97-02-23 + LFUN_CITATION_INSERT, // AAS 97-02-23 LFUN_INSERT_BIBTEX, // AAS 97-02-23 - LFUN_INDEX_INSERT, // Lgb 97-02-27 - LFUN_INDEX_INSERT_LAST, // 180 // Reh 98-09-17 + LFUN_INDEX_CREATE, // Lgb 97-02-27 + LFUN_INDEX_CREATE_LAST, // 180 // Reh 98-09-17 LFUN_INDEX_PRINT, // Lgb 97-02-27 LFUN_APROPOS, // Asger 1997-02-27 LFUN_LATEX_LOG, // Lgb 97-04-05 @@ -267,12 +267,13 @@ enum kb_action { LFUN_INSET_FLOAT, // Lgb 20000627 LFUN_INSET_LIST, // Lgb 20000627 LFUN_INSET_THEOREM, // Lgb 20000630 - LFUN_CREATE_CITATION, // Angus 20000705 + LFUN_CITATION_CREATE, // Angus 20000705 LFUN_INSET_CAPTION, // Lgb 20000718 LFUN_SWITCHBUFFER, // and where is this comming from? LFUN_INSERT_URL, // Angus 20000726 LFUN_TABULAR_FEATURE, // Jug 20000728 LFUN_LAYOUT_TABULAR, // Jug 20000731 + LFUN_INDEX_INSERT, // Angus 20000803 LFUN_LASTACTION /* this marks the end of the table */ }; diff --git a/src/frontends/Dialogs.h b/src/frontends/Dialogs.h index df2715107f..6d3ac5c906 100644 --- a/src/frontends/Dialogs.h +++ b/src/frontends/Dialogs.h @@ -33,7 +33,6 @@ class InsetGraphics; class InsetBibKey; class InsetBibtex; class InsetInclude; -class InsetIndex; class InsetInfo; class InsetTabular; class InsetCommand; @@ -109,7 +108,9 @@ public: /// Signal1 showInclude; /// - Signal1 showIndex; + Signal1 showIndex; + /// + Signal1 createIndex; /// Signal1 showBibkey; /// diff --git a/src/frontends/xforms/Dialogs.C b/src/frontends/xforms/Dialogs.C index d58f906a00..e193eecc06 100644 --- a/src/frontends/xforms/Dialogs.C +++ b/src/frontends/xforms/Dialogs.C @@ -2,10 +2,11 @@ #include FORMS_H_LOCATION #include "Dialogs.h" +#include "FormCitation.h" #include "FormCopyright.h" -#include "FormPreferences.h" #include "FormGraphics.h" -#include "FormCitation.h" +#include "FormIndex.h" +#include "FormPreferences.h" #include "FormPrint.h" #include "FormTabular.h" #include "FormToc.h" @@ -18,10 +19,11 @@ Dialogs::Dialogs(LyXView * lv) { + dialogs_.push_back(new FormCitation(lv, this)); dialogs_.push_back(new FormCopyright(lv, this)); - dialogs_.push_back(new FormPreferences(lv, this)); dialogs_.push_back(new FormGraphics(lv, this)); - dialogs_.push_back(new FormCitation(lv, this)); + dialogs_.push_back(new FormIndex(lv, this)); + dialogs_.push_back(new FormPreferences(lv, this)); dialogs_.push_back(new FormPrint(lv, this)); dialogs_.push_back(new FormTabular(lv, this)); dialogs_.push_back(new FormToc(lv, this)); diff --git a/src/frontends/xforms/FormCitation.C b/src/frontends/xforms/FormCitation.C index c09e26a4a9..cee0946f1e 100644 --- a/src/frontends/xforms/FormCitation.C +++ b/src/frontends/xforms/FormCitation.C @@ -40,7 +40,7 @@ static vector bibkeys; static vector bibkeysInfo; FormCitation::FormCitation(LyXView * lv, Dialogs * d) - : FormCommand(lv, d, _("Citation")), dialog_(0) + : FormCommand(lv, d, _("Citation")), dialog_(0) { // let the dialog be shown // These are permanent connections so we won't bother @@ -52,11 +52,18 @@ FormCitation::FormCitation(LyXView * lv, Dialogs * d) FormCitation::~FormCitation() { - free(); delete dialog_; } +void FormCitation::clearStore() +{ + citekeys.clear(); + bibkeys.clear(); + bibkeysInfo.clear(); +} + + void FormCitation::build() { dialog_ = build_citation(); @@ -416,7 +423,7 @@ void FormCitation::apply() lv_->view()->updateInset( inset_, true ); } } else { - lv_->getLyXFunc()->Dispatch( LFUN_INSERT_CITATION, + lv_->getLyXFunc()->Dispatch( LFUN_CITATION_INSERT, params.getAsString().c_str() ); } } diff --git a/src/frontends/xforms/FormCitation.h b/src/frontends/xforms/FormCitation.h index 76781bac88..cf542c1703 100644 --- a/src/frontends/xforms/FormCitation.h +++ b/src/frontends/xforms/FormCitation.h @@ -43,17 +43,19 @@ public: //@} private: - /**@name Slot Methods */ - //@{ - virtual void update(); - /// Apply from dialog - virtual void apply(); - /// Filter the inputs - virtual void input( long ); /// Build the dialog virtual void build(); - /// + /// Filter the inputs + virtual void input( long ); + /// Update dialog before showing it + virtual void update(); + /// Apply from dialog (modify or create inset) + virtual void apply(); + /// delete derived class variables from hide() + virtual void clearStore(); + /// Pointer to the actual instantiation of the xform's form virtual FL_FORM * const form() const; + /// void updateBrowser( FL_OBJECT *, std::vector const & ) const; /// @@ -64,7 +66,6 @@ private: void setSize( int, bool ) const; /// FD_form_citation * build_citation(); - //@} /// Real GUI implementation. FD_form_citation * dialog_; diff --git a/src/frontends/xforms/FormCommand.C b/src/frontends/xforms/FormCommand.C index 4f30c131ef..44237d86d6 100644 --- a/src/frontends/xforms/FormCommand.C +++ b/src/frontends/xforms/FormCommand.C @@ -34,15 +34,18 @@ FormCommand::FormCommand(LyXView * lv, Dialogs * d, string const & t) {} +FormCommand::~FormCommand() +{ + free(); +} + + void FormCommand::showInset( InsetCommand * const inset ) { if( dialogIsOpen || inset == 0 ) return; inset_ = inset; - // companion to Lars' commenting out in insetcommand. - // need a better plan perhaps since there seems to be a small - // flaw here if we copy an inset while it's visible - // ih_ = inset_->hide.connect(slot(this, &FormCommand::hide)); + ih_ = inset_->hide.connect(slot(this, &FormCommand::hide)); params = inset->params(); show(); @@ -110,6 +113,7 @@ void FormCommand::hide() inset_ = 0; ih_.disconnect(); dialogIsOpen = false; + clearStore(); } diff --git a/src/frontends/xforms/FormCommand.h b/src/frontends/xforms/FormCommand.h index 34da044836..a0d89367bc 100644 --- a/src/frontends/xforms/FormCommand.h +++ b/src/frontends/xforms/FormCommand.h @@ -31,6 +31,8 @@ class FormCommand : public DialogBase, public noncopyable { public: /// Constructor FormCommand(LyXView *, Dialogs *, string const & ); + /// Destructor + virtual ~FormCommand(); /**@name Real per-instance Callback Methods */ //@{ @@ -44,29 +46,26 @@ public: protected: /**@name Slot Methods */ //@{ - /// Create the dialog if necessary, update it and display it. + /// Slot launching dialog to (possibly) create a new inset void createInset( string const & ); - /// + /// Slot launching dialog to an existing inset void showInset( InsetCommand * const ); - /// - void show(); - /// Hide the dialog. - void hide(); - /// Explicitly free the dialog. - void free(); - /// + //@} + + /// Build the dialog + virtual void build() = 0; + /// Filter the inputs on callback from xforms virtual void input( long ) = 0; - /// + /// Update dialog before showing it virtual void update() = 0; - /// Apply from dialog + /// Apply from dialog (modify or create inset) virtual void apply() = 0; - /// Build the dialog - virtual void build() = 0; - /// + /// delete derived class variables from hide() + virtual void clearStore() {} + /// Pointer to the actual instantiation of the xform's form virtual FL_FORM * const form() const = 0; - //@} - /**@name Private Data */ + /**@name Protected Data */ //@{ /** Which LyXFunc do we use? We could modify Dialogs to have a visible LyXFunc* instead and @@ -77,19 +76,32 @@ protected: Used so we can get at the signals we have to connect to. */ Dialogs * d_; + /// pointer to the inset passed through showInset (if any) + InsetCommand * inset_; + /// the nitty-griity. What is modified and passed back + InsetCommandParams params; + //@} + +private: + /// Create the dialog if necessary, update it and display it. + void show(); + /// Hide the dialog. + void hide(); + /// Explicitly free the dialog. + void free(); + + + /**@name Private Data */ + //@{ /// Update connection. Connection u_; /// Hide connection. Connection h_; /// inset::hide connection. Connection ih_; - /// - InsetCommand * inset_; - /// + /// block opening of form from more than one inset bool dialogIsOpen; - /// - InsetCommandParams params; - /// + /// dialog title, displayed by WM. string title; //@} }; diff --git a/src/frontends/xforms/FormIndex.C b/src/frontends/xforms/FormIndex.C new file mode 100644 index 0000000000..147886c84c --- /dev/null +++ b/src/frontends/xforms/FormIndex.C @@ -0,0 +1,108 @@ +// -*- C++ -*- +/* This file is part of + * ====================================================== + * + * LyX, The Document Processor + * + * Copyright 2000 The LyX Team. + * + * ====================================================== + */ + +#include + +#include FORMS_H_LOCATION + +#ifdef __GNUG__ +#pragma implementation +#endif + + +#include "gettext.h" +#include "Dialogs.h" +#include "FormIndex.h" +#include "LyXView.h" +#include "buffer.h" +#include "form_index.h" +#include "lyxfunc.h" + +FormIndex::FormIndex(LyXView * lv, Dialogs * d) + : FormCommand(lv, d, _("Index")), 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->showIndex.connect(slot(this, &FormIndex::showInset)); + d->createIndex.connect(slot(this, &FormIndex::createInset)); +} + + +FormIndex::~FormIndex() +{ + delete dialog_; +} + + +void FormIndex::build() +{ + dialog_ = build_index(); +} + + +FL_FORM * const FormIndex::form() const +{ + if( dialog_ && dialog_->form_index ) + return dialog_->form_index; + else + return 0; +} + + +void FormIndex::update() +{ + static int ow = -1, oh; + + if (ow < 0) { + ow = dialog_->form_index->w; + oh = dialog_->form_index->h; + + fl_set_form_minsize(dialog_->form_index, ow, oh); + fl_set_form_maxsize(dialog_->form_index, 2*ow, oh); + } + + fl_freeze_form( dialog_->form_index ); + + fl_set_input(dialog_->key, params.getContents().c_str()); + + if( lv_->buffer()->isReadonly() ) { + fl_deactivate_object( dialog_->key ); + fl_deactivate_object( dialog_->ok ); + fl_set_object_lcol( dialog_->ok, FL_INACTIVE ); + } else { + fl_activate_object( dialog_->key ); + fl_activate_object( dialog_->ok ); + fl_set_object_lcol( dialog_->ok, FL_BLACK ); + } + + fl_unfreeze_form( dialog_->form_index ); +} + + +void FormIndex::apply() +{ + if( lv_->buffer()->isReadonly() ) return; + + params.setContents( fl_get_input(dialog_->key) ); + + if( inset_ != 0 ) + { + // Only update if contents have changed + if( params.getContents() != inset_->getContents() ) { + inset_->setParams( params ); + lv_->view()->updateInset( inset_, true ); + } + } else { + lv_->getLyXFunc()->Dispatch( LFUN_INDEX_INSERT, + params.getAsString().c_str() ); + } +} diff --git a/src/frontends/xforms/FormIndex.h b/src/frontends/xforms/FormIndex.h new file mode 100644 index 0000000000..4b7fa42b51 --- /dev/null +++ b/src/frontends/xforms/FormIndex.h @@ -0,0 +1,53 @@ +// -*- C++ -*- +/* This file is part of + * ====================================================== + * + * LyX, The Document Processor + * + * Copyright 2000 The LyX Team. + * + * ====================================================== + */ + +#ifndef FORMINDEX_H +#define FORMINDEX_H + +#ifdef __GNUG__ +#pragma interface +#endif + +#include "FormCommand.h" +struct FD_form_index; + +/** This class provides an XForms implementation of the FormIndex Dialog. + */ +class FormIndex : public FormCommand { +public: + /**@name Constructors and Destructors */ + //@{ + /// + FormIndex(LyXView *, Dialogs *); + /// + ~FormIndex(); + //@} + +private: + /// Build the dialog + virtual void build(); + /// Not used but must be instantiated + virtual void input( long ) {} + /// Update dialog before showing it + virtual void update(); + /// Apply from dialog (modify or create inset) + virtual void apply(); + /// Pointer to the actual instantiation of the xform's form + virtual FL_FORM * const form() const; + /// + FD_form_index * build_index(); + //@} + + /// Real GUI implementation. + FD_form_index * dialog_; +}; + +#endif diff --git a/src/frontends/xforms/FormToc.C b/src/frontends/xforms/FormToc.C index 8063ec4a67..4dba7b0fb0 100644 --- a/src/frontends/xforms/FormToc.C +++ b/src/frontends/xforms/FormToc.C @@ -30,7 +30,7 @@ static vector toclist; FormToc::FormToc(LyXView * lv, Dialogs * d) - : FormCommand(lv, d, _("Table of Contents")), dialog_(0) + : FormCommand(lv, d, _("Table of Contents")), dialog_(0) { // let the dialog be shown // These are permanent connections so we won't bother @@ -42,11 +42,16 @@ FormToc::FormToc(LyXView * lv, Dialogs * d) FormToc::~FormToc() { - free(); delete dialog_; } +void FormToc::clearStore() +{ + toclist.clear(); +} + + void FormToc::build() { dialog_ = build_toc(); diff --git a/src/frontends/xforms/FormToc.h b/src/frontends/xforms/FormToc.h index c115b9f993..6825b212c9 100644 --- a/src/frontends/xforms/FormToc.h +++ b/src/frontends/xforms/FormToc.h @@ -31,23 +31,22 @@ public: ~FormToc(); private: - /**@name Slot Methods */ - //@{ - /// - virtual void update(); - /// Apply from dialog - virtual void apply(); - /// - virtual void input( long ) {}; /// Build the dialog virtual void build(); - /// + /// Not used but must be instantiated + virtual void input( long ) {} + /// Update dialog before showing it + virtual void update(); + /// Apply from dialog (modify or create inset) + virtual void apply(); + /// delete derived class variables from hide() + virtual void clearStore(); + /// Pointer to the actual instantiation of the xform's form virtual FL_FORM * const form() const; /// void updateToc(); /// FD_form_toc * build_toc(); - //@} /// Real GUI implementation. FD_form_toc * dialog_; diff --git a/src/frontends/xforms/FormUrl.C b/src/frontends/xforms/FormUrl.C index 41873282c3..bf640fe656 100644 --- a/src/frontends/xforms/FormUrl.C +++ b/src/frontends/xforms/FormUrl.C @@ -19,20 +19,15 @@ #include "gettext.h" -#include "BufferView.h" #include "Dialogs.h" #include "FormUrl.h" #include "LyXView.h" #include "buffer.h" #include "form_url.h" #include "lyxfunc.h" -#include "xform_macros.h" -#include "insets/insetcommand.h" -#include "insets/inseturl.h" -#include "support/filetools.h" FormUrl::FormUrl(LyXView * lv, Dialogs * d) - : FormCommand(lv, d, _("Url")), dialog_(0) + : FormCommand(lv, d, _("Url")), dialog_(0) { // let the dialog be shown // These are permanent connections so we won't bother @@ -44,7 +39,6 @@ FormUrl::FormUrl(LyXView * lv, Dialogs * d) FormUrl::~FormUrl() { - free(); delete dialog_; } diff --git a/src/frontends/xforms/FormUrl.h b/src/frontends/xforms/FormUrl.h index 6bb5d0ea14..0635409c85 100644 --- a/src/frontends/xforms/FormUrl.h +++ b/src/frontends/xforms/FormUrl.h @@ -32,17 +32,15 @@ public: //@} private: - /**@name Slot Methods */ - //@{ - /// - virtual void update(); - /// Apply from dialog - void apply(); - /// - virtual void input( long ) {}; /// Build the dialog - void build(); - /// + virtual void build(); + /// Not used but must be instantiated + virtual void input( long ) {} + /// Update dialog before showing it + virtual void update(); + /// Apply from dialog (modify or create inset) + virtual void apply(); + /// Pointer to the actual instantiation of the xform's form virtual FL_FORM * const form() const; /// FD_form_url * build_url(); diff --git a/src/frontends/xforms/Makefile.am b/src/frontends/xforms/Makefile.am index 0cca58a829..abcfc97fdf 100644 --- a/src/frontends/xforms/Makefile.am +++ b/src/frontends/xforms/Makefile.am @@ -26,6 +26,10 @@ libxforms_la_SOURCES = \ FormGraphics.h \ form_graphics.C \ form_graphics.h \ + FormIndex.C \ + FormIndex.h \ + form_index.C \ + form_index.h \ FormPreferences.C \ FormPreferences.h \ form_preferences.C \ diff --git a/src/frontends/xforms/form_index.C b/src/frontends/xforms/form_index.C new file mode 100644 index 0000000000..a644864fdd --- /dev/null +++ b/src/frontends/xforms/form_index.C @@ -0,0 +1,40 @@ +// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext +#include +#include "lyx_gui_misc.h" +#include "gettext.h" + +/* Form definition file generated with fdesign. */ + +#include FORMS_H_LOCATION +#include +#include "form_index.h" +#include "FormIndex.h" + +FD_form_index * FormIndex::build_index() +{ + FL_OBJECT *obj; + FD_form_index *fdui = new FD_form_index; + + fdui->form_index = fl_bgn_form(FL_NO_BOX, 520, 100); + fdui->form_index->u_vdata = this; + obj = fl_add_box(FL_UP_BOX, 0, 0, 520, 100, ""); + fdui->key = obj = fl_add_input(FL_NORMAL_INPUT, 90, 10, 420, 30, _("Keyword")); + fl_set_input_shortcut(obj, scex(_("Keyword|#K#k")), 1); + fl_set_object_lsize(obj, FL_NORMAL_SIZE); + fl_set_object_resize(obj, FL_RESIZE_X); + fdui->cancel = obj = fl_add_button(FL_NORMAL_BUTTON, 410, 60, 100, 30, _("Cancel")); + fl_set_button_shortcut(obj, _("^["), 1); + fl_set_object_lsize(obj, FL_NORMAL_SIZE); + fl_set_object_gravity(obj, FL_SouthEast, FL_SouthEast); + fl_set_object_callback(obj, C_FormCommandCancelCB, 0); + fdui->ok = obj = fl_add_button(FL_RETURN_BUTTON, 300, 60, 100, 30, _("OK")); + fl_set_object_gravity(obj, FL_SouthEast, FL_SouthEast); + fl_set_object_callback(obj, C_FormCommandOKCB, 0); + fl_end_form(); + + fdui->form_index->fdui = fdui; + + return fdui; +} +/*---------------------------------------*/ + diff --git a/src/frontends/xforms/form_index.h b/src/frontends/xforms/form_index.h new file mode 100644 index 0000000000..7cec02b7f5 --- /dev/null +++ b/src/frontends/xforms/form_index.h @@ -0,0 +1,20 @@ +/** Header file generated with fdesign on Thu Aug 3 11:33:50 2000.**/ + +#ifndef FD_form_index_h_ +#define FD_form_index_h_ + +/** Callbacks, globals and object handlers **/ +extern "C" void C_FormCommandCancelCB(FL_OBJECT *, long); +extern "C" void C_FormCommandOKCB(FL_OBJECT *, long); + + +/**** Forms and Objects ****/ +struct FD_form_index { + + FL_FORM *form_index; + FL_OBJECT *key; + FL_OBJECT *cancel; + FL_OBJECT *ok; +}; + +#endif /* FD_form_index_h_ */ diff --git a/src/frontends/xforms/forms/form_index.fd b/src/frontends/xforms/forms/form_index.fd new file mode 100644 index 0000000000..996cf87fa5 --- /dev/null +++ b/src/frontends/xforms/forms/form_index.fd @@ -0,0 +1,88 @@ +Magic: 13000 + +Internal Form Definition File + (do not change) + +Number of forms: 1 +Unit of measure: FL_COORD_PIXEL + +=============== FORM =============== +Name: form_index +Width: 520 +Height: 100 +Number of Objects: 4 + +-------------------- +class: FL_BOX +type: UP_BOX +box: 0 0 520 100 +boxtype: FL_UP_BOX +colors: FL_COL1 FL_COL1 +alignment: FL_ALIGN_CENTER +style: FL_NORMAL_STYLE +size: FL_DEFAULT_SIZE +lcol: FL_BLACK +label: +shortcut: +resize: FL_RESIZE_ALL +gravity: FL_NoGravity FL_NoGravity +name: +callback: +argument: + +-------------------- +class: FL_INPUT +type: NORMAL_INPUT +box: 90 10 420 30 +boxtype: FL_DOWN_BOX +colors: FL_COL1 FL_MCOL +alignment: FL_ALIGN_LEFT +style: FL_NORMAL_STYLE +size: FL_NORMAL_SIZE +lcol: FL_BLACK +label: Keyword +shortcut: Keyword|#K#k +resize: FL_RESIZE_X +gravity: FL_NoGravity FL_NoGravity +name: key +callback: +argument: + +-------------------- +class: FL_BUTTON +type: NORMAL_BUTTON +box: 410 60 100 30 +boxtype: FL_UP_BOX +colors: FL_COL1 FL_COL1 +alignment: FL_ALIGN_CENTER +style: FL_NORMAL_STYLE +size: FL_NORMAL_SIZE +lcol: FL_BLACK +label: Cancel +shortcut: ^[ +resize: FL_RESIZE_NONE +gravity: FL_SouthEast FL_SouthEast +name: cancel +callback: C_FormCommandCancelCB +argument: 0 + +-------------------- +class: FL_BUTTON +type: RETURN_BUTTON +box: 300 60 100 30 +boxtype: FL_UP_BOX +colors: FL_COL1 FL_COL1 +alignment: FL_ALIGN_CENTER +style: FL_NORMAL_STYLE +size: FL_DEFAULT_SIZE +lcol: FL_BLACK +label: OK +shortcut: ^M +resize: FL_RESIZE_ALL +gravity: FL_SouthEast FL_SouthEast +name: ok +callback: C_FormCommandOKCB +argument: 0 + +============================== +create_the_forms diff --git a/src/frontends/xforms/forms/makefile b/src/frontends/xforms/forms/makefile index 50b20c6a3e..754e90f0ca 100644 --- a/src/frontends/xforms/forms/makefile +++ b/src/frontends/xforms/forms/makefile @@ -21,6 +21,7 @@ FDESIGN = fdesign SRCS := form_citation.fd \ form_copyright.fd \ + form_index.fd \ form_preferences.fd \ form_print.fd \ form_graphics.fd \ diff --git a/src/insets/insetcite.C b/src/insets/insetcite.C index 51d9658f4b..f0d33a8021 100644 --- a/src/insets/insetcite.C +++ b/src/insets/insetcite.C @@ -21,7 +21,7 @@ #include "support/lstrings.h" InsetCitation::InsetCitation(InsetCommandParams const & p) - : InsetCommand(p) + : InsetCommand(p) {} string InsetCitation::getScreenLabel() const diff --git a/src/insets/insetcite.h b/src/insets/insetcite.h index 7e7676400b..7a766f577d 100644 --- a/src/insets/insetcite.h +++ b/src/insets/insetcite.h @@ -16,13 +16,13 @@ #endif #include "insetcommand.h" +#include "support/utility.hpp" /** Used to insert citations */ -class InsetCitation : public InsetCommand { +class InsetCitation : public InsetCommand, public noncopyable { public: /// - explicit InsetCitation(InsetCommandParams const &); /// Inset * Clone() const { return new InsetCitation(params()); } diff --git a/src/insets/insetindex.C b/src/insets/insetindex.C index c009b38848..c5ebb9b92f 100644 --- a/src/insets/insetindex.C +++ b/src/insets/insetindex.C @@ -1,158 +1,39 @@ #include -#include - #ifdef __GNUG__ #pragma implementation #endif -#include FORMS_H_LOCATION #include "insetindex.h" -#include "buffer.h" -#include "debug.h" +#include "BufferView.h" +#include "LyXView.h" +#include "frontends/Dialogs.h" #include "LaTeXFeatures.h" -#include "gettext.h" -#include "LString.h" -#include "lyx_gui_misc.h" // WarnReadonly - -FD_index_form * index_form = 0; - -extern "C" -void index_cb(FL_OBJECT *, long data) -{ - InsetIndex::Holder * holder = - static_cast - (index_form->index_form->u_vdata); - - holder->inset->callback( index_form, data ); -} - - -static -FD_index_form * create_form_index_form() -{ - FL_OBJECT * obj; - FD_index_form *fdui = (FD_index_form *) fl_calloc(1, sizeof(FD_index_form)); - - fdui->index_form = fl_bgn_form(FL_NO_BOX, 258, 196); - obj = fl_add_box(FL_UP_BOX, 0, 0, 258, 196, ""); - fdui->key = obj = fl_add_input(FL_NORMAL_INPUT, 93, 26, 130, 30, - idex(_("Keyword:|#K"))); - fl_set_object_shortcut(obj, scex(_("Keyword:|#K")), 1); - fl_set_object_lsize(obj, FL_NORMAL_SIZE); - obj = fl_add_button(FL_RETURN_BUTTON, 50, 140, 80, 30, _("OK")); - obj->u_vdata = index_form; - fl_set_object_callback(obj, index_cb, 1); - obj = fl_add_button(FL_NORMAL_BUTTON, 150, 140, 80, 30, - idex(_("Cancel|^["))); - fl_set_object_shortcut(obj, scex(_("Cancel|^[")), 1); - obj->u_vdata = index_form; - fl_set_object_callback(obj, index_cb, 0); - fl_end_form(); - - return fdui; -} - - -/*---------------------------------------*/ - - -InsetIndex::InsetIndex(string const & key) - : InsetCommand("index", key) +InsetIndex::InsetIndex(InsetCommandParams const & p) + : InsetCommand(p) {} -InsetIndex::~InsetIndex() -{ - if(index_form && index_form->index_form - && index_form->index_form->visible - && index_form->index_form->u_vdata == &holder) - fl_hide_form(index_form->index_form); -} - - -void InsetIndex::callback( FD_index_form * form, long data ) -{ - switch (data) - { - case 1: // OK - if(!holder.view->buffer()->isReadonly()) - { - string tmp = fl_get_input(form->key); - if(tmp != getContents()) - { - setContents(tmp); - holder.view->updateInset( this, true ); - } - } // fall through to Cancel - case 0: - fl_hide_form(form->index_form); - break; - } -} - - -void InsetIndex::Edit(BufferView * bv, int, int, unsigned int) -{ - if(bv->buffer()->isReadonly()) - WarnReadonly(bv->buffer()->fileName()); - - if (!index_form) { - index_form = create_form_index_form(); - fl_set_form_atclose(index_form->index_form, - CancelCloseBoxCB, 0); - } - - holder.inset = this; - holder.view = bv; - - index_form->index_form->u_vdata = &holder; - fl_set_input(index_form->key, getContents().c_str()); - if (index_form->index_form->visible) { - fl_raise_form(index_form->index_form); - } else { - fl_show_form(index_form->index_form, - FL_PLACE_MOUSE, FL_FULLBORDER, - _("Index")); - } -} - - string InsetIndex::getScreenLabel() const { return _("Idx"); } -// -// InsetPrintIndex -// - -#if 0 -InsetPrintIndex::InsetPrintIndex() - : InsetCommand("printindex") +void InsetIndex::Edit(BufferView * bv, int, int, unsigned int) { - owner = 0; + bv->owner()->getDialogs()->showIndex( this ); } -#endif -InsetPrintIndex::InsetPrintIndex(Buffer * o) - : InsetCommand("printindex"), owner(o) +InsetPrintIndex::InsetPrintIndex(InsetCommandParams const & p) + : InsetCommand(p) {} - -#if 0 -InsetPrintIndex::~InsetPrintIndex() -{ -} -#endif - - string InsetPrintIndex::getScreenLabel() const { - return _("PrintIndex"); + return _("Index"); } diff --git a/src/insets/insetindex.h b/src/insets/insetindex.h index 50a2e4cf20..b92853804f 100644 --- a/src/insets/insetindex.h +++ b/src/insets/insetindex.h @@ -17,88 +17,45 @@ #endif #include "insetcommand.h" +#include "support/utility.hpp" -class Buffer; struct LaTeXFeatures; -struct FD_index_form; - -// Created by Lgb 970227 - /** Used to insert index labels */ -class InsetIndex : public InsetCommand { +class InsetIndex : public InsetCommand, public noncopyable { public: /// - InsetIndex() : InsetCommand("index") {} - /// - explicit - InsetIndex(string const & key); - /// - ~InsetIndex(); + InsetIndex(InsetCommandParams const &); /// - Inset * Clone() const { return new InsetIndex(getContents());} - /// - void Edit(BufferView *, int, int, unsigned int); - /// - EDITABLE Editable() const - { - return IS_EDITABLE; - } + Inset * Clone() const { return new InsetIndex(params());} /// string getScreenLabel() const; /// - void callback( FD_index_form *, long ); - /// - struct Holder { - InsetIndex * inset; - BufferView * view; - }; - private: + EDITABLE Editable() const { return IS_EDITABLE; } /// - Holder holder; + void Edit(BufferView *, int, int, unsigned int); }; -class InsetPrintIndex : public InsetCommand { +class InsetPrintIndex : public InsetCommand, public noncopyable { public: -#if 0 - /// - InsetPrintIndex(); -#endif /// - InsetPrintIndex(Buffer *); -#if 0 + InsetPrintIndex(InsetCommandParams const &); /// - ~InsetPrintIndex(); -#endif + Inset * Clone() const { return new InsetPrintIndex(params());} /// Updates needed features for this inset. void Validate(LaTeXFeatures & features) const; /// void Edit(BufferView *, int, int, unsigned int) {} /// - EDITABLE Editable() const{ - return IS_EDITABLE; - } - /// WHY is clone missing? (Lgb) + EDITABLE Editable() const{ return NOT_EDITABLE; } /// bool display() const { return true; } /// Inset::Code LyxCode() const; /// string getScreenLabel() const; -private: - /// - Buffer * owner; -}; - -// this was shifted here rather than a separate -// file because its little and only need by -// insetindex.C and lyx_gui_misc.C ARRae 981020 -struct FD_index_form { - FL_FORM * index_form; - FL_OBJECT * key; }; -extern FD_index_form * index_form; #endif diff --git a/src/insets/insettoc.h b/src/insets/insettoc.h index cf0de54519..4c6848c447 100644 --- a/src/insets/insettoc.h +++ b/src/insets/insettoc.h @@ -17,10 +17,11 @@ #endif #include "insetcommand.h" +#include "support/utility.hpp" /** Used to insert table of contents */ -class InsetTOC : public InsetCommand { +class InsetTOC : public InsetCommand, public noncopyable { public: /// InsetTOC(InsetCommandParams const & p) : InsetCommand(p) {} diff --git a/src/insets/inseturl.h b/src/insets/inseturl.h index 30a7b2c49b..6170b545df 100644 --- a/src/insets/inseturl.h +++ b/src/insets/inseturl.h @@ -16,12 +16,13 @@ #endif #include "insetcommand.h" +#include "support/utility.hpp" struct LaTeXFeatures; /** The url inset */ -class InsetUrl : public InsetCommand { +class InsetUrl : public InsetCommand, public noncopyable { public: /// explicit diff --git a/src/lyx_gui_misc.C b/src/lyx_gui_misc.C index fd6cfd2119..7954c72221 100644 --- a/src/lyx_gui_misc.C +++ b/src/lyx_gui_misc.C @@ -33,7 +33,6 @@ #include "minibuffer.h" #include "print_form.h" #include "sp_form.h" -#include "insets/insetindex.h" #include "LyXView.h" #include "bufferview_funcs.h" #include "support/filetools.h" @@ -66,7 +65,6 @@ extern FD_space * fd_space; extern FD_matrix * fd_matrix; extern FD_bibitem_form * bibitem_form; extern FD_include * form; -extern FD_index_form * index_form; extern void HideFiguresPopups(); @@ -178,11 +176,6 @@ void CloseAllBufferRelatedDialogs() fl_hide_form(form->include); } } - if (index_form) { - if (index_form->index_form->visible) { - fl_hide_form(index_form->index_form); - } - } HideFiguresPopups(); } @@ -321,11 +314,6 @@ void updateAllVisibleBufferRelatedDialogs() fl_hide_form(form->include); } } - if (index_form) { - if (index_form->index_form->visible) { - fl_hide_form(index_form->index_form); - } - } HideFiguresPopups(); } diff --git a/src/lyxfunc.C b/src/lyxfunc.C index 34112ce3b5..d01236b739 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -2538,11 +2538,10 @@ string LyXFunc::Dispatch(int ac, } break; - case LFUN_CREATE_CITATION: + case LFUN_CITATION_CREATE: { // Should do this "at source" - InsetCommandParams p; - p.setCmdName( "cite" ); + InsetCommandParams p( "cite" ); if (contains(argument, "|")) { p.setContents( token(argument, '|', 0) ); @@ -2555,7 +2554,7 @@ string LyXFunc::Dispatch(int ac, } break; - case LFUN_INSERT_CITATION: + case LFUN_CITATION_INSERT: { InsetCommandParams p; p.setFromString( argument ); @@ -2621,21 +2620,18 @@ string LyXFunc::Dispatch(int ac, } break; - case LFUN_INDEX_INSERT: - case LFUN_INDEX_INSERT_LAST: + case LFUN_INDEX_CREATE: + case LFUN_INDEX_CREATE_LAST: { // Can't do that at the beginning of a paragraph. if (owner->view()->text->cursor.pos() - 1 < 0) break; - InsetIndex * new_inset = new InsetIndex(); + InsetCommandParams p( "index" ); + if (!argument.empty()) { - string lsarg(argument); - new_inset->setContents(lsarg); - if (!owner->view()->insertInset(new_inset)) - delete new_inset; + p.setContents( argument ); } else { - //reh 98/09/21 //get the current word for an argument LyXParagraph::size_type lastpos = owner->view()->text->cursor.pos() - 1; @@ -2646,36 +2642,32 @@ string LyXFunc::Dispatch(int ac, ->text->cursor.par()->GetWord(lastpos)); //make the new inset and write the current word into it - InsetIndex * new_inset = new InsetIndex(); - - new_inset->setContents(curstring); - - //don't edit it if the call was to INSERT_LAST - if(action != LFUN_INDEX_INSERT_LAST) { - new_inset->Edit(owner->view(), 0, 0, 0); - } else { - //it looks blank on the screen unless - //we do something. put it here. - - // move the cursor to the returned value of lastpos - // but only for the auto-insert - owner->view()->text->cursor.pos(lastpos); - } - - //put the new inset into the buffer. - // there should be some way of knowing the user - //cancelled & avoiding this, but i don't know how - if (!owner->view()->insertInset(new_inset)) - delete new_inset; + p.setContents( curstring ); } + + owner->getDialogs()->createIndex( p.getAsString() ); } break; + + case LFUN_INDEX_INSERT: + { + InsetCommandParams p; + p.setFromString( argument ); + InsetIndex * inset = new InsetIndex( p ); + if (!owner->view()->insertInset(inset)) + delete inset; + else + owner->view()->updateInset( inset, true ); + } + break; + case LFUN_INDEX_PRINT: { - Inset * new_inset = new InsetPrintIndex(owner->buffer()); - if (!owner->view()->insertInset(new_inset, "Standard", true)) - delete new_inset; + InsetCommandParams p("printindex"); + Inset * inset = new InsetPrintIndex(p); + if (!owner->view()->insertInset(inset, "Standard", true)) + delete inset; } break; diff --git a/src/mathed/math_write.C b/src/mathed/math_write.C index bd5bff0659..425f015299 100644 --- a/src/mathed/math_write.C +++ b/src/mathed/math_write.C @@ -99,6 +99,12 @@ void MathDelimInset::Write(ostream & os, bool fragile) void MathDecorationInset::Write(ostream & os, bool fragile) { latexkeys * l = lm_get_key_by_id(deco, LM_TK_WIDE); + if (fragile && + (strcmp(l->name, "overbrace") == 0 || + strcmp(l->name, "underbrace") == 0 || + strcmp(l->name, "overleftarrow") == 0 || + strcmp(l->name, "overrightarrow") == 0)) + os << "\\protect"; os << '\\' << l->name << '{'; MathParInset::Write(os, fragile); os << '}'; diff --git a/src/menus.C b/src/menus.C index d1b091df93..aacb3f007c 100644 --- a/src/menus.C +++ b/src/menus.C @@ -1899,9 +1899,9 @@ void Menus::ShowInsertMenu(FL_OBJECT * ob, long) case 12: tmpfunc->Dispatch(LFUN_INSERT_NOTE); break; case 13: tmpfunc->Dispatch(LFUN_INSERT_LABEL); break; case 14: tmpfunc->Dispatch(LFUN_INSERT_REF); break; - case 15: tmpfunc->Dispatch(LFUN_CREATE_CITATION); break; - case 16: tmpfunc->Dispatch(LFUN_INDEX_INSERT); break; - case 17: tmpfunc->Dispatch(LFUN_INDEX_INSERT_LAST); break; + case 15: tmpfunc->Dispatch(LFUN_CITATION_CREATE); break; + case 16: tmpfunc->Dispatch(LFUN_INDEX_CREATE); break; + case 17: tmpfunc->Dispatch(LFUN_INDEX_CREATE_LAST); break; case 18: tmpfunc->Dispatch(LFUN_URL); break; } }