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
|
2002-10-21 17:38:09 +00:00
|
|
|
* \author Angus Leeming
|
2002-09-05 14:10:50 +00:00
|
|
|
* \author Baruch Even
|
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS
|
2001-03-15 13:37:04 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef BUTTONCONTROLLER_H
|
|
|
|
#define BUTTONCONTROLLER_H
|
|
|
|
|
|
|
|
|
2001-06-16 14:48:12 +00:00
|
|
|
#include "ButtonControllerBase.h"
|
2002-01-16 14:47:58 +00:00
|
|
|
#include "gettext.h"
|
|
|
|
#include <list>
|
2001-06-16 14:48:12 +00:00
|
|
|
|
2002-01-16 14:47:58 +00:00
|
|
|
/** A templatised instantiation of the ButtonController requiring the
|
|
|
|
* gui-frontend widgets.
|
|
|
|
* The template declarations are in ButtonController.tmpl, which should
|
|
|
|
* be #included in the gui-frontend BC class, see e.g. xforms/xformsBC.C
|
|
|
|
*/
|
2001-03-30 09:51:46 +00:00
|
|
|
template <class Button, class Widget>
|
2002-10-21 17:38:09 +00:00
|
|
|
class GuiBC : public ButtonControllerBase {
|
2001-03-15 13:37:04 +00:00
|
|
|
public:
|
|
|
|
///
|
2001-03-30 09:51:46 +00:00
|
|
|
GuiBC(string const & cancel, string const & close);
|
|
|
|
|
2002-03-21 21:21:28 +00:00
|
|
|
///
|
2001-03-30 09:51:46 +00:00
|
|
|
void setOK(Button * obj) { okay_ = obj; }
|
2002-03-21 21:21:28 +00:00
|
|
|
///
|
2001-03-30 09:51:46 +00:00
|
|
|
void setApply(Button * obj) { apply_ = obj; }
|
2002-03-21 21:21:28 +00:00
|
|
|
///
|
2001-03-30 09:51:46 +00:00
|
|
|
void setCancel(Button * obj) { cancel_ = obj; }
|
2001-03-15 13:37:04 +00:00
|
|
|
///
|
2001-04-03 14:30:58 +00:00
|
|
|
void setRestore(Button * obj) { restore_ = obj; }
|
2001-03-15 13:37:04 +00:00
|
|
|
///
|
2001-03-30 09:51:46 +00:00
|
|
|
void addReadOnly(Widget * obj) { read_only_.push_back(obj); }
|
2001-03-15 13:37:04 +00:00
|
|
|
///
|
2001-03-30 09:51:46 +00:00
|
|
|
void eraseReadOnly() { read_only_.clear(); }
|
2001-03-15 13:37:04 +00:00
|
|
|
|
2001-06-02 14:53:35 +00:00
|
|
|
/// Refresh the status of the Ok, Apply, Restore, Cancel buttons.
|
2001-03-30 09:51:46 +00:00
|
|
|
void refresh();
|
2001-06-02 14:53:35 +00:00
|
|
|
/// Refresh the status of any widgets in the read_only list
|
|
|
|
void refreshReadOnly();
|
2001-03-30 09:51:46 +00:00
|
|
|
private:
|
|
|
|
/// Enable/Disable a widget
|
|
|
|
virtual void setWidgetEnabled(Widget * obj, bool enable) = 0;
|
|
|
|
/// Enable/Disable a button
|
|
|
|
virtual void setButtonEnabled(Button * obj, bool enable) = 0;
|
|
|
|
/// Set the Label on the button
|
|
|
|
virtual void setButtonLabel(Button * obj, string const & label) = 0;
|
|
|
|
|
|
|
|
Button * okay_;
|
|
|
|
Button * apply_;
|
|
|
|
Button * cancel_;
|
2001-04-03 14:30:58 +00:00
|
|
|
Button * restore_;
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2001-03-30 09:51:46 +00:00
|
|
|
typedef std::list<Widget *> Widgets;
|
|
|
|
Widgets read_only_;
|
2001-03-15 13:37:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
template <class BP, class GUIBC>
|
2002-10-21 17:38:09 +00:00
|
|
|
class ButtonController: public GUIBC {
|
2001-03-15 13:37:04 +00:00
|
|
|
public:
|
|
|
|
///
|
|
|
|
ButtonController(string const & = _("Cancel"),
|
|
|
|
string const & = _("Close"));
|
|
|
|
///
|
2002-08-16 07:00:35 +00:00
|
|
|
~ButtonController() {}
|
|
|
|
///
|
2001-03-15 13:37:04 +00:00
|
|
|
virtual ButtonPolicy & bp() { return bp_; }
|
|
|
|
protected:
|
|
|
|
///
|
|
|
|
BP bp_;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2002-06-10 17:33:05 +00:00
|
|
|
#include "ButtonController.tmpl"
|
|
|
|
|
2001-03-15 13:37:04 +00:00
|
|
|
#endif // BUTTONCONTROLLER_H
|