]> 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 b0337d3fd81a0c6956f4f4824af0ab60a5c89f56..43f7b041a6f13e1cc3abbead0e597366d3277208 100644 (file)
@@ -1,14 +1,9 @@
 // -*- C++ -*-
-/* This file is part of
- * ====================================================== 
- *
- *           LyX, The Document Processor
- *
- *           Copyright 2000-2001 The LyX Team.
- *
- * ======================================================
- *
+/*
  * \file ButtonController.h
+ * 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
 
+
+#include "ButtonControllerBase.h"
+#include "gettext.h"
 #include <list>
 
+/** 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
+ */
 template <class Button, class Widget>
 class GuiBC : public ButtonControllerBase
 {
@@ -39,8 +42,10 @@ public:
        ///
        void eraseReadOnly() { read_only_.clear(); }
 
-       /// Refresh the widgets status.
+       /// 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
@@ -60,50 +65,6 @@ private:
 };
 
 
-template <class Button, class Widget>
-GuiBC<Button, Widget>::GuiBC(string const & cancel, string const & close)
-       : ButtonControllerBase(cancel, close),
-         okay_(0), apply_(0), cancel_(0), restore_(0)
-{}
-
-
-template <class Button, class Widget>
-void GuiBC<Button, Widget>::refresh()
-{
-       if (okay_) {
-               bool const enabled = bp().buttonStatus(ButtonPolicy::OKAY);
-               setButtonEnabled(okay_, enabled);
-       }
-       if (apply_) {
-               bool const enabled = bp().buttonStatus(ButtonPolicy::APPLY);
-               setButtonEnabled(apply_, enabled);
-       }
-       if (restore_) {
-               bool const enabled = bp().buttonStatus(ButtonPolicy::RESTORE);
-               setButtonEnabled(restore_, enabled);
-       }
-       if (cancel_) {
-               bool const enabled = bp().buttonStatus(ButtonPolicy::CANCEL);
-               if (enabled)
-                       setButtonLabel(cancel_, cancel_label_);
-               else
-                       setButtonLabel(cancel_, close_label_);
-       }
-
-       // Enable/Disable read-only handled widgets.
-       if (!read_only_.empty()) {
-               bool const enable = !bp().isReadOnly();
-
-               Widgets::const_iterator end = read_only_.end();
-               Widgets::const_iterator iter = read_only_.begin();
-               for (; iter != end; ++iter) {
-                       setWidgetEnabled(*iter, enable);
-               }
-       }
-
-}
-
-
 template <class BP, class GUIBC>
 class ButtonController: public GUIBC
 {
@@ -120,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