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
|
|
|
|
2007-11-23 10:45:14 +00:00
|
|
|
#include <string>
|
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
|
|
|
|
2007-11-23 10:45:14 +00:00
|
|
|
Dialog::Dialog(GuiView & lv, std::string const & name)
|
|
|
|
: lyxview_(&lv), name_(name.c_str())
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
2007-09-10 22:32:59 +00:00
|
|
|
Dialog::~Dialog()
|
2003-03-10 03:13:28 +00:00
|
|
|
{}
|
|
|
|
|
|
|
|
|
2007-11-23 10:45:14 +00:00
|
|
|
std::string Dialog::name() const
|
|
|
|
{
|
|
|
|
return name_;
|
|
|
|
}
|
|
|
|
|
2007-10-09 21:21:01 +00:00
|
|
|
bool Dialog::canApply() const
|
2007-09-08 21:16:54 +00:00
|
|
|
{
|
2007-11-23 10:45:14 +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-11-26 22:45:17 +00:00
|
|
|
theLyXFunc().setLyXView(lyxview_);
|
|
|
|
lyx::dispatch(fr);
|
2003-02-25 14:51:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-11-23 10:45:14 +00:00
|
|
|
void Dialog::updateDialog() const
|
2003-02-25 14:51:38 +00:00
|
|
|
{
|
2007-11-23 10:45:14 +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-11-23 10:45:14 +00:00
|
|
|
void Dialog::disconnect() const
|
2007-09-03 05:59:32 +00:00
|
|
|
{
|
2007-11-23 10:45: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
|