3 * \file ControlConnections.h
4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Angus Leeming
9 * Full author contact details are available in file CREDITS.
11 * ControlConnections.h contains the definition of three controller classes,
12 * ControlConnectBase, ControlConnectBI and ControlConnectBD.
14 * Together they control the connection/disconnection of signals with the LyX
15 * kernel. Controllers of individual dialogs interacting with the kernel through
16 * signals/slots will all be derived from ControlConnectBI or ControlConnectBD.
18 * A dialog is classed as "Buffer Dependent" if its contents change with the
19 * buffer (document). An example would be the Citation dialog. Such a dialog
20 * would be derived, therefore, from ControlConnectBD.
22 * Conversely, a dialog is "Buffer Independent" if its contents do not change
23 * when the buffer changes. An example would be the Copyright dialog. Such a
24 * dialog is therefore derived from ControlConnectBI.
28 #ifndef CONTROLCONNECTIONS_H
29 #define CONTROLCONNECTIONS_H
32 #include "ControlButtons.h"
34 #include <boost/signals/connection.hpp>
42 /** Base class to control connection/disconnection of signals with the LyX
43 kernel. It is meant to be used solely as the parent class to
44 ControlConnectBI and ControlConnectBD.
46 class ControlConnectBase : public ControlButtons {
60 ControlConnectBase(LyXView &, Dialogs &);
61 /// The View may need to know if the buffer is read-only.
62 bool bufferIsReadonly() const;
64 DocTypes docType() const;
66 /// True if the dialog depends on the buffer, else false.
67 virtual bool isBufferDependent() const = 0;
70 virtual void connect();
71 /// Disconnect signals
72 virtual void disconnect();
74 /** Redraw the dialog (on receipt of a Signal indicating, for example,
75 its colors have been re-mapped).
79 /// a wrapper for BufferView::avaliable()
80 bool bufferIsAvailable() const;
81 /// a wrapper for LyXView::view()
82 BufferView * bufferview();
84 BufferView const * bufferview() const;
85 /// a wrapper for LyXView::buffer()
88 Buffer const & buffer() const;
89 /// a wrapper for LyXView::getLyXFunc()
92 LyXFunc const & lyxfunc() const;
96 /// Contains the signals we have to connect to.
99 boost::signals::connection h_;
100 /// Redraw connection.
101 boost::signals::connection r_;
105 /** Base class to control connection/disconnection of signals with the LyX
106 kernel for Buffer Independent dialogs.
107 Such dialogs do not require an update Connection although they may use
108 an update() function which is also supported by the Restore button.
111 class ControlConnectBI : public ControlConnectBase {
114 ControlConnectBI(LyXView &, Dialogs &);
117 virtual bool isBufferDependent() const { return false; }
119 virtual void connect();
123 /** Base class to control connection/disconnection of signals with the LyX
124 kernel for Buffer Dependent dialogs.
126 class ControlConnectBD : public ControlConnectBase {
129 ControlConnectBD(LyXView &, Dialogs &);
132 virtual bool isBufferDependent() const { return true; }
134 virtual void connect();
135 /// Disconnect signals
136 virtual void disconnect();
138 /** Slot connected to update signal.
139 Bool indicates if a buffer switch took place.
140 Default behaviour is to ignore this and simply update().
142 virtual void updateSlot(bool) { update(); }
143 /// Update connection.
144 boost::signals::connection u_;
147 #endif // CONTROLCONNECTIONS_H