X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2Finsetindex.C;h=03e844d5d5021a270962d923aea1780bfa19b1aa;hb=3c8aba3b556871fb1100a2f98cd93d5d4e3f70c9;hp=5344ec2b3a739604fb310d4eab90d187711ecc21;hpb=27de1486ca34aaad446adb798d71a77d6f6304da;p=lyx.git diff --git a/src/insets/insetindex.C b/src/insets/insetindex.C index 5344ec2b3a..03e844d5d5 100644 --- a/src/insets/insetindex.C +++ b/src/insets/insetindex.C @@ -1,6 +1,6 @@ #include -#include +#include #ifdef __GNUG__ #pragma implementation @@ -9,38 +9,28 @@ #include FORMS_H_LOCATION #include "insetindex.h" #include "buffer.h" -#include "error.h" +#include "debug.h" #include "LaTeXFeatures.h" #include "gettext.h" #include "LString.h" -#include "lyx_gui_misc.h" // WarnReadonly() +#include "lyx_gui_misc.h" // WarnReadonly -extern BufferView *current_view; -extern void UpdateInset(Inset* inset, bool mark_dirty = true); +extern BufferView * current_view; -FD_index_form *index_form = 0; +FD_index_form * index_form = 0; -static -void index_cb(FL_OBJECT *, long data) +extern "C" void index_cb(FL_OBJECT *, long data) { - InsetIndex *inset = (InsetIndex*)index_form->vdata; + InsetIndex * inset = static_cast(index_form->index_form->u_vdata); switch (data) { -// - case 0: fl_hide_form(index_form->index_form); break; -// - case 1: -// - { -// - inset->setContents(fl_get_input(index_form->key)); -// - fl_hide_form(index_form->index_form); -// - UpdateInset(inset); -// - break; -// - } case 1: // OK - if(!current_view->currentBuffer()->isReadonly()) { - LString tmp = fl_get_input(index_form->key); + if(!current_view->buffer()->isReadonly()) { + string tmp = fl_get_input(index_form->key); if(tmp != inset->getContents()) { inset->setContents(tmp); fl_hide_form(index_form->index_form); - UpdateInset(inset); + current_view->updateInset(inset, true); break; } } // fall through to Cancel on RO @@ -51,25 +41,25 @@ void index_cb(FL_OBJECT *, long data) static -FD_index_form *create_form_index_form() +FD_index_form * create_form_index_form() { - FL_OBJECT *obj; + 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, + 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")); + 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, + 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); + fl_set_object_shortcut(obj, scex(_("Cancel|^[")), 1); obj->u_vdata = index_form; - fl_set_object_callback(obj,index_cb,0); + fl_set_object_callback(obj, index_cb, 0); fl_end_form(); return fdui; @@ -80,7 +70,7 @@ FD_index_form *create_form_index_form() /*---------------------------------------*/ -InsetIndex::InsetIndex(LString const & key) +InsetIndex::InsetIndex(string const & key) : InsetCommand("index", key) { } @@ -90,20 +80,20 @@ InsetIndex::~InsetIndex() { if(index_form && index_form->index_form && index_form->index_form->visible - && index_form->vdata == this) + && index_form->index_form->u_vdata == this) fl_hide_form(index_form->index_form); } -void InsetIndex::Edit(int, int) +void InsetIndex::Edit(BufferView * bv, int, int, unsigned int) { - if(current_view->currentBuffer()->isReadonly()) - WarnReadonly(); + if(bv->buffer()->isReadonly()) + WarnReadonly(bv->buffer()->fileName()); if (!index_form) index_form = create_form_index_form(); - index_form->vdata = this; + index_form->index_form->u_vdata = this; fl_set_input(index_form->key, getContents().c_str()); if (index_form->index_form->visible) { fl_raise_form(index_form->index_form); @@ -115,7 +105,7 @@ void InsetIndex::Edit(int, int) } -LString InsetIndex::getScreenLabel() const +string InsetIndex::getScreenLabel() const { return _("Idx"); } @@ -128,11 +118,11 @@ LString InsetIndex::getScreenLabel() const InsetPrintIndex::InsetPrintIndex() : InsetCommand("printindex") { - owner = NULL; + owner = 0; } -InsetPrintIndex::InsetPrintIndex(Buffer *o) +InsetPrintIndex::InsetPrintIndex(Buffer * o) : InsetCommand("printindex"), owner(o) { } @@ -143,13 +133,13 @@ InsetPrintIndex::~InsetPrintIndex() } -LString InsetPrintIndex::getScreenLabel() const +string InsetPrintIndex::getScreenLabel() const { return _("PrintIndex"); } -void InsetPrintIndex::Validate(LaTeXFeatures &features) const +void InsetPrintIndex::Validate(LaTeXFeatures & features) const { features.makeidx = true; }