1999-09-27 18:44:28 +00:00
|
|
|
#include <config.h>
|
|
|
|
|
1999-11-04 01:40:20 +00:00
|
|
|
#include <cstdlib>
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma implementation
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include FORMS_H_LOCATION
|
|
|
|
#include "insetindex.h"
|
|
|
|
#include "buffer.h"
|
1999-10-07 18:44:17 +00:00
|
|
|
#include "debug.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
#include "LaTeXFeatures.h"
|
|
|
|
#include "gettext.h"
|
|
|
|
#include "LString.h"
|
1999-12-21 06:10:21 +00:00
|
|
|
#include "lyx_gui_misc.h" // WarnReadonly
|
1999-09-27 18:44:28 +00:00
|
|
|
|
1999-11-04 01:40:20 +00:00
|
|
|
FD_index_form * index_form = 0;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2000-07-15 23:51:46 +00:00
|
|
|
extern "C"
|
|
|
|
void index_cb(FL_OBJECT *, long data)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2000-07-07 07:46:37 +00:00
|
|
|
InsetIndex::Holder * holder =
|
|
|
|
static_cast<InsetIndex::Holder*>
|
|
|
|
(index_form->index_form->u_vdata);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2000-07-07 07:46:37 +00:00
|
|
|
holder->inset->callback( index_form, data );
|
|
|
|
}
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
static
|
1999-11-04 01:40:20 +00:00
|
|
|
FD_index_form * create_form_index_form()
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
1999-11-04 01:40:20 +00:00
|
|
|
FL_OBJECT * obj;
|
1999-09-27 18:44:28 +00:00
|
|
|
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);
|
1999-11-15 10:58:38 +00:00
|
|
|
obj = fl_add_box(FL_UP_BOX, 0, 0, 258, 196, "");
|
|
|
|
fdui->key = obj = fl_add_input(FL_NORMAL_INPUT, 93, 26, 130, 30,
|
1999-09-27 18:44:28 +00:00
|
|
|
idex(_("Keyword:|#K")));
|
1999-11-15 10:58:38 +00:00
|
|
|
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"));
|
1999-09-27 18:44:28 +00:00
|
|
|
obj->u_vdata = index_form;
|
1999-11-15 10:58:38 +00:00
|
|
|
fl_set_object_callback(obj, index_cb, 1);
|
|
|
|
obj = fl_add_button(FL_NORMAL_BUTTON, 150, 140, 80, 30,
|
1999-09-27 18:44:28 +00:00
|
|
|
idex(_("Cancel|^[")));
|
1999-11-15 10:58:38 +00:00
|
|
|
fl_set_object_shortcut(obj, scex(_("Cancel|^[")), 1);
|
1999-09-27 18:44:28 +00:00
|
|
|
obj->u_vdata = index_form;
|
1999-11-15 10:58:38 +00:00
|
|
|
fl_set_object_callback(obj, index_cb, 0);
|
1999-09-27 18:44:28 +00:00
|
|
|
fl_end_form();
|
|
|
|
|
|
|
|
return fdui;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*---------------------------------------*/
|
|
|
|
|
|
|
|
|
1999-10-02 16:21:10 +00:00
|
|
|
InsetIndex::InsetIndex(string const & key)
|
1999-09-27 18:44:28 +00:00
|
|
|
: InsetCommand("index", key)
|
2000-07-15 23:51:46 +00:00
|
|
|
{}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
InsetIndex::~InsetIndex()
|
|
|
|
{
|
|
|
|
if(index_form && index_form->index_form
|
|
|
|
&& index_form->index_form->visible
|
2000-07-07 07:46:37 +00:00
|
|
|
&& index_form->index_form->u_vdata == &holder)
|
1999-09-27 18:44:28 +00:00
|
|
|
fl_hide_form(index_form->index_form);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-07-07 07:46:37 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-02-25 12:06:15 +00:00
|
|
|
void InsetIndex::Edit(BufferView * bv, int, int, unsigned int)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2000-02-22 00:36:17 +00:00
|
|
|
if(bv->buffer()->isReadonly())
|
|
|
|
WarnReadonly(bv->buffer()->fileName());
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2000-06-28 14:55:57 +00:00
|
|
|
if (!index_form) {
|
1999-09-27 18:44:28 +00:00
|
|
|
index_form = create_form_index_form();
|
2000-07-15 23:51:46 +00:00
|
|
|
fl_set_form_atclose(index_form->index_form,
|
|
|
|
CancelCloseBoxCB, 0);
|
2000-06-28 14:55:57 +00:00
|
|
|
}
|
|
|
|
|
2000-07-07 07:46:37 +00:00
|
|
|
holder.inset = this;
|
|
|
|
holder.view = bv;
|
|
|
|
|
|
|
|
index_form->index_form->u_vdata = &holder;
|
1999-09-27 18:44:28 +00:00
|
|
|
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"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-10-02 16:21:10 +00:00
|
|
|
string InsetIndex::getScreenLabel() const
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
return _("Idx");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// InsetPrintIndex
|
|
|
|
//
|
|
|
|
|
2000-07-15 23:51:46 +00:00
|
|
|
#if 0
|
1999-09-27 18:44:28 +00:00
|
|
|
InsetPrintIndex::InsetPrintIndex()
|
|
|
|
: InsetCommand("printindex")
|
|
|
|
{
|
1999-10-02 16:21:10 +00:00
|
|
|
owner = 0;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
2000-07-15 23:51:46 +00:00
|
|
|
#endif
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
1999-11-04 01:40:20 +00:00
|
|
|
InsetPrintIndex::InsetPrintIndex(Buffer * o)
|
1999-09-27 18:44:28 +00:00
|
|
|
: InsetCommand("printindex"), owner(o)
|
2000-07-15 23:51:46 +00:00
|
|
|
{}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
2000-07-15 23:51:46 +00:00
|
|
|
#if 0
|
1999-09-27 18:44:28 +00:00
|
|
|
InsetPrintIndex::~InsetPrintIndex()
|
|
|
|
{
|
|
|
|
}
|
2000-07-15 23:51:46 +00:00
|
|
|
#endif
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
1999-10-02 16:21:10 +00:00
|
|
|
string InsetPrintIndex::getScreenLabel() const
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
return _("PrintIndex");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-11-04 01:40:20 +00:00
|
|
|
void InsetPrintIndex::Validate(LaTeXFeatures & features) const
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
features.makeidx = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Inset::Code InsetPrintIndex::LyxCode() const
|
|
|
|
{
|
|
|
|
return Inset::INDEX_CODE;
|
|
|
|
}
|