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