]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/BCView.tmpl
Add a buffer_path arg to InsetGraphicsMailer's params2string, string2params.
[lyx.git] / src / frontends / controllers / BCView.tmpl
1 // -*- C++ -*-
2 /**
3  * \file ButtonController.tmpl
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Allan Rae
8  * \author Angus Leeming
9  * \author Baruch Even
10  *
11  * Full author contact details are available in file CREDITS
12  *
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
16  */
17
18 #include "BCView.h"
19 #include "ButtonPolicies.h"
20 #include "debug.h"
21
22 template <class Button, class Widget>
23 GuiBC<Button, Widget>::GuiBC(ButtonController const & parent,
24                              string const & cancel, string const & close)
25         : BCView(parent),
26           cancel_label_(cancel), close_label_(close),
27           okay_(0), apply_(0), cancel_(0), restore_(0)
28 {}
29
30
31 template <class Button, class Widget>
32 void GuiBC<Button, Widget>::refresh() const
33 {
34         lyxerr[Debug::GUI] << "Calling BC refresh()" << std::endl;
35
36         bool const all_valid = checkWidgets();
37
38         if (okay_) {
39                 bool const enabled =
40                         all_valid && bp().buttonStatus(ButtonPolicy::OKAY);
41                 setButtonEnabled(okay_, enabled);
42         }
43         if (apply_) {
44                 bool const enabled =
45                         all_valid && bp().buttonStatus(ButtonPolicy::APPLY);
46                 setButtonEnabled(apply_, enabled);
47         }
48         if (restore_) {
49                 bool const enabled =
50                         all_valid && bp().buttonStatus(ButtonPolicy::RESTORE);
51                 setButtonEnabled(restore_, enabled);
52         }
53         if (cancel_) {
54                 bool const enabled = bp().buttonStatus(ButtonPolicy::CANCEL);
55                 if (enabled)
56                         setButtonLabel(cancel_, cancel_label_);
57                 else
58                         setButtonLabel(cancel_, close_label_);
59         }
60 }
61
62
63 template <class Button, class Widget>
64 void GuiBC<Button, Widget>::refreshReadOnly() const
65 {
66         if (read_only_.empty()) return;
67
68         bool const enable = !bp().isReadOnly();
69
70         typename Widgets::const_iterator end = read_only_.end();
71         typename Widgets::const_iterator iter = read_only_.begin();
72         for (; iter != end; ++iter) {
73                 setWidgetEnabled(*iter, enable);
74         }
75 }