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
23 #include "FormIndex.h"
26 #include "form_index.h"
29 FormIndex::FormIndex(LyXView * lv, Dialogs * d)
30 : FormCommand(lv, d, _("Index")), dialog_(0)
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()
47 void FormIndex::build()
49 dialog_ = build_index();
53 FL_FORM * const FormIndex::form() const
55 if( dialog_ && dialog_->form_index )
56 return dialog_->form_index;
62 void FormIndex::update()
64 static int ow = -1, oh;
67 ow = dialog_->form_index->w;
68 oh = dialog_->form_index->h;
70 fl_set_form_minsize(dialog_->form_index, ow, oh);
71 fl_set_form_maxsize(dialog_->form_index, 2*ow, oh);
74 fl_freeze_form( dialog_->form_index );
76 fl_set_input(dialog_->key, params.getContents().c_str());
78 if( lv_->buffer()->isReadonly() ) {
79 fl_deactivate_object( dialog_->key );
80 fl_deactivate_object( dialog_->ok );
81 fl_set_object_lcol( dialog_->ok, FL_INACTIVE );
83 fl_activate_object( dialog_->key );
84 fl_activate_object( dialog_->ok );
85 fl_set_object_lcol( dialog_->ok, FL_BLACK );
88 fl_unfreeze_form( dialog_->form_index );
92 void FormIndex::apply()
94 if( lv_->buffer()->isReadonly() ) return;
96 params.setContents( fl_get_input(dialog_->key) );
100 // Only update if contents have changed
101 if( params.getContents() != inset_->getContents() ) {
102 inset_->setParams( params );
103 lv_->view()->updateInset( inset_, true );
106 lv_->getLyXFunc()->Dispatch( LFUN_INDEX_INSERT,
107 params.getAsString().c_str() );