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"
|
2002-05-23 12:08:47 +00:00
|
|
|
#include "frontends/LyXView.h"
|
2000-10-13 05:57:05 +00:00
|
|
|
#include "FormInset.h"
|
2001-03-15 13:37:04 +00:00
|
|
|
#include "xformsBC.h"
|
2000-10-13 05:57:05 +00:00
|
|
|
|
2002-05-29 16:21:03 +00:00
|
|
|
#include <boost/bind.hpp>
|
2001-03-16 12:08:14 +00:00
|
|
|
|
2001-03-15 13:37:04 +00:00
|
|
|
FormInset::FormInset(LyXView * lv, Dialogs * d, string const & t)
|
2002-05-29 16:21:03 +00:00
|
|
|
: FormBaseBD(lv, d, t)
|
2000-10-13 05:57:05 +00:00
|
|
|
{}
|
|
|
|
|
|
|
|
|
2000-10-24 15:15:25 +00:00
|
|
|
void FormInset::connect()
|
|
|
|
{
|
|
|
|
u_ = d_->updateBufferDependent.
|
2002-05-29 16:21:03 +00:00
|
|
|
connect(boost::bind(&FormInset::updateSlot, this, _1));
|
2000-10-24 15:15:25 +00:00
|
|
|
h_ = d_->hideBufferDependent.
|
2002-05-29 16:21:03 +00:00
|
|
|
connect(boost::bind(&FormInset::hide, this));
|
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();
|
|
|
|
}
|
|
|
|
|
2002-03-21 21:21:28 +00:00
|
|
|
|
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();
|
2002-05-29 16:21:03 +00:00
|
|
|
ih_ = inset->hideDialog.connect(boost::bind(&FormCommand::hide, this));
|
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();
|
|
|
|
}
|