]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/xformsBC.C
Implemented controller-view split for FormBibtex.
[lyx.git] / src / frontends / xforms / xformsBC.C
1 /**
2  * \file xformsBC.C
3  * Copyright 2001 the LyX Team
4  * Read the file COPYING
5  *
6  * \author Allan Rae <rae@lyx.org>
7  * \author Angus Leeming <a.leeming@ic.ac.uk>
8  */
9
10 #include <config.h>
11
12 #ifdef __GNUG__
13 #pragma implementation
14 #endif
15
16 #include "xformsBC.h"
17 #include "xforms_helpers.h"
18
19
20 xformsBC::xformsBC(string const & cancel, string const & close)
21         : ButtonControllerBase(cancel, close),
22           okay_(0), apply_(0), cancel_(0), undo_all_(0), read_only_()
23 {}
24
25
26 void xformsBC::refresh()
27 {
28         if (okay_) {
29                 if (bp().buttonStatus(ButtonPolicy::OKAY)) {
30                         setEnabled(okay_, true);
31                 } else {
32                         setEnabled(okay_, false);
33                 }
34         }
35         if (apply_) {
36                 if (bp().buttonStatus(ButtonPolicy::APPLY)) {
37                         setEnabled(apply_, true);
38                 } else {
39                         setEnabled(apply_, false);
40                 }
41         }
42         if (undo_all_) {
43                 if (bp().buttonStatus(ButtonPolicy::UNDO_ALL)) {
44                         setEnabled(undo_all_, true);
45                 } else {
46                         setEnabled(undo_all_, false);
47                 }
48         }
49         if (cancel_) {
50                 if (bp().buttonStatus(ButtonPolicy::CANCEL)) {
51                         fl_set_object_label(cancel_, cancel_label.c_str());
52                 } else {
53                         fl_set_object_label(cancel_, close_label.c_str());
54                 }
55         }
56         if (!read_only_.empty()) {
57                 bool enable = true;
58                 if (bp().isReadOnly()) enable = false;
59  
60                 for (std::list<FL_OBJECT *>::iterator iter = read_only_.begin();
61                      iter != read_only_.end(); ++iter) {
62                         setEnabled(*iter, enable);
63                 }
64         }
65 }