3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Angus Leeming
8 * Full author contact details are available in file CREDITS.
15 #include "FuncRequest.h"
16 #include "FuncStatus.h"
19 #include "frontends/LyXView.h"
20 #include "frontends/Dialogs.h" // FIXME
33 Controller::Controller(Dialog & parent)
34 : parent_(parent), lyxview_(0)
38 Controller::Controller(Dialog * parent)
39 : parent_(*parent), lyxview_(0)
43 Controller::~Controller()
47 bool Controller::canApply() const
49 FuncRequest const fr(getLfun(), dialog().name());
50 FuncStatus const fs(getStatus(fr));
55 void Controller::dispatch(FuncRequest const & fr) const
57 lyxview_->dispatch(fr);
61 void Controller::updateDialog(std::string const & name) const
63 dispatch(FuncRequest(LFUN_DIALOG_UPDATE, name));
67 void Controller::disconnect(std::string const & name) const
69 lyxview_->getDialogs().disconnect(name);
73 bool Controller::isBufferAvailable() const
75 return lyxview_->buffer() != 0;
79 bool Controller::isBufferReadonly() const
81 if (!lyxview_->buffer())
83 return lyxview_->buffer()->isReadonly();
87 std::string const Controller::bufferFilepath() const
89 return buffer().filePath();
93 KernelDocType Controller::docType() const
95 if (buffer().isLatex())
97 if (buffer().isLiterate())
104 BufferView * Controller::bufferview()
106 return lyxview_->view();
110 BufferView const * Controller::bufferview() const
112 return lyxview_->view();
116 Buffer & Controller::buffer()
118 BOOST_ASSERT(lyxview_->buffer());
119 return *lyxview_->buffer();
123 Buffer const & Controller::buffer() const
125 BOOST_ASSERT(lyxview_->buffer());
126 return *lyxview_->buffer();
129 } // namespace frontend