2002-03-11 17:00:41 +00:00
|
|
|
/**
|
|
|
|
* \file FormInset.C
|
|
|
|
* Copyright 2000-2001 The LyX Team.
|
|
|
|
* See the file COPYING.
|
2000-10-13 05:57:05 +00:00
|
|
|
*
|
2002-03-11 17:00:41 +00:00
|
|
|
* \author Angus Leeming, a.leeming@ic.ac.uk
|
2000-10-13 05:57:05 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#include FORMS_H_LOCATION
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma implementation
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "Dialogs.h"
|
|
|
|
#include "LyXView.h"
|
|
|
|
#include "FormInset.h"
|
2001-03-15 13:37:04 +00:00
|
|
|
#include "xformsBC.h"
|
2000-10-13 05:57:05 +00:00
|
|
|
|
2001-03-16 12:08:14 +00:00
|
|
|
using SigC::slot;
|
|
|
|
|
2001-03-15 13:37:04 +00:00
|
|
|
FormInset::FormInset(LyXView * lv, Dialogs * d, string const & t)
|
|
|
|
: FormBaseBD(lv, d, t), ih_(0)
|
2000-10-13 05:57:05 +00:00
|
|
|
{}
|
|
|
|
|
|
|
|
|
2000-10-24 15:15:25 +00:00
|
|
|
void FormInset::connect()
|
|
|
|
{
|
|
|
|
u_ = d_->updateBufferDependent.
|
|
|
|
connect(slot(this, &FormInset::updateSlot));
|
|
|
|
h_ = d_->hideBufferDependent.
|
|
|
|
connect(slot(this, &FormInset::hide));
|
2001-03-15 13:37:04 +00:00
|
|
|
FormBaseDeprecated::connect();
|
2000-10-24 15:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-10-24 13:13:59 +00:00
|
|
|
void FormInset::disconnect()
|
2000-10-13 05:57:05 +00:00
|
|
|
{
|
2000-10-24 13:13:59 +00:00
|
|
|
ih_.disconnect();
|
|
|
|
FormBaseBD::disconnect();
|
2000-10-13 05:57:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-11-14 02:01:57 +00:00
|
|
|
void FormInset::updateSlot(bool switched)
|
2000-10-13 05:57:05 +00:00
|
|
|
{
|
2000-10-24 13:13:59 +00:00
|
|
|
if (switched)
|
|
|
|
hide();
|
|
|
|
else
|
|
|
|
update();
|
2000-10-13 05:57:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-03-15 13:37:04 +00:00
|
|
|
FormCommand::FormCommand(LyXView * lv, Dialogs * d, string const & t)
|
|
|
|
: FormInset(lv, d, t),
|
2000-10-13 05:57:05 +00:00
|
|
|
inset_(0)
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
void FormCommand::disconnect()
|
|
|
|
{
|
|
|
|
inset_ = 0;
|
2000-11-14 02:01:57 +00:00
|
|
|
params = InsetCommandParams(string());
|
2000-10-13 05:57:05 +00:00
|
|
|
FormInset::disconnect();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-11-14 02:01:57 +00:00
|
|
|
void FormCommand::showInset(InsetCommand * inset)
|
2000-10-13 05:57:05 +00:00
|
|
|
{
|
|
|
|
if (inset == 0) return; // maybe we should Assert this?
|
|
|
|
|
|
|
|
// If connected to another inset, disconnect from it.
|
|
|
|
if (inset_)
|
|
|
|
ih_.disconnect();
|
|
|
|
|
|
|
|
inset_ = inset;
|
|
|
|
params = inset->params();
|
2001-02-19 16:01:31 +00:00
|
|
|
ih_ = inset->hideDialog.connect(slot(this, &FormCommand::hide));
|
2000-10-13 05:57:05 +00:00
|
|
|
show();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-11-14 02:01:57 +00:00
|
|
|
void FormCommand::createInset(string const & arg)
|
2000-10-13 05:57:05 +00:00
|
|
|
{
|
|
|
|
if (inset_) {
|
|
|
|
ih_.disconnect();
|
|
|
|
inset_ = 0;
|
|
|
|
}
|
|
|
|
|
2000-11-14 02:01:57 +00:00
|
|
|
params.setFromString(arg);
|
2002-02-16 15:59:55 +00:00
|
|
|
if ( !arg.empty())
|
2001-03-15 13:37:04 +00:00
|
|
|
bc().valid(); // so that the user can press Ok
|
2000-10-13 05:57:05 +00:00
|
|
|
show();
|
|
|
|
}
|