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"
|
|
|
|
|
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
|
|
|
|
2007-09-10 22:32:59 +00:00
|
|
|
#include "frontends/LyXView.h"
|
|
|
|
#include "frontends/Dialogs.h" // FIXME
|
|
|
|
|
|
|
|
#include "Buffer.h"
|
2003-02-25 14:51:38 +00:00
|
|
|
|
2003-10-06 15:43:21 +00:00
|
|
|
|
2004-05-19 15:11:37 +00:00
|
|
|
namespace lyx {
|
|
|
|
namespace frontend {
|
2003-10-06 15:43:21 +00:00
|
|
|
|
2007-09-10 22:32:59 +00:00
|
|
|
|
|
|
|
Dialog::~Dialog()
|
2003-03-10 03:13:28 +00:00
|
|
|
{}
|
|
|
|
|
|
|
|
|
2007-09-10 22:32:59 +00:00
|
|
|
Controller::Controller(Dialog & parent)
|
|
|
|
: parent_(parent), lyxview_(0)
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
2007-10-05 20:16:05 +00:00
|
|
|
Controller::Controller(Dialog * parent)
|
|
|
|
: parent_(*parent), lyxview_(0)
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
2007-09-10 22:32:59 +00:00
|
|
|
Controller::~Controller()
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
bool Controller::canApply() const
|
2007-09-08 21:16:54 +00:00
|
|
|
{
|
2007-09-10 22:32:59 +00:00
|
|
|
FuncRequest const fr(getLfun(), dialog().name());
|
|
|
|
FuncStatus const fs(getStatus(fr));
|
|
|
|
return fs.enabled();
|
2007-09-08 21:16:54 +00:00
|
|
|
}
|
2003-02-25 14:51:38 +00:00
|
|
|
|
|
|
|
|
2007-09-10 22:32:59 +00:00
|
|
|
void Controller::dispatch(FuncRequest const & fr) const
|
2003-02-25 14:51:38 +00:00
|
|
|
{
|
2007-09-10 22:32:59 +00:00
|
|
|
lyxview_->dispatch(fr);
|
2003-02-25 14:51:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-09-10 22:32:59 +00:00
|
|
|
void Controller::updateDialog(std::string const & name) const
|
2003-02-25 14:51:38 +00:00
|
|
|
{
|
2007-09-10 22:32:59 +00:00
|
|
|
dispatch(FuncRequest(LFUN_DIALOG_UPDATE, name));
|
2007-09-03 05:59:32 +00:00
|
|
|
}
|
2003-02-25 14:51:38 +00:00
|
|
|
|
2007-09-03 05:59:32 +00:00
|
|
|
|
2007-09-10 22:32:59 +00:00
|
|
|
void Controller::disconnect(std::string const & name) const
|
2007-09-03 05:59:32 +00:00
|
|
|
{
|
2007-09-10 22:32:59 +00:00
|
|
|
lyxview_->getDialogs().disconnect(name);
|
2003-02-25 14:51:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-09-10 22:32:59 +00:00
|
|
|
bool Controller::isBufferAvailable() const
|
2003-02-25 14:51:38 +00:00
|
|
|
{
|
2007-09-10 22:32:59 +00:00
|
|
|
return lyxview_->buffer() != 0;
|
2003-02-25 14:51:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-09-10 22:32:59 +00:00
|
|
|
bool Controller::isBufferReadonly() const
|
2003-02-25 14:51:38 +00:00
|
|
|
{
|
2007-09-10 22:32:59 +00:00
|
|
|
if (!lyxview_->buffer())
|
|
|
|
return true;
|
|
|
|
return lyxview_->buffer()->isReadonly();
|
2003-02-25 14:51:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-09-10 22:32:59 +00:00
|
|
|
std::string const Controller::bufferFilepath() const
|
2003-02-25 14:51:38 +00:00
|
|
|
{
|
2007-09-10 22:32:59 +00:00
|
|
|
return buffer().filePath();
|
2003-02-25 14:51:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-09-10 22:32:59 +00:00
|
|
|
KernelDocType Controller::docType() const
|
2003-02-25 14:51:38 +00:00
|
|
|
{
|
2007-09-10 22:32:59 +00:00
|
|
|
if (buffer().isLatex())
|
|
|
|
return LATEX;
|
|
|
|
if (buffer().isLiterate())
|
|
|
|
return LITERATE;
|
|
|
|
|
|
|
|
return DOCBOOK;
|
2003-02-25 14:51:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-09-10 22:32:59 +00:00
|
|
|
BufferView * Controller::bufferview()
|
2003-07-17 15:35:42 +00:00
|
|
|
{
|
2007-09-10 22:32:59 +00:00
|
|
|
return lyxview_->view();
|
2003-07-17 15:35:42 +00:00
|
|
|
}
|
|
|
|
|
2007-09-10 22:32:59 +00:00
|
|
|
|
|
|
|
BufferView const * Controller::bufferview() const
|
2007-09-10 19:02:11 +00:00
|
|
|
{
|
2007-09-10 22:32:59 +00:00
|
|
|
return lyxview_->view();
|
2007-09-10 19:02:11 +00:00
|
|
|
}
|
|
|
|
|
2003-07-17 15:35:42 +00:00
|
|
|
|
2007-09-10 22:32:59 +00:00
|
|
|
Buffer & Controller::buffer()
|
|
|
|
{
|
|
|
|
BOOST_ASSERT(lyxview_->buffer());
|
|
|
|
return *lyxview_->buffer();
|
|
|
|
}
|
2003-07-16 20:10:59 +00:00
|
|
|
|
|
|
|
|
2007-09-10 22:32:59 +00:00
|
|
|
Buffer const & Controller::buffer() const
|
2005-04-26 09:37:52 +00:00
|
|
|
{
|
2007-09-10 22:32:59 +00:00
|
|
|
BOOST_ASSERT(lyxview_->buffer());
|
|
|
|
return *lyxview_->buffer();
|
2005-04-26 09:37:52 +00:00
|
|
|
}
|
|
|
|
|
2004-05-19 15:11:37 +00:00
|
|
|
} // namespace frontend
|
|
|
|
} // namespace lyx
|