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")), minh(0), minw(0), 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()
46 void FormIndex::build()
48 dialog_ = build_index();
50 // XFORMS bug workaround
51 // Define the min/max dimensions. Actually applied in update()
52 minw = form()->w; minh = form()->h;
56 FL_FORM * const FormIndex::form() const
58 if( dialog_ ) // no need to test for dialog_->form
65 void FormIndex::update()
67 fl_set_form_minsize(form(), minw, minh);
68 fl_set_form_maxsize(form(), 2*minw, minh);
70 fl_set_input(dialog_->key, params.getContents().c_str());
72 if( lv_->buffer()->isReadonly() ) {
73 fl_deactivate_object( dialog_->key );
74 fl_deactivate_object( dialog_->ok );
75 fl_set_object_lcol( dialog_->ok, FL_INACTIVE );
77 fl_activate_object( dialog_->key );
78 fl_activate_object( dialog_->ok );
79 fl_set_object_lcol( dialog_->ok, FL_BLACK );
84 void FormIndex::apply()
86 if( lv_->buffer()->isReadonly() ) return;
88 params.setContents( fl_get_input(dialog_->key) );
92 // Only update if contents have changed
93 if( params != inset_->params() ) {
94 inset_->setParams( params );
95 lv_->view()->updateInset( inset_, true );
98 lv_->getLyXFunc()->Dispatch( LFUN_INDEX_INSERT,
99 params.getAsString().c_str() );