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"
|
|
|
|
|
2001-03-16 12:08:14 +00:00
|
|
|
using SigC::slot;
|
|
|
|
|
2000-08-03 12:56:25 +00:00
|
|
|
FormIndex::FormIndex(LyXView * lv, Dialogs * d)
|
2001-03-15 13:37:04 +00:00
|
|
|
: FormCommand(lv, d, _("Index"))
|
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));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-10-03 05:53:25 +00:00
|
|
|
FL_FORM * FormIndex::form() const
|
|
|
|
{
|
2001-03-15 13:37:04 +00:00
|
|
|
if (dialog_.get()) return dialog_->form;
|
2000-10-03 05:53:25 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-10-20 09:50:09 +00:00
|
|
|
void FormIndex::connect()
|
|
|
|
{
|
2000-11-14 02:01:57 +00:00
|
|
|
fl_set_form_maxsize(form(), 2 * minw_, minh_);
|
2000-10-20 09:50:09 +00:00
|
|
|
FormCommand::connect();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-08-03 12:56:25 +00:00
|
|
|
void FormIndex::build()
|
|
|
|
{
|
2001-03-15 13:37:04 +00:00
|
|
|
dialog_.reset(build_index());
|
2000-08-04 13:12:30 +00:00
|
|
|
|
2000-11-28 06:46:06 +00:00
|
|
|
fl_set_input_return(dialog_->input_key, FL_RETURN_CHANGED);
|
|
|
|
|
|
|
|
// Manage the ok, apply, restore and cancel/close buttons
|
2001-03-15 13:37:04 +00:00
|
|
|
bc().setOK(dialog_->button_ok);
|
|
|
|
bc().setApply(dialog_->button_apply);
|
|
|
|
bc().setCancel(dialog_->button_cancel);
|
|
|
|
bc().setUndoAll(dialog_->button_restore);
|
|
|
|
bc().refresh();
|
2000-11-28 06:46:06 +00:00
|
|
|
|
2001-03-15 13:37:04 +00:00
|
|
|
bc().addReadOnly(dialog_->input_key);
|
2000-08-03 12:56:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-10-24 13:13:59 +00:00
|
|
|
void FormIndex::update()
|
2000-08-03 12:56:25 +00:00
|
|
|
{
|
2000-11-28 06:46:06 +00:00
|
|
|
fl_set_input(dialog_->input_key, params.getContents().c_str());
|
|
|
|
// Surely, this should reset the buttons to their original state?
|
|
|
|
// It doesn't. Instead "Restore" becomes a "Close"
|
2001-03-15 13:37:04 +00:00
|
|
|
//bc().refresh();
|
|
|
|
bc().readOnly(lv_->buffer()->isReadonly());
|
2000-08-03 12:56:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FormIndex::apply()
|
|
|
|
{
|
2000-10-03 05:53:25 +00:00
|
|
|
if (lv_->buffer()->isReadonly()) return;
|
2000-08-03 12:56:25 +00:00
|
|
|
|
2000-11-28 06:46:06 +00:00
|
|
|
params.setContents(fl_get_input(dialog_->input_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
|
|
|
}
|
|
|
|
}
|