9 #include FORMS_H_LOCATION
10 #include "insetindex.h"
13 #include "LaTeXFeatures.h"
16 #include "lyx_gui_misc.h" // WarnReadonly()
18 extern BufferView *current_view;
19 extern void UpdateInset(Inset* inset, bool mark_dirty = true);
21 FD_index_form *index_form = 0;
24 void index_cb(FL_OBJECT *, long data)
26 InsetIndex *inset = (InsetIndex*)index_form->vdata;
29 // - case 0: fl_hide_form(index_form->index_form); break;
32 // - inset->setContents(fl_get_input(index_form->key));
33 // - fl_hide_form(index_form->index_form);
34 // - UpdateInset(inset);
38 if(!current_view->currentBuffer()->isReadonly()) {
39 string tmp = fl_get_input(index_form->key);
40 if(tmp != inset->getContents()) {
41 inset->setContents(tmp);
42 fl_hide_form(index_form->index_form);
46 } // fall through to Cancel on RO
48 fl_hide_form(index_form->index_form); break;
54 FD_index_form *create_form_index_form()
57 FD_index_form *fdui = (FD_index_form *) fl_calloc(1, sizeof(FD_index_form));
59 fdui->index_form = fl_bgn_form(FL_NO_BOX, 258, 196);
60 obj = fl_add_box(FL_UP_BOX,0,0,258,196,"");
61 fdui->key = obj = fl_add_input(FL_NORMAL_INPUT,93,26,130,30,
62 idex(_("Keyword:|#K")));
63 fl_set_object_shortcut(obj,scex(_("Keyword:|#K")),1);
64 fl_set_object_lsize(obj,FL_NORMAL_SIZE);
65 obj = fl_add_button(FL_RETURN_BUTTON,50,140,80,30,_("OK"));
66 obj->u_vdata = index_form;
67 fl_set_object_callback(obj,index_cb,1);
68 obj = fl_add_button(FL_NORMAL_BUTTON,150,140,80,30,
69 idex(_("Cancel|^[")));
70 fl_set_object_shortcut(obj,scex(_("Cancel|^[")),1);
71 obj->u_vdata = index_form;
72 fl_set_object_callback(obj,index_cb,0);
80 /*---------------------------------------*/
83 InsetIndex::InsetIndex(string const & key)
84 : InsetCommand("index", key)
89 InsetIndex::~InsetIndex()
91 if(index_form && index_form->index_form
92 && index_form->index_form->visible
93 && index_form->vdata == this)
94 fl_hide_form(index_form->index_form);
98 void InsetIndex::Edit(int, int)
100 if(current_view->currentBuffer()->isReadonly())
104 index_form = create_form_index_form();
106 index_form->vdata = this;
107 fl_set_input(index_form->key, getContents().c_str());
108 if (index_form->index_form->visible) {
109 fl_raise_form(index_form->index_form);
111 fl_show_form(index_form->index_form,
112 FL_PLACE_MOUSE, FL_FULLBORDER,
118 string InsetIndex::getScreenLabel() const
128 InsetPrintIndex::InsetPrintIndex()
129 : InsetCommand("printindex")
135 InsetPrintIndex::InsetPrintIndex(Buffer *o)
136 : InsetCommand("printindex"), owner(o)
141 InsetPrintIndex::~InsetPrintIndex()
146 string InsetPrintIndex::getScreenLabel() const
148 return _("PrintIndex");
152 void InsetPrintIndex::Validate(LaTeXFeatures &features) const
154 features.makeidx = true;
158 Inset::Code InsetPrintIndex::LyxCode() const
160 return Inset::INDEX_CODE;