2 /* This file is part of
3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright 2000 The LyX Team.
9 * ======================================================
14 #include FORMS_H_LOCATION
17 #pragma implementation
22 #include "FormIndex.h"
25 #include "form_index.h"
28 FormIndex::FormIndex(LyXView * lv, Dialogs * d)
29 : FormCommand(lv, d, _("Index"))
31 // let the dialog be shown
32 // These are permanent connections so we won't bother
33 // storing a copy because we won't be disconnecting.
34 d->showIndex.connect(slot(this, &FormIndex::showInset));
35 d->createIndex.connect(slot(this, &FormIndex::createInset));
39 FL_FORM * FormIndex::form() const
41 if (dialog_.get()) return dialog_->form;
46 void FormIndex::connect()
48 fl_set_form_maxsize(form(), 2 * minw_, minh_);
49 FormCommand::connect();
53 void FormIndex::build()
55 dialog_.reset(build_index());
57 // Workaround dumb xforms sizing bug
61 fl_set_input_return(dialog_->input_key, FL_RETURN_CHANGED);
63 // Manage the ok, apply, restore and cancel/close buttons
64 bc().setOK(dialog_->button_ok);
65 bc().setApply(dialog_->button_apply);
66 bc().setCancel(dialog_->button_cancel);
67 bc().setUndoAll(dialog_->button_restore);
70 bc().addReadOnly(dialog_->input_key);
74 void FormIndex::update()
76 fl_set_input(dialog_->input_key, params.getContents().c_str());
77 // Surely, this should reset the buttons to their original state?
78 // It doesn't. Instead "Restore" becomes a "Close"
80 bc().readOnly(lv_->buffer()->isReadonly());
84 void FormIndex::apply()
86 if (lv_->buffer()->isReadonly()) return;
88 params.setContents(fl_get_input(dialog_->input_key));
91 // Only update if contents have changed
92 if (params != inset_->params()) {
93 inset_->setParams(params);
94 lv_->view()->updateInset(inset_, true);
97 lv_->getLyXFunc()->Dispatch(LFUN_INDEX_INSERT,
98 params.getAsString());