2003-02-25 14:51:38 +00:00
|
|
|
/**
|
2007-04-25 18:04:04 +00:00
|
|
|
* \file Dialog.cpp
|
2003-02-25 14:51:38 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
|
|
|
* \author Angus Leeming
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
* Full author contact details are available in file CREDITS.
|
2003-02-25 14:51:38 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#include "Dialog.h"
|
|
|
|
|
2005-04-13 09:43:58 +00:00
|
|
|
#include "frontends/LyXView.h"
|
|
|
|
|
2007-09-01 20:44:14 +00:00
|
|
|
#include "debug.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
#include "FuncRequest.h"
|
2005-04-13 09:43:58 +00:00
|
|
|
#include "FuncStatus.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
#include "LyXFunc.h"
|
2005-04-13 09:43:58 +00:00
|
|
|
|
2003-02-25 14:51:38 +00:00
|
|
|
|
2003-10-06 15:43:21 +00:00
|
|
|
using std::string;
|
|
|
|
|
2004-05-19 15:11:37 +00:00
|
|
|
namespace lyx {
|
|
|
|
namespace frontend {
|
2003-10-06 15:43:21 +00:00
|
|
|
|
2003-02-25 14:51:38 +00:00
|
|
|
Dialog::Dialog(LyXView & lv, string const & name)
|
2007-09-03 05:59:32 +00:00
|
|
|
: is_closing_(false), kernel_(lv), name_(name)
|
2003-03-10 03:13:28 +00:00
|
|
|
{}
|
|
|
|
|
|
|
|
|
2007-09-03 05:59:32 +00:00
|
|
|
Dialog::~Dialog()
|
|
|
|
{}
|
2003-02-25 14:51:38 +00:00
|
|
|
|
|
|
|
|
2007-09-03 20:28:26 +00:00
|
|
|
void Dialog::setButtonsValid(bool /*valid*/)
|
2007-09-03 05:59:32 +00:00
|
|
|
{}
|
2003-02-25 14:51:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
void Dialog::show(string const & data)
|
|
|
|
{
|
|
|
|
if (controller().isBufferDependent() && !kernel().isBufferAvailable())
|
|
|
|
return;
|
|
|
|
|
2003-03-14 00:20:42 +00:00
|
|
|
if (!controller().initialiseParams(data)) {
|
|
|
|
lyxerr << "Dialog \"" << name_
|
|
|
|
<< "\" failed to translate the data "
|
|
|
|
"string passed to show()" << std::endl;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-09-03 05:59:32 +00:00
|
|
|
preShow();
|
2007-09-05 20:33:29 +00:00
|
|
|
showView();
|
2007-09-03 05:59:32 +00:00
|
|
|
postShow();
|
2003-02-25 14:51:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Dialog::update(string const & data)
|
|
|
|
{
|
|
|
|
if (controller().isBufferDependent() && !kernel().isBufferAvailable())
|
|
|
|
return;
|
|
|
|
|
2003-03-14 00:20:42 +00:00
|
|
|
if (!controller().initialiseParams(data)) {
|
|
|
|
lyxerr << "Dialog \"" << name_
|
2004-03-31 19:51:55 +00:00
|
|
|
<< "\" could not be initialized" << std::endl;
|
2003-03-14 00:20:42 +00:00
|
|
|
return;
|
|
|
|
}
|
2003-02-25 14:51:38 +00:00
|
|
|
|
2007-09-03 05:59:32 +00:00
|
|
|
preUpdate();
|
2007-09-05 20:33:29 +00:00
|
|
|
updateView();
|
2007-09-03 05:59:32 +00:00
|
|
|
postUpdate();
|
|
|
|
}
|
2003-02-25 14:51:38 +00:00
|
|
|
|
2007-09-03 05:59:32 +00:00
|
|
|
|
|
|
|
void Dialog::checkStatus()
|
|
|
|
{
|
2003-02-25 14:51:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Dialog::hide()
|
|
|
|
{
|
2007-09-05 20:33:29 +00:00
|
|
|
if (!isVisibleView())
|
2003-02-25 14:51:38 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
controller().clearParams();
|
2007-09-05 20:33:29 +00:00
|
|
|
hideView();
|
2007-09-08 16:53:54 +00:00
|
|
|
kernel().disconnect(name_);
|
2003-02-25 14:51:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Dialog::apply()
|
|
|
|
{
|
2004-03-31 18:51:11 +00:00
|
|
|
if (controller().isBufferDependent()) {
|
|
|
|
if (!kernel().isBufferAvailable() ||
|
2007-09-05 20:33:29 +00:00
|
|
|
(kernel().isBufferReadonly() && !controller().canApplyToReadOnly()))
|
2004-03-31 18:51:11 +00:00
|
|
|
return;
|
|
|
|
}
|
2003-02-25 14:51:38 +00:00
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
applyView();
|
2003-02-25 14:51:38 +00:00
|
|
|
controller().dispatchParams();
|
|
|
|
|
|
|
|
if (controller().disconnectOnApply() && !is_closing_) {
|
2007-09-08 16:53:54 +00:00
|
|
|
kernel().disconnect(name_);
|
2003-06-30 23:56:22 +00:00
|
|
|
controller().initialiseParams(string());
|
2007-09-05 20:33:29 +00:00
|
|
|
updateView();
|
2003-02-25 14:51:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool Dialog::isVisible() const
|
|
|
|
{
|
2007-09-05 20:33:29 +00:00
|
|
|
return isVisibleView();
|
2003-02-25 14:51:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Dialog::redraw()
|
|
|
|
{
|
2007-09-05 20:33:29 +00:00
|
|
|
redrawView();
|
2003-02-25 14:51:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-07-17 15:35:42 +00:00
|
|
|
void Dialog::setController(Controller * i)
|
|
|
|
{
|
2003-09-09 17:25:35 +00:00
|
|
|
BOOST_ASSERT(i && !controller_ptr_.get());
|
2003-07-17 15:35:42 +00:00
|
|
|
controller_ptr_.reset(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-07-16 20:10:59 +00:00
|
|
|
Dialog::Controller::Controller(Dialog & parent)
|
|
|
|
: parent_(parent)
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
2005-04-26 09:37:52 +00:00
|
|
|
bool Dialog::Controller::canApply() const
|
|
|
|
{
|
2007-09-08 16:53:54 +00:00
|
|
|
FuncRequest const fr(getLfun(), dialog().name_);
|
2007-04-25 23:06:48 +00:00
|
|
|
FuncStatus const fs(getStatus(fr));
|
2005-04-26 09:37:52 +00:00
|
|
|
return fs.enabled();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-02-25 14:51:38 +00:00
|
|
|
Dialog::Controller & Dialog::controller() const
|
|
|
|
{
|
2003-09-09 17:25:35 +00:00
|
|
|
BOOST_ASSERT(controller_ptr_.get());
|
2003-02-25 14:51:38 +00:00
|
|
|
return *controller_ptr_.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
void Dialog::setViewTitle(docstring const & newtitle)
|
2003-05-22 15:42:50 +00:00
|
|
|
{
|
|
|
|
title_ = newtitle;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
docstring const & Dialog::getViewTitle() const
|
2003-05-22 15:42:50 +00:00
|
|
|
{
|
|
|
|
return title_;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-05-19 15:11:37 +00:00
|
|
|
} // namespace frontend
|
|
|
|
} // namespace lyx
|