/**
- * \file Dialog.C
+ * \file Dialog.cpp
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
#include "ButtonController.h"
#include "BCView.h"
+#include "frontends/LyXView.h"
+
+#include "funcrequest.h"
+#include "FuncStatus.h"
+#include "lyxfunc.h"
+
+using lyx::docstring;
using std::string;
}
+void Dialog::checkStatus()
+{
+ // buffer independant dialogs are always active.
+ // This check allows us leave canApply unimplemented for some dialogs.
+ if (!controller().isBufferDependent())
+ return;
+
+ // deactivate the dialog if we have no buffer
+ if (!kernel().isBufferAvailable()) {
+ bc().readOnly(true);
+ return;
+ }
+
+ // check whether this dialog may be active
+ if (controller().canApply()) {
+ bool const readonly = kernel().isBufferReadonly();
+ bc().readOnly(readonly);
+ // refreshReadOnly() is too generous in _enabling_ widgets
+ // update dialog to disable disabled widgets again
+ if (!readonly)
+ view().update();
+ } else
+ bc().readOnly(true);
+}
+
+
Dialog::Controller::Controller(Dialog & parent)
: parent_(parent)
{}
+bool Dialog::Controller::canApply() const
+{
+ FuncRequest const fr(getLfun(), dialog().name());
+ FuncStatus const fs(lyx::getStatus(fr));
+ return fs.enabled();
+}
+
+
Dialog::Controller & Dialog::controller() const
{
BOOST_ASSERT(controller_ptr_.get());
}
-Dialog::View::View(Dialog & parent, string title) :
+Dialog::View::View(Dialog & parent, docstring title) :
p_(parent), title_(title)
{}
}
-void Dialog::View::setTitle(string const & newtitle)
+void Dialog::View::setTitle(docstring const & newtitle)
{
title_ = newtitle;
}
-string const & Dialog::View::getTitle() const
+docstring const & Dialog::View::getTitle() const
{
return title_;
}