]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ControlConnections.C
* Constify Buffer::getLabelList.
[lyx.git] / src / frontends / controllers / ControlConnections.C
1 /* This file is part of
2  * ======================================================
3  *
4  *           LyX, The Document Processor
5  *
6  *           Copyright 2001 The LyX Team.
7  *
8  * ======================================================
9  *
10  * \file ControlConnections.C
11  * \author Angus Leeming <a.leeming@ic.ac.uk>
12  */
13
14 #include <config.h>
15
16 #ifdef __GNUG__
17 #pragma implementation
18 #endif
19
20 #include "ControlConnections.h"
21 #include "ViewBase.h"
22 #include "Dialogs.h"
23 #include "buffer.h"
24 #include "BufferView.h"
25
26 #include "frontends/LyXView.h"
27
28 #include <boost/bind.hpp>
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 }