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