3 * \file ButtonController.tmpl
4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
8 * \author Angus Leeming
11 * Full author contact details are available in file CREDITS
13 * GuiBC is a base class and so these templatised methods will be
14 * instantiated if this file is #included in the derived classes' .C file.
15 * see, e.g., xforms/xformsBC.C
18 #include "ButtonController.h"
21 template <class Button, class Widget>
22 GuiBC<Button, Widget>::GuiBC(string const & cancel, string const & close)
23 : ButtonControllerBase(cancel, close),
24 okay_(0), apply_(0), cancel_(0), restore_(0)
28 template <class Button, class Widget>
29 void GuiBC<Button, Widget>::refresh()
31 lyxerr[Debug::GUI] << "Calling BC refresh()" << std::endl;
33 bool const all_valid = checkWidgets();
37 all_valid && bp().buttonStatus(ButtonPolicy::OKAY);
38 setButtonEnabled(okay_, enabled);
42 all_valid && bp().buttonStatus(ButtonPolicy::APPLY);
43 setButtonEnabled(apply_, enabled);
47 all_valid && bp().buttonStatus(ButtonPolicy::RESTORE);
48 setButtonEnabled(restore_, enabled);
51 bool const enabled = bp().buttonStatus(ButtonPolicy::CANCEL);
53 setButtonLabel(cancel_, cancel_label_);
55 setButtonLabel(cancel_, close_label_);
60 template <class Button, class Widget>
61 void GuiBC<Button, Widget>::refreshReadOnly()
63 if (read_only_.empty()) return;
65 bool const enable = !bp().isReadOnly();
67 typename Widgets::const_iterator end = read_only_.end();
68 typename Widgets::const_iterator iter = read_only_.begin();
69 for (; iter != end; ++iter) {
70 setWidgetEnabled(*iter, enable);
75 template <class BP, class GUIBC>
76 ButtonController<BP, GUIBC>::ButtonController(string const & cancel,
78 : GUIBC(cancel, close)