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")), dialog_(0)
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 FormIndex::~FormIndex()
45 FL_FORM * FormIndex::form() const
47 if (dialog_ ) return dialog_->form;
52 void FormIndex::connect()
54 fl_set_form_maxsize( form(), 2*minw_, minh_ );
55 FormCommand::connect();
59 void FormIndex::build()
61 dialog_ = build_index();
64 #warning use the buttoncontroller
66 // Workaround dumb xforms sizing bug
72 void FormIndex::update()
74 fl_set_input(dialog_->key, params.getContents().c_str());
76 if (lv_->buffer()->isReadonly()) {
77 fl_deactivate_object( dialog_->key );
78 fl_deactivate_object( dialog_->ok );
79 fl_set_object_lcol( dialog_->ok, FL_INACTIVE );
81 fl_activate_object( dialog_->key );
82 fl_activate_object( dialog_->ok );
83 fl_set_object_lcol( dialog_->ok, FL_BLACK );
88 void FormIndex::apply()
90 if (lv_->buffer()->isReadonly()) return;
92 params.setContents(fl_get_input(dialog_->key));
95 // Only update if contents have changed
96 if (params != inset_->params()) {
97 inset_->setParams(params);
98 lv_->view()->updateInset(inset_, true);
101 lv_->getLyXFunc()->Dispatch(LFUN_INDEX_INSERT,
102 params.getAsString());