]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/controllers/ButtonController.h
Add the missing template instatiations!
[lyx.git] / src / frontends / controllers / ButtonController.h
index 73dae9f694099f855f451bdefd3826764a23c1d1..43f7b041a6f13e1cc3abbead0e597366d3277208 100644 (file)
@@ -1,82 +1,67 @@
 // -*- C++ -*-
-/* This file is part of
- * ====================================================== 
- *
- *           LyX, The Document Processor
- *
- *           Copyright 2000 The LyX Team.
- *
- * ======================================================
- *
+/*
  * \file ButtonController.h
- * \author Allan Rae
+ * Copyright 2002 the LyX Team
+ * Read the file COPYING
+ *
+ * \author Allan Rae, rae@lyx.org
+ * \author Angus Leeming, a.leeming@ic.ac.uk
+ * \author Baruch Even, baruch.even@writeme.com
  */
 
 #ifndef BUTTONCONTROLLER_H
 #define BUTTONCONTROLLER_H
 
-#ifdef __GNUG__
-#pragma interface
-#endif
 
-#include "ButtonPolicies.h"
-#include "LString.h"
+#include "ButtonControllerBase.h"
 #include "gettext.h"
+#include <list>
 
-/** Abstract base class for a ButtonController
-
- * Controls the activation of the OK, Apply and Cancel buttons.
- * 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.
- * Author: Allan Rae <rae@lyx.org>.
- * This abstract base class stripped of xforms-specific code by
- * Angus Leeming <a.leeming@ic.ac.uk>
+/** 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
  */
-class ButtonControllerBase : public noncopyable
+template <class Button, class Widget>
+class GuiBC : public ButtonControllerBase
 {
 public:
-       /** Constructor.
-           The cancel/close label entries are _not_ managed within the class
-           thereby allowing you to reassign at will and to use static labels.
-           It also means if you really don't want to have the Cancel button
-           label be different when there is nothing changed in the dialog then
-           you can just assign "Cancel" to both labels.  Or even reuse this
-           class for something completely different.
-        */
-       ButtonControllerBase(string const & cancel, string const & close);
-       ///
-       virtual ~ButtonControllerBase() {}
-       ///
-       virtual void refresh() = 0;
-       ///
-       virtual ButtonPolicy & bp() = 0;
-       ///
-       virtual void input(ButtonPolicy::SMInput);
-       ///
-       void ok();
        ///
-       void apply();
-       ///
-       void cancel();
-       ///
-       void undoAll();
-       ///
-       void hide();
-       /// Passthrough function -- returns its input value
-       bool readOnly(bool = true);
+       GuiBC(string const & cancel, string const & close);
+
+       /// 
+       void setOK(Button * obj) { okay_ = obj; }
+       /// 
+       void setApply(Button * obj) { apply_ = obj; }
+       /// 
+       void setCancel(Button * obj) { cancel_ = obj; }
        ///
-       void readWrite();
+       void setRestore(Button * obj) { restore_ = obj; }
        ///
-       void valid(bool = true);
+       void addReadOnly(Widget * obj) { read_only_.push_back(obj); }
        ///
-       void invalid();
+       void eraseReadOnly() { read_only_.clear(); }
 
-protected:
-       ///
-       string cancel_label;
-       ///
-       string close_label;     
+       /// 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();
+
+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_;
 };
 
 
@@ -96,10 +81,4 @@ protected:
 };
 
 
-template <class BP, class GUIBC>
-ButtonController<BP, GUIBC>::ButtonController(string const & cancel,
-                                             string const & close)
-       : GUIBC(cancel, close)
-{}
-
 #endif // BUTTONCONTROLLER_H