3 * \file ButtonController.tmpl
4 * Copyright 2002 the LyX Team
5 * Read the file COPYING
7 * \author Allan Rae, rae@lyx.org
8 * \author Angus Leeming, a.leeming@ic.ac.uk
9 * \author Baruch Even, baruch.even@writeme.com
11 * GuiBC is a base class and so these templatised methods will be
12 * instantiated if this file is #included in the derived classes' .C file.
13 * see, e.g., xforms/xformsBC.C
16 #include "ButtonController.h"
19 template <class Button, class Widget>
20 GuiBC<Button, Widget>::GuiBC(string const & cancel, string const & close)
21 : ButtonControllerBase(cancel, close),
22 okay_(0), apply_(0), cancel_(0), restore_(0)
26 template <class Button, class Widget>
27 void GuiBC<Button, Widget>::refresh()
29 lyxerr[Debug::GUI] << "Calling BC refresh()" << std::endl;
32 bool const enabled = bp().buttonStatus(ButtonPolicy::OKAY);
33 setButtonEnabled(okay_, enabled);
36 bool const enabled = bp().buttonStatus(ButtonPolicy::APPLY);
37 setButtonEnabled(apply_, enabled);
40 bool const enabled = bp().buttonStatus(ButtonPolicy::RESTORE);
41 setButtonEnabled(restore_, enabled);
44 bool const enabled = bp().buttonStatus(ButtonPolicy::CANCEL);
46 setButtonLabel(cancel_, cancel_label_);
48 setButtonLabel(cancel_, close_label_);
53 template <class Button, class Widget>
54 void GuiBC<Button, Widget>::refreshReadOnly()
56 if (read_only_.empty()) return;
58 bool const enable = !bp().isReadOnly();
60 typename Widgets::const_iterator end = read_only_.end();
61 typename Widgets::const_iterator iter = read_only_.begin();
62 for (; iter != end; ++iter) {
63 setWidgetEnabled(*iter, enable);
68 template <class BP, class GUIBC>
69 ButtonController<BP, GUIBC>::ButtonController(string const & cancel,
71 : GUIBC(cancel, close)