2000-08-03 12:56:25 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/* This file is part of
|
|
|
|
* ======================================================
|
|
|
|
*
|
|
|
|
* LyX, The Document Processor
|
|
|
|
*
|
|
|
|
* Copyright 2000 The LyX Team.
|
|
|
|
*
|
|
|
|
* ======================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#include FORMS_H_LOCATION
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma implementation
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#include "Dialogs.h"
|
|
|
|
#include "FormIndex.h"
|
|
|
|
#include "LyXView.h"
|
|
|
|
#include "buffer.h"
|
|
|
|
#include "form_index.h"
|
|
|
|
#include "lyxfunc.h"
|
|
|
|
|
|
|
|
FormIndex::FormIndex(LyXView * lv, Dialogs * d)
|
2000-08-14 05:24:35 +00:00
|
|
|
: FormCommand(lv, d, _("Index")), minh(0), minw(0), dialog_(0)
|
2000-08-03 12:56:25 +00:00
|
|
|
{
|
|
|
|
// let the dialog be shown
|
|
|
|
// These are permanent connections so we won't bother
|
|
|
|
// storing a copy because we won't be disconnecting.
|
|
|
|
d->showIndex.connect(slot(this, &FormIndex::showInset));
|
|
|
|
d->createIndex.connect(slot(this, &FormIndex::createInset));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
FormIndex::~FormIndex()
|
|
|
|
{
|
|
|
|
delete dialog_;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FormIndex::build()
|
|
|
|
{
|
|
|
|
dialog_ = build_index();
|
2000-08-04 13:12:30 +00:00
|
|
|
|
2000-08-08 13:55:26 +00:00
|
|
|
// XFORMS bug workaround
|
|
|
|
// Define the min/max dimensions. Actually applied in update()
|
|
|
|
minw = form()->w; minh = form()->h;
|
2000-08-03 12:56:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
FL_FORM * const FormIndex::form() const
|
|
|
|
{
|
2000-08-14 05:24:35 +00:00
|
|
|
if( dialog_ ) // no need to test for dialog_->form
|
|
|
|
return dialog_->form;
|
2000-08-03 12:56:25 +00:00
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FormIndex::update()
|
|
|
|
{
|
2000-08-08 13:55:26 +00:00
|
|
|
fl_set_form_minsize(form(), minw, minh);
|
|
|
|
fl_set_form_maxsize(form(), 2*minw, minh);
|
|
|
|
|
2000-08-03 12:56:25 +00:00
|
|
|
fl_set_input(dialog_->key, params.getContents().c_str());
|
|
|
|
|
|
|
|
if( lv_->buffer()->isReadonly() ) {
|
|
|
|
fl_deactivate_object( dialog_->key );
|
|
|
|
fl_deactivate_object( dialog_->ok );
|
|
|
|
fl_set_object_lcol( dialog_->ok, FL_INACTIVE );
|
|
|
|
} else {
|
|
|
|
fl_activate_object( dialog_->key );
|
|
|
|
fl_activate_object( dialog_->ok );
|
|
|
|
fl_set_object_lcol( dialog_->ok, FL_BLACK );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FormIndex::apply()
|
|
|
|
{
|
2000-09-19 11:18:35 +00:00
|
|
|
if(lv_->buffer()->isReadonly()) return;
|
2000-08-03 12:56:25 +00:00
|
|
|
|
2000-09-19 11:18:35 +00:00
|
|
|
params.setContents(fl_get_input(dialog_->key));
|
2000-08-03 12:56:25 +00:00
|
|
|
|
2000-09-19 11:18:35 +00:00
|
|
|
if (inset_ != 0) {
|
2000-08-03 12:56:25 +00:00
|
|
|
// Only update if contents have changed
|
2000-09-19 11:18:35 +00:00
|
|
|
if (params != inset_->params()) {
|
|
|
|
inset_->setParams(params);
|
|
|
|
lv_->view()->updateInset(inset_, true);
|
2000-08-03 12:56:25 +00:00
|
|
|
}
|
|
|
|
} else {
|
2000-09-19 11:18:35 +00:00
|
|
|
lv_->getLyXFunc()->Dispatch(LFUN_INDEX_INSERT,
|
|
|
|
params.getAsString());
|
2000-08-03 12:56:25 +00:00
|
|
|
}
|
|
|
|
}
|