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"), new NoRepeatedApplyPolicy),
32 // let the dialog be shown
33 // These are permanent connections so we won't bother
34 // storing a copy because we won't be disconnecting.
35 d->showIndex.connect(slot(this, &FormIndex::showInset));
36 d->createIndex.connect(slot(this, &FormIndex::createInset));
40 FormIndex::~FormIndex()
46 FL_FORM * FormIndex::form() const
48 if (dialog_) return dialog_->form;
53 void FormIndex::connect()
55 fl_set_form_maxsize(form(), 2 * minw_, minh_);
56 FormCommand::connect();
60 void FormIndex::build()
62 dialog_ = build_index();
64 // Workaround dumb xforms sizing bug
68 fl_set_input_return(dialog_->input_key, FL_RETURN_CHANGED);
70 // Manage the ok, apply, restore and cancel/close buttons
71 bc_.setOK(dialog_->button_ok);
72 bc_.setApply(dialog_->button_apply);
73 bc_.setCancel(dialog_->button_cancel);
74 bc_.setUndoAll(dialog_->button_restore);
77 bc_.addReadOnly(dialog_->input_key);
81 void FormIndex::update()
83 fl_set_input(dialog_->input_key, params.getContents().c_str());
84 // Surely, this should reset the buttons to their original state?
85 // It doesn't. Instead "Restore" becomes a "Close"
87 bc_.readOnly(lv_->buffer()->isReadonly());
91 void FormIndex::apply()
93 if (lv_->buffer()->isReadonly()) return;
95 params.setContents(fl_get_input(dialog_->input_key));
98 // Only update if contents have changed
99 if (params != inset_->params()) {
100 inset_->setParams(params);
101 lv_->view()->updateInset(inset_, true);
104 lv_->getLyXFunc()->Dispatch(LFUN_INDEX_INSERT,
105 params.getAsString());