2001-04-17 14:06:11 +00:00
|
|
|
// -*- C++ -*-
|
2002-09-05 14:10:50 +00:00
|
|
|
/**
|
2001-03-30 09:51:46 +00:00
|
|
|
* \file ButtonController.h
|
2002-09-05 15:14:23 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
2002-01-16 14:47:58 +00:00
|
|
|
*
|
2002-09-05 14:10:50 +00:00
|
|
|
* \author Allan Rae
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
* Full author contact details are available in file CREDITS.
|
2001-03-15 13:37:04 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef BUTTONCONTROLLER_H
|
|
|
|
#define BUTTONCONTROLLER_H
|
|
|
|
|
|
|
|
|
2003-03-10 03:13:28 +00:00
|
|
|
#include "ButtonPolicies.h"
|
2001-06-16 14:48:12 +00:00
|
|
|
|
2003-03-10 03:13:28 +00:00
|
|
|
#include <boost/scoped_ptr.hpp>
|
|
|
|
|
|
|
|
|
2003-03-14 00:20:42 +00:00
|
|
|
class BCView;
|
|
|
|
|
|
|
|
|
2003-06-28 01:23:11 +00:00
|
|
|
/** \c ButtonController controls the activation of the OK, Apply and
|
2003-03-14 00:20:42 +00:00
|
|
|
* Cancel buttons.
|
2003-03-10 03:13:28 +00:00
|
|
|
*
|
2003-03-14 00:20:42 +00:00
|
|
|
* It actually supports 4 buttons in all and it's up to the user to decide on
|
2003-03-10 03:13:28 +00:00
|
|
|
* the activation policy and which buttons correspond to which output of the
|
|
|
|
* state machine.
|
2002-01-16 14:47:58 +00:00
|
|
|
*/
|
2003-03-10 03:13:28 +00:00
|
|
|
|
|
|
|
class ButtonController : boost::noncopyable {
|
2001-03-15 13:37:04 +00:00
|
|
|
public:
|
2003-03-14 00:20:42 +00:00
|
|
|
//@{
|
|
|
|
/** Methods to set and get the GUI view (containing the actual
|
|
|
|
* button widgets.
|
|
|
|
* \param ptr is owned by the ButtonController.
|
|
|
|
*/
|
|
|
|
void view(BCView * ptr);
|
2003-03-10 03:13:28 +00:00
|
|
|
BCView & view() const;
|
2003-03-14 00:20:42 +00:00
|
|
|
//@}
|
2003-03-10 03:13:28 +00:00
|
|
|
|
2003-03-14 00:20:42 +00:00
|
|
|
//@{
|
|
|
|
/** Methods to set and get the ButtonPolicy.
|
|
|
|
* \param ptr is owned by the ButtonController.
|
|
|
|
*/
|
|
|
|
void bp(ButtonPolicy * ptr);
|
2003-03-10 03:13:28 +00:00
|
|
|
ButtonPolicy & bp() const;
|
2003-03-14 00:20:42 +00:00
|
|
|
//@}
|
2003-03-10 03:13:28 +00:00
|
|
|
|
2001-03-15 13:37:04 +00:00
|
|
|
///
|
2003-03-14 00:20:42 +00:00
|
|
|
void input(ButtonPolicy::SMInput) const;
|
2001-03-15 13:37:04 +00:00
|
|
|
|
2003-03-14 00:20:42 +00:00
|
|
|
//@{
|
|
|
|
/// Tell the BC that a particular button has been pressed.
|
|
|
|
void ok() const;
|
|
|
|
void apply() const;
|
|
|
|
void cancel() const;
|
|
|
|
void restore() const;
|
|
|
|
//@}
|
2001-03-15 13:37:04 +00:00
|
|
|
|
2003-03-14 00:20:42 +00:00
|
|
|
/// Tell the BC that the dialog is being hidden
|
|
|
|
void hide() const;
|
2001-03-15 13:37:04 +00:00
|
|
|
|
2003-03-14 00:20:42 +00:00
|
|
|
/**Refresh the activation state of the Ok, Apply, Close and
|
|
|
|
* Restore buttons.
|
|
|
|
*/
|
|
|
|
void refresh() const;
|
|
|
|
|
|
|
|
/** Refresh the activation state of all the widgets under the control
|
|
|
|
* of the BC to reflect the read-only status of the underlying buffer.
|
|
|
|
*/
|
|
|
|
void refreshReadOnly() const;
|
|
|
|
|
|
|
|
/** Passthrough function -- returns its input value
|
|
|
|
* Tell the BC about the read-only status of the underlying buffer.
|
|
|
|
*/
|
|
|
|
bool readOnly(bool = true) const;
|
|
|
|
|
|
|
|
/** \param validity Tell the BC that the data is, or is not, valid.
|
|
|
|
* Sets the activation state of the buttons immediately.
|
|
|
|
*/
|
|
|
|
void valid(bool = true) const;
|
2003-03-10 03:13:28 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
boost::scoped_ptr<ButtonPolicy> bp_;
|
|
|
|
boost::scoped_ptr<BCView> view_;
|
2001-03-15 13:37:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // BUTTONCONTROLLER_H
|