]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ButtonController.tmpl
Really dull and boring header shit
[lyx.git] / src / frontends / controllers / ButtonController.tmpl
1 // -*- C++ -*-
2 /**
3  * \file ButtonController.tmpl
4  * Read the file COPYING
5  *
6  * \author Allan Rae
7  * \author Angus Leeming 
8  * \author Baruch Even
9  *
10  * Full author contact details are available in file CREDITS
11  *
12  * GuiBC is a base class and so these templatised methods will be
13  * instantiated if this file is #included in the derived classes' .C file.
14  * see, e.g., xforms/xformsBC.C
15  */
16
17 #include "ButtonController.h"
18 #include "debug.h" 
19
20 template <class Button, class Widget>
21 GuiBC<Button, Widget>::GuiBC(string const & cancel, string const & close)
22         : ButtonControllerBase(cancel, close),
23           okay_(0), apply_(0), cancel_(0), restore_(0)
24 {}
25
26
27 template <class Button, class Widget>
28 void GuiBC<Button, Widget>::refresh()
29 {
30         lyxerr[Debug::GUI] << "Calling BC refresh()" << std::endl; 
31  
32         if (okay_) {
33                 bool const enabled = bp().buttonStatus(ButtonPolicy::OKAY);
34                 setButtonEnabled(okay_, enabled);
35         }
36         if (apply_) {
37                 bool const enabled = bp().buttonStatus(ButtonPolicy::APPLY);
38                 setButtonEnabled(apply_, enabled);
39         }
40         if (restore_) {
41                 bool const enabled = bp().buttonStatus(ButtonPolicy::RESTORE);
42                 setButtonEnabled(restore_, enabled);
43         }
44         if (cancel_) {
45                 bool const enabled = bp().buttonStatus(ButtonPolicy::CANCEL);
46                 if (enabled)
47                         setButtonLabel(cancel_, cancel_label_);
48                 else
49                         setButtonLabel(cancel_, close_label_);
50         }
51 }
52
53
54 template <class Button, class Widget>
55 void GuiBC<Button, Widget>::refreshReadOnly()
56 {
57         if (read_only_.empty()) return;
58
59         bool const enable = !bp().isReadOnly();
60
61         typename Widgets::const_iterator end = read_only_.end();
62         typename Widgets::const_iterator iter = read_only_.begin();
63         for (; iter != end; ++iter) {
64                 setWidgetEnabled(*iter, enable);
65         }
66 }
67
68
69 template <class BP, class GUIBC>
70 ButtonController<BP, GUIBC>::ButtonController(string const & cancel,
71                                               string const & close)
72         : GUIBC(cancel, close)
73 {}