2001-04-17 14:06:11 +00:00
|
|
|
// -*- C++ -*-
|
2002-01-16 14:47:58 +00:00
|
|
|
/*
|
2001-03-30 09:51:46 +00:00
|
|
|
* \file ButtonController.h
|
2002-01-16 14:47:58 +00:00
|
|
|
* Copyright 2002 the LyX Team
|
|
|
|
* Read the file COPYING
|
|
|
|
*
|
2001-03-22 11:24:36 +00:00
|
|
|
* \author Allan Rae, rae@lyx.org
|
2001-03-30 09:51:46 +00:00
|
|
|
* \author Angus Leeming, a.leeming@ic.ac.uk
|
|
|
|
* \author Baruch Even, baruch.even@writeme.com
|
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>
|
|
|
|
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>
|
|
|
|
class ButtonController: public GUIBC
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
///
|
|
|
|
ButtonController(string const & = _("Cancel"),
|
|
|
|
string const & = _("Close"));
|
|
|
|
///
|
|
|
|
virtual ButtonPolicy & bp() { return bp_; }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
///
|
|
|
|
BP bp_;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // BUTTONCONTROLLER_H
|