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), minh(0), minw(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();
51 // XFORMS bug workaround
52 // Define the min/max dimensions. Actually applied in update()
53 minw = form()->w; minh = form()->h;
57 FL_FORM * const FormIndex::form() const
59 if( dialog_ ) // no need to test for dialog_->form_index
60 return dialog_->form_index;
66 void FormIndex::update()
68 fl_set_form_minsize(form(), minw, minh);
69 fl_set_form_maxsize(form(), 2*minw, minh);
71 fl_set_input(dialog_->key, params.getContents().c_str());
73 if( lv_->buffer()->isReadonly() ) {
74 fl_deactivate_object( dialog_->key );
75 fl_deactivate_object( dialog_->ok );
76 fl_set_object_lcol( dialog_->ok, FL_INACTIVE );
78 fl_activate_object( dialog_->key );
79 fl_activate_object( dialog_->ok );
80 fl_set_object_lcol( dialog_->ok, FL_BLACK );
85 void FormIndex::apply()
87 if( lv_->buffer()->isReadonly() ) return;
89 params.setContents( fl_get_input(dialog_->key) );
93 // Only update if contents have changed
94 if( params != inset_->params() ) {
95 inset_->setParams( params );
96 lv_->view()->updateInset( inset_, true );
99 lv_->getLyXFunc()->Dispatch( LFUN_INDEX_INSERT,
100 params.getAsString().c_str() );