* Licence details can be found in the file COPYING.
*
* \author Allan Rae
- * \author Angus Leeming
- * \author Baruch Even
*
- * Full author contact details are available in file CREDITS
+ * Full author contact details are available in file CREDITS.
*/
#ifndef BUTTONCONTROLLER_H
#define BUTTONCONTROLLER_H
-#include "ButtonControllerBase.h"
-#include "gettext.h"
-#include <list>
+#include "ButtonPolicies.h"
-/** 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
+#include "support/std_string.h"
+#include <boost/scoped_ptr.hpp>
+
+
+class BCView;
+
+
+/** \c ButtonController controls the activation of the OK, Apply and
+ * Cancel buttons.
+ *
+ * It actually supports 4 buttons in all and it's up to the user to decide on
+ * the activation policy and which buttons correspond to which output of the
+ * state machine.
*/
-template <class Button, class Widget>
-class GuiBC : public ButtonControllerBase
-{
+
+class ButtonController : boost::noncopyable {
public:
- ///
- GuiBC(string const & cancel, string const & close);
+ //@{
+ /** Methods to set and get the GUI view (containing the actual
+ * button widgets.
+ * \param ptr is owned by the ButtonController.
+ */
+ void view(BCView * ptr);
+ BCView & view() const;
+ //@}
+
+ //@{
+ /** Methods to set and get the ButtonPolicy.
+ * \param ptr is owned by the ButtonController.
+ */
+ void bp(ButtonPolicy * ptr);
+ ButtonPolicy & bp() const;
+ //@}
///
- void setOK(Button * obj) { okay_ = obj; }
- ///
- void setApply(Button * obj) { apply_ = obj; }
- ///
- void setCancel(Button * obj) { cancel_ = obj; }
- ///
- void setRestore(Button * obj) { restore_ = obj; }
- ///
- void addReadOnly(Widget * obj) { read_only_.push_back(obj); }
- ///
- void eraseReadOnly() { read_only_.clear(); }
+ void input(ButtonPolicy::SMInput) const;
- /// Refresh the status of the Ok, Apply, Restore, Cancel buttons.
- void refresh();
- /// Refresh the status of any widgets in the read_only list
- void refreshReadOnly();
+ //@{
+ /// Tell the BC that a particular button has been pressed.
+ void ok() const;
+ void apply() const;
+ void cancel() const;
+ void restore() const;
+ //@}
-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_;
- Button * restore_;
-
- typedef std::list<Widget *> Widgets;
- Widgets read_only_;
-};
+ /// Tell the BC that the dialog is being hidden
+ void hide() const;
+ /**Refresh the activation state of the Ok, Apply, Close and
+ * Restore buttons.
+ */
+ void refresh() const;
-template <class BP, class GUIBC>
-class ButtonController: public GUIBC
-{
-public:
- ///
- ButtonController(string const & = _("Cancel"),
- string const & = _("Close"));
- ///
- ~ButtonController() {}
- ///
- virtual ButtonPolicy & bp() { return bp_; }
+ /** 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;
-protected:
- ///
- BP bp_;
-};
+ /** 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;
-#include "ButtonController.tmpl"
+private:
+ boost::scoped_ptr<ButtonPolicy> bp_;
+ boost::scoped_ptr<BCView> view_;
+};
#endif // BUTTONCONTROLLER_H