]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ControlConnections.C
prefs/tabular MVC work
[lyx.git] / src / frontends / controllers / ControlConnections.C
1 /**
2  * \file ControlConnections.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Angus Leeming
7  *
8  * Full author contact details are available in file CREDITS
9  */
10
11 #include <config.h>
12
13 #ifdef __GNUG__
14 #pragma implementation
15 #endif
16
17 #include "ControlConnections.h"
18
19 #include "ViewBase.h"
20
21 #include "buffer.h"
22 #include "BufferView.h"
23
24 #include "frontends/Dialogs.h"
25 #include "frontends/LyXView.h"
26
27 #include <boost/bind.hpp>
28
29
30 ControlConnectBase::ControlConnectBase(LyXView & lv, Dialogs & d)
31         : lv_(lv), d_(d)
32 {}
33
34
35 void ControlConnectBase::connect()
36 {
37         r_ = d_.redrawGUI().
38                 connect(boost::bind(&ControlConnectBase::redraw, this));
39 }
40
41 void ControlConnectBase::disconnect()
42 {
43         h_.disconnect();
44         r_.disconnect();
45 }
46
47
48 void ControlConnectBase::redraw()
49 {
50         view().redraw();
51 }
52
53
54 bool ControlConnectBase::bufferIsReadonly() const
55 {
56         if (!lv_.buffer())
57                 return true;
58
59         return lv_.buffer()->isReadonly();
60 }
61
62
63 bool ControlConnectBase::bufferIsAvailable() const
64 {
65         if (!lv_.view())
66                 return false;
67
68         return lv_.view()->available();
69 }
70
71
72 BufferView * ControlConnectBase::bufferview()
73 {
74         return lv_.view().get();
75 }
76
77
78 BufferView const * ControlConnectBase::bufferview() const
79 {
80         return lv_.view().get();
81 }
82
83
84 Buffer * ControlConnectBase::buffer()
85 {
86         return lv_.buffer();
87 }
88
89
90 Buffer const * ControlConnectBase::buffer() const
91 {
92         return lv_.buffer();
93 }
94
95
96 LyXFunc & ControlConnectBase::lyxfunc()
97 {
98         return lv_.getLyXFunc();
99 }
100
101
102 LyXFunc const & ControlConnectBase::lyxfunc() const
103 {
104         return lv_.getLyXFunc();
105 }
106
107
108 ControlConnectBase::DocTypes ControlConnectBase::docType() const
109 {
110         if (!lv_.buffer())
111                 return LATEX;
112
113         if (lv_.buffer()->isLatex())
114                 return LATEX;
115         else if (lv_.buffer()->isLiterate())
116                 return LITERATE;
117         else if (lv_.buffer()->isLinuxDoc())
118                 return LINUXDOC;
119         /* else if (lv_.buffer()->isDocBook()) */
120                 return DOCBOOK;
121 }
122
123
124 ControlConnectBI::ControlConnectBI(LyXView & lv, Dialogs & d)
125         : ControlConnectBase(lv, d)
126 {}
127
128
129 void ControlConnectBI::connect()
130 {
131         h_ = d_.hideAll.connect(boost::bind(&ControlConnectBI::hide, this));
132         ControlConnectBase::connect();
133 }
134
135 ControlConnectBD::ControlConnectBD(LyXView & lv, Dialogs & d)
136         : ControlConnectBase(lv, d)
137 {}
138
139
140 void ControlConnectBD::connect()
141 {
142         u_ = d_.updateBufferDependent.
143                 connect(boost::bind(&ControlConnectBD::updateSlot, this, _1));
144         h_ = d_.hideBufferDependent.
145                 connect(boost::bind(&ControlConnectBD::hide, this));
146         ControlConnectBase::connect();
147 }
148
149 void ControlConnectBD::disconnect()
150 {
151         u_.disconnect();
152         ControlConnectBase::disconnect();
153 }