3 * \file ControlConnections.h
4 * Read the file COPYING
6 * \author Angus Leeming
8 * Full author contact details are available in file CREDITS
10 * ControlConnections.h contains the definition of three controller classes,
11 * ControlConnectBase, ControlConnectBI and ControlConnectBD.
13 * Together they control the connection/disconnection of signals with the LyX
14 * kernel. Controllers of individual dialogs interacting with the kernel through
15 * signals/slots will all be derived from ControlConnectBI or ControlConnectBD.
17 * A dialog is classed as "Buffer Dependent" if its contents change with the
18 * buffer (document). An example would be the Citation dialog. Such a dialog
19 * would be derived, therefore, from ControlConnectBD.
21 * Conversely, a dialog is "Buffer Independent" if its contents do not change
22 * when the buffer changes. An example would be the Copyright dialog. Such a
23 * dialog is therefore derived from ControlConnectBI.
27 #ifndef CONTROLCONNECTIONS_H
28 #define CONTROLCONNECTIONS_H
34 #include "ControlButtons.h"
36 #include <boost/signals/connection.hpp>
44 /** Base class to control connection/disconnection of signals with the LyX
45 kernel. It is meant to be used solely as the parent class to
46 ControlConnectBI and ControlConnectBD.
48 class ControlConnectBase : public ControlButtons
63 ControlConnectBase(LyXView &, Dialogs &);
64 /// The View may need to know if the buffer is read-only.
65 bool bufferIsReadonly() const;
67 DocTypes docType() const;
70 /// True if the dialog depends on the buffer, else false.
71 virtual bool isBufferDependent() const = 0;
74 virtual void connect();
75 /// Disconnect signals
76 virtual void disconnect();
78 /** Redraw the dialog (on receipt of a Signal indicating, for example,
79 its colors have been re-mapped).
83 /// a wrapper for BufferView::avaliable()
84 bool bufferIsAvailable() const;
85 /// a wrapper for LyXView::view()
86 BufferView * bufferview();
88 BufferView const * bufferview() const;
89 /// a wrapper for LyXView::buffer()
92 Buffer const * buffer() const;
93 /// a wrapper for LyXView::getLyXFunc()
96 LyXFunc const & lyxfunc() const;
101 /// Contains the signals we have to connect to.
104 boost::signals::connection h_;
105 /// Redraw connection.
106 boost::signals::connection r_;
110 /** Base class to control connection/disconnection of signals with the LyX
111 kernel for Buffer Independent dialogs.
112 Such dialogs do not require an update Connection although they may use
113 an update() function which is also supported by the Restore button.
116 class ControlConnectBI : public ControlConnectBase
120 ControlConnectBI(LyXView &, Dialogs &);
124 virtual bool isBufferDependent() const { return false; }
126 virtual void connect();
130 /** Base class to control connection/disconnection of signals with the LyX
131 kernel for Buffer Dependent dialogs.
133 class ControlConnectBD : public ControlConnectBase
137 ControlConnectBD(LyXView &, Dialogs &);
141 virtual bool isBufferDependent() const { return true; }
143 virtual void connect();
144 /// Disconnect signals
145 virtual void disconnect();
148 /** Slot connected to update signal.
149 Bool indicates if a buffer switch took place.
150 Default behaviour is to ignore this and simply update().
152 virtual void updateSlot(bool) { update(); }
153 /// Update connection.
154 boost::signals::connection u_;
157 #endif // CONTROLCONNECTIONS_H