X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2Finsetindex.C;h=c175cf1ffd14cb5e05d7aafff22049ef7542ac57;hb=e28331ed63062dea10d0a21b9ec12034b4b17b9a;hp=7e617a84afe045e815cf1999e59a93a29cc86029;hpb=89885b5fa1d24ee5275b4744ed3344bccf51df04;p=lyx.git diff --git a/src/insets/insetindex.C b/src/insets/insetindex.C index 7e617a84af..c175cf1ffd 100644 --- a/src/insets/insetindex.C +++ b/src/insets/insetindex.C @@ -1,164 +1,91 @@ +/** + * \file insetindex.C + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. + * + * \author Lars Gullik Bjønnes + * + * Full author contact details are available in file CREDITS. + */ #include -#include - -#ifdef __GNUG__ -#pragma implementation -#endif - -#include FORMS_H_LOCATION #include "insetindex.h" -#include "buffer.h" -#include "debug.h" -#include "LaTeXFeatures.h" + +#include "dispatchresult.h" +#include "funcrequest.h" #include "gettext.h" -#include "LString.h" -#include "lyx_gui_misc.h" // WarnReadonly - -FD_index_form * index_form = 0; +#include "LaTeXFeatures.h" +#include "metricsinfo.h" +#include "sgml.h" -extern "C" void index_cb(FL_OBJECT *, long data) -{ - InsetIndex::Holder * holder = - static_cast - (index_form->index_form->u_vdata); +#include "support/std_ostream.h" - 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; -} +namespace lyx { +using std::string; +using std::ostream; -/*---------------------------------------*/ +InsetIndex::InsetIndex(InsetCommandParams const & p) + : InsetCommand(p, "index") +{} -InsetIndex::InsetIndex(string const & key) - : InsetCommand("index", key) -{ -} +// InsetIndex::InsetIndex(InsetCommandParams const & p, bool) +// : InsetCommand(p, false) +// {} -InsetIndex::~InsetIndex() +docstring const InsetIndex::getScreenLabel(Buffer const &) const { - 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; - } + return _("Idx"); } -void InsetIndex::Edit(BufferView * bv, int, int, unsigned int) +int InsetIndex::docbook(Buffer const &, odocstream & os, + OutputParams const &) const { - 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")); - } + os << "" + << sgml::escapeString(getParam("name")) + << ""; + return 0; } -string InsetIndex::getScreenLabel() const +InsetBase::Code InsetIndex::lyxCode() const { - return _("Idx"); + return InsetBase::INDEX_CODE; } -// -// InsetPrintIndex -// -InsetPrintIndex::InsetPrintIndex() - : InsetCommand("printindex") -{ - owner = 0; -} +InsetPrintIndex::InsetPrintIndex(InsetCommandParams const & p) + : InsetCommand(p, string()) +{} -InsetPrintIndex::InsetPrintIndex(Buffer * o) - : InsetCommand("printindex"), owner(o) -{ -} +// InsetPrintIndex::InsetPrintIndex(InsetCommandParams const & p, bool) +// : InsetCommand(p, false) +// {} -InsetPrintIndex::~InsetPrintIndex() +docstring const InsetPrintIndex::getScreenLabel(Buffer const &) const { + return _("Index"); } -string InsetPrintIndex::getScreenLabel() const +void InsetPrintIndex::validate(LaTeXFeatures & features) const { - return _("PrintIndex"); + features.require("makeidx"); } -void InsetPrintIndex::Validate(LaTeXFeatures & features) const +InsetBase::Code InsetPrintIndex::lyxCode() const { - features.makeidx = true; + return InsetBase::INDEX_PRINT_CODE; } -Inset::Code InsetPrintIndex::LyxCode() const -{ - return Inset::INDEX_CODE; -} +} // namespace lyx