]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ButtonControllerBase.C
dont use pragma impementation and interface anymore
[lyx.git] / src / frontends / controllers / ButtonControllerBase.C
1 /**
2  * \file ButtonControllerBase.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Allan Rae
7  *
8  * Full author contact details are available in file CREDITS
9  */
10
11
12 #include <config.h>
13 #include "ButtonControllerBase.h"
14 #include "support/LAssert.h"
15 #include "debug.h"
16
17
18 CheckedWidget::~CheckedWidget()
19 {}
20
21
22 ButtonControllerBase::ButtonControllerBase(string const & cancel,
23                                            string const & close)
24         : cancel_label_(cancel), close_label_(close)
25 {}
26
27
28 void ButtonControllerBase::ok()
29 {
30         input(ButtonPolicy::SMI_OKAY);
31 }
32
33
34 void ButtonControllerBase::input(ButtonPolicy::SMInput in)
35 {
36         if (ButtonPolicy::SMI_NOOP == in)
37                 return;
38         bp().input(in);
39         refresh();
40 }
41
42
43 void ButtonControllerBase::apply()
44 {
45         input(ButtonPolicy::SMI_APPLY);
46 }
47
48
49 void ButtonControllerBase::cancel()
50 {
51         input(ButtonPolicy::SMI_CANCEL);
52 }
53
54
55 void ButtonControllerBase::restore()
56 {
57         input(ButtonPolicy::SMI_RESTORE);
58 }
59
60
61 void ButtonControllerBase::hide()
62 {
63         input(ButtonPolicy::SMI_HIDE);
64 }
65
66
67 void ButtonControllerBase::valid(bool v)
68 {
69         if (v) {
70                 input(ButtonPolicy::SMI_VALID);
71         } else {
72                 input(ButtonPolicy::SMI_INVALID);
73         }
74 }
75
76
77 void ButtonControllerBase::invalid()
78 {
79         input(ButtonPolicy::SMI_INVALID);
80 }
81
82
83 bool ButtonControllerBase::readOnly(bool ro)
84 {
85         lyxerr[Debug::GUI] << "Setting controller ro: " << ro << std::endl;
86
87         if (ro) {
88                 bp().input(ButtonPolicy::SMI_READ_ONLY);
89         } else {
90                 bp().input(ButtonPolicy::SMI_READ_WRITE);
91         }
92         refreshReadOnly();
93         refresh();
94         return ro;
95 }
96
97
98 void ButtonControllerBase::readWrite()
99 {
100         readOnly(false);
101 }
102
103
104 void ButtonControllerBase::addCheckedWidget(CheckedWidget * ptr)
105 {
106         if (ptr)
107                 checked_widgets.push_back(checked_widget_ptr(ptr));
108 }
109
110
111 bool ButtonControllerBase::checkWidgets()
112 {
113         bool valid = true;
114
115         checked_widget_list::const_iterator it  = checked_widgets.begin();
116         checked_widget_list::const_iterator end = checked_widgets.end();
117
118         for (; it != end; ++it) {
119                 valid &= (*it)->check();
120         }
121
122         // return valid status after checking ALL widgets
123         return valid;
124 }