]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ButtonControllerBase.C
two patches from john
[lyx.git] / src / frontends / controllers / ButtonControllerBase.C
1 /* This file is part of
2  * ====================================================== 
3  *
4  *           LyX, The Document Processor
5  *
6  *           Copyright 2000-2001 The LyX Team.
7  *
8  * ======================================================
9  *
10  * \file ButtonControllerBase.C
11  * \author Allan Rae
12  */
13
14 #ifdef __GNUG__
15 #pragma implementation
16 #endif
17
18 #include <config.h>
19 #include "ButtonControllerBase.h"
20 #include "support/LAssert.h"
21 #include "debug.h" 
22
23
24 ButtonControllerBase::ButtonControllerBase(string const & cancel,
25                                            string const & close)
26         : cancel_label_(cancel), close_label_(close)
27 {}
28
29
30 void ButtonControllerBase::ok()
31 {
32         input(ButtonPolicy::SMI_OKAY);
33 }
34
35
36 void ButtonControllerBase::input(ButtonPolicy::SMInput in)
37 {
38         if (ButtonPolicy::SMI_NOOP == in) return;
39         bp().input(in);
40         refresh();
41 }
42
43
44 void ButtonControllerBase::apply()
45 {
46         input(ButtonPolicy::SMI_APPLY);
47 }
48
49
50 void ButtonControllerBase::cancel()
51 {
52         input(ButtonPolicy::SMI_CANCEL);
53 }
54
55
56 void ButtonControllerBase::restore()
57 {
58         input(ButtonPolicy::SMI_RESTORE);
59 }
60
61
62 void ButtonControllerBase::hide()
63 {
64         input(ButtonPolicy::SMI_HIDE);
65 }
66
67
68 void ButtonControllerBase::valid(bool v)
69 {
70         if (v) {
71                 input(ButtonPolicy::SMI_VALID);
72         } else {
73                 input(ButtonPolicy::SMI_INVALID);
74         }
75 }
76
77
78 void ButtonControllerBase::invalid()
79 {
80         input(ButtonPolicy::SMI_INVALID);
81 }
82
83
84 bool ButtonControllerBase::readOnly(bool ro)
85 {
86         lyxerr[Debug::GUI] << "Setting controller ro: " << ro << std::endl;
87  
88         if (ro) {
89                 bp().input(ButtonPolicy::SMI_READ_ONLY);
90         } else {
91                 bp().input(ButtonPolicy::SMI_READ_WRITE);
92         }
93         refreshReadOnly();
94         refresh();
95         return ro;
96 }
97
98
99 void ButtonControllerBase::readWrite()
100 {
101         readOnly(false);
102 }