2003-03-10 03:13:28 +00:00
|
|
|
/**
|
|
|
|
* \file ButtonController.C
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
|
|
|
* \author Allan Rae
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
* Full author contact details are available in file CREDITS.
|
2003-03-10 03:13:28 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
2003-09-09 17:25:35 +00:00
|
|
|
|
2003-03-10 03:13:28 +00:00
|
|
|
#include "ButtonController.h"
|
|
|
|
#include "BCView.h"
|
|
|
|
|
2004-05-19 15:11:37 +00:00
|
|
|
namespace lyx {
|
|
|
|
namespace frontend {
|
2003-03-10 03:13:28 +00:00
|
|
|
|
|
|
|
BCView & ButtonController::view() const
|
|
|
|
{
|
2003-09-09 17:25:35 +00:00
|
|
|
BOOST_ASSERT(view_.get());
|
2003-03-10 03:13:28 +00:00
|
|
|
return *view_.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ButtonController::view(BCView * view)
|
|
|
|
{
|
|
|
|
view_.reset(view);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ButtonPolicy & ButtonController::bp() const
|
|
|
|
{
|
2003-09-09 17:25:35 +00:00
|
|
|
BOOST_ASSERT(bp_.get());
|
2003-03-10 03:13:28 +00:00
|
|
|
return *bp_.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ButtonController::bp(ButtonPolicy * bp)
|
|
|
|
{
|
|
|
|
bp_.reset(bp);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-03-14 00:20:42 +00:00
|
|
|
void ButtonController::refresh() const
|
2003-03-10 03:13:28 +00:00
|
|
|
{
|
|
|
|
view().refresh();
|
|
|
|
}
|
|
|
|
|
2003-03-14 00:20:42 +00:00
|
|
|
|
|
|
|
void ButtonController::refreshReadOnly() const
|
2003-03-10 03:13:28 +00:00
|
|
|
{
|
|
|
|
view().refreshReadOnly();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-03-14 00:20:42 +00:00
|
|
|
void ButtonController::ok() const
|
2003-03-10 03:13:28 +00:00
|
|
|
{
|
|
|
|
input(ButtonPolicy::SMI_OKAY);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-03-14 00:20:42 +00:00
|
|
|
void ButtonController::input(ButtonPolicy::SMInput in) const
|
2003-03-10 03:13:28 +00:00
|
|
|
{
|
|
|
|
if (ButtonPolicy::SMI_NOOP == in)
|
|
|
|
return;
|
|
|
|
bp().input(in);
|
|
|
|
view().refresh();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-03-14 00:20:42 +00:00
|
|
|
void ButtonController::apply() const
|
2003-03-10 03:13:28 +00:00
|
|
|
{
|
|
|
|
input(ButtonPolicy::SMI_APPLY);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-03-14 00:20:42 +00:00
|
|
|
void ButtonController::cancel() const
|
2003-03-10 03:13:28 +00:00
|
|
|
{
|
|
|
|
input(ButtonPolicy::SMI_CANCEL);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-03-14 00:20:42 +00:00
|
|
|
void ButtonController::restore() const
|
2003-03-10 03:13:28 +00:00
|
|
|
{
|
|
|
|
input(ButtonPolicy::SMI_RESTORE);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-03-14 00:20:42 +00:00
|
|
|
void ButtonController::hide() const
|
2003-03-10 03:13:28 +00:00
|
|
|
{
|
|
|
|
input(ButtonPolicy::SMI_HIDE);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-03-14 00:20:42 +00:00
|
|
|
void ButtonController::valid(bool v) const
|
2003-03-10 03:13:28 +00:00
|
|
|
{
|
|
|
|
if (v) {
|
|
|
|
input(ButtonPolicy::SMI_VALID);
|
|
|
|
} else {
|
|
|
|
input(ButtonPolicy::SMI_INVALID);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-03-14 00:20:42 +00:00
|
|
|
bool ButtonController::readOnly(bool ro) const
|
2003-03-10 03:13:28 +00:00
|
|
|
{
|
|
|
|
lyxerr[Debug::GUI] << "Setting controller ro: " << ro << std::endl;
|
|
|
|
|
|
|
|
if (ro) {
|
|
|
|
bp().input(ButtonPolicy::SMI_READ_ONLY);
|
|
|
|
} else {
|
|
|
|
bp().input(ButtonPolicy::SMI_READ_WRITE);
|
|
|
|
}
|
|
|
|
view().refreshReadOnly();
|
|
|
|
view().refresh();
|
|
|
|
return ro;
|
|
|
|
}
|
2004-05-19 15:11:37 +00:00
|
|
|
|
|
|
|
} // namespace frontend
|
|
|
|
} // namespace lyx
|