]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ButtonController.tmpl
to much stuff for my liking...
[lyx.git] / src / frontends / controllers / ButtonController.tmpl
1 // -*- C++ -*-
2 /*
3  * \file ButtonController.tmpl
4  * Copyright 2002 the LyX Team
5  * Read the file COPYING
6  *
7  * \author Allan Rae, rae@lyx.org
8  * \author Angus Leeming, a.leeming@ic.ac.uk
9  * \author Baruch Even, baruch.even@writeme.com
10  *
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
14  */
15
16 #include "ButtonController.h"
17 #include "debug.h" 
18
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)
23 {}
24
25
26 template <class Button, class Widget>
27 void GuiBC<Button, Widget>::refresh()
28 {
29         lyxerr[Debug::GUI] << "Calling BC refresh()" << std::endl; 
30  
31         if (okay_) {
32                 bool const enabled = bp().buttonStatus(ButtonPolicy::OKAY);
33                 setButtonEnabled(okay_, enabled);
34         }
35         if (apply_) {
36                 bool const enabled = bp().buttonStatus(ButtonPolicy::APPLY);
37                 setButtonEnabled(apply_, enabled);
38         }
39         if (restore_) {
40                 bool const enabled = bp().buttonStatus(ButtonPolicy::RESTORE);
41                 setButtonEnabled(restore_, enabled);
42         }
43         if (cancel_) {
44                 bool const enabled = bp().buttonStatus(ButtonPolicy::CANCEL);
45                 if (enabled)
46                         setButtonLabel(cancel_, cancel_label_);
47                 else
48                         setButtonLabel(cancel_, close_label_);
49         }
50 }
51
52
53 template <class Button, class Widget>
54 void GuiBC<Button, Widget>::refreshReadOnly()
55 {
56         if (read_only_.empty()) return;
57
58         bool const enable = !bp().isReadOnly();
59
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);
64         }
65 }
66
67
68 template <class BP, class GUIBC>
69 ButtonController<BP, GUIBC>::ButtonController(string const & cancel,
70                                               string const & close)
71         : GUIBC(cancel, close)
72 {}