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-11-23 09:44:02 +00:00
|
|
|
#include "GuiView.h"
|
|
|
|
|
2007-11-18 00:01:14 +00:00
|
|
|
#include "Buffer.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-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-10-09 21:21:01 +00:00
|
|
|
bool Dialog::canApply() const
|
2007-09-08 21:16:54 +00:00
|
|
|
{
|
2007-10-09 21:21:01 +00:00
|
|
|
FuncRequest const fr(getLfun(), name());
|
2007-09-10 22:32:59 +00:00
|
|
|
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-10-09 21:21:01 +00:00
|
|
|
void Dialog::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-10-09 21:21:01 +00:00
|
|
|
void Dialog::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-10-09 21:21:01 +00:00
|
|
|
void Dialog::disconnect(std::string const & name) const
|
2007-09-03 05:59:32 +00:00
|
|
|
{
|
2007-11-18 00:01:14 +00:00
|
|
|
lyxview_->disconnectDialog(name);
|
2003-02-25 14:51:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-09 21:21:01 +00:00
|
|
|
bool Dialog::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-10-09 21:21:01 +00:00
|
|
|
bool Dialog::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-10-09 21:21:01 +00:00
|
|
|
std::string const Dialog::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-10-09 21:21:01 +00:00
|
|
|
KernelDocType Dialog::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-10-09 21:21:01 +00:00
|
|
|
BufferView * Dialog::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
|
|
|
|
2007-10-09 21:21:01 +00:00
|
|
|
BufferView const * Dialog::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-10-09 21:21:01 +00:00
|
|
|
Buffer & Dialog::buffer()
|
2007-09-10 22:32:59 +00:00
|
|
|
{
|
|
|
|
BOOST_ASSERT(lyxview_->buffer());
|
|
|
|
return *lyxview_->buffer();
|
|
|
|
}
|
2003-07-16 20:10:59 +00:00
|
|
|
|
|
|
|
|
2007-10-09 21:21:01 +00:00
|
|
|
Buffer const & Dialog::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
|