]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ControlConnections.C
This file is part of LyX, the document processor.
[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 ControlConnectBase::ControlConnectBase(LyXView & lv, Dialogs & d)
30         : lv_(lv), d_(d)
31 {}
32
33
34 void ControlConnectBase::connect()
35 {
36         r_ = d_.redrawGUI().
37                 connect(boost::bind(&ControlConnectBase::redraw, this));
38 }
39
40 void ControlConnectBase::disconnect()
41 {
42         h_.disconnect();
43         r_.disconnect();
44 }
45
46
47 void ControlConnectBase::redraw()
48 {
49         view().redraw();
50 }
51
52
53 bool ControlConnectBase::bufferIsReadonly() const
54 {
55         if (!lv_.buffer())
56                 return true;
57
58         return lv_.buffer()->isReadonly();
59 }
60
61
62 bool ControlConnectBase::bufferIsAvailable() const
63 {
64         if (!lv_.view())
65                 return false;
66
67         return lv_.view()->available();
68 }
69
70
71 BufferView * ControlConnectBase::bufferview()
72 {
73         return lv_.view().get();
74 }
75
76
77 BufferView const * ControlConnectBase::bufferview() const
78 {
79         return lv_.view().get();
80 }
81
82
83 Buffer * ControlConnectBase::buffer()
84 {
85         return lv_.buffer();
86 }
87
88
89 Buffer const * ControlConnectBase::buffer() const
90 {
91         return lv_.buffer();
92 }
93
94
95 LyXFunc & ControlConnectBase::lyxfunc()
96 {
97         return lv_.getLyXFunc();
98 }
99
100
101 LyXFunc const & ControlConnectBase::lyxfunc() const
102 {
103         return lv_.getLyXFunc();
104 }
105
106
107 ControlConnectBase::DocTypes ControlConnectBase::docType() const
108 {
109         if (!lv_.buffer())
110                 return LATEX;
111
112         if (lv_.buffer()->isLatex())
113                 return LATEX;
114         else if (lv_.buffer()->isLiterate())
115                 return LITERATE;
116         else if (lv_.buffer()->isLinuxDoc())
117                 return LINUXDOC;
118         /* else if (lv_.buffer()->isDocBook()) */
119                 return DOCBOOK;
120 }
121
122
123 ControlConnectBI::ControlConnectBI(LyXView & lv, Dialogs & d)
124         : ControlConnectBase(lv, d)
125 {}
126
127
128 void ControlConnectBI::connect()
129 {
130         h_ = d_.hideAll.connect(boost::bind(&ControlConnectBI::hide, this));
131         ControlConnectBase::connect();
132 }
133
134 ControlConnectBD::ControlConnectBD(LyXView & lv, Dialogs & d)
135         : ControlConnectBase(lv, d)
136 {}
137
138
139 void ControlConnectBD::connect()
140 {
141         u_ = d_.updateBufferDependent.
142                 connect(boost::bind(&ControlConnectBD::updateSlot, this, _1));
143         h_ = d_.hideBufferDependent.
144                 connect(boost::bind(&ControlConnectBD::hide, this));
145         ControlConnectBase::connect();
146 }
147
148 void ControlConnectBD::disconnect()
149 {
150         u_.disconnect();
151         ControlConnectBase::disconnect();
152 }