2 /* This file is part of
3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright 2001 The LyX Team.
9 * ======================================================
11 * \file ControlConnections.h
12 * \author Angus Leeming <a.leeming@ic.ac.uk>
14 * ControlConnections.h contains the definition of three controller classes,
15 * ControlConnectBase, ControlConnectBI and ControlConnectBD.
17 * Together they control the connection/disconnection of signals with the LyX
18 * kernel. Controllers of individual dialogs interacting with the kernel through
19 * signals/slots will all be derived from ControlConnectBI or ControlConnectBD.
21 * A dialog is classed as "Buffer Dependent" if its contents change with the
22 * buffer (document). An example would be the Citation dialog. Such a dialog
23 * would be derived, therefore, from ControlConnectBD.
25 * Conversely, a dialog is "Buffer Independent" if its contents do not change
26 * when the buffer changes. An example would be the Copyright dialog. Such a
27 * dialog is therefore derived from ControlConnectBI.
31 #ifndef CONTROLCONNECTIONS_H
32 #define CONTROLCONNECTIONS_H
38 #include "ControlButtons.h"
40 #include <boost/signals/connection.hpp>
45 /** Base class to control connection/disconnection of signals with the LyX
46 kernel. It is meant to be used solely as the parent class to
47 ControlConnectBI and ControlConnectBD.
49 class ControlConnectBase : public ControlButtons
64 ControlConnectBase(LyXView &, Dialogs &);
65 /// The View may need to know if the buffer is read-only.
66 bool isReadonly() const;
68 DocTypes docType() const;
71 /// True if the dialog depends on the buffer, else false.
72 virtual bool isBufferDependent() const = 0;
75 virtual void connect();
76 /// Disconnect signals
77 virtual void disconnect();
79 /** Redraw the dialog (on receipt of a Signal indicating, for example,
80 its colors have been re-mapped).
84 /// Get at the kernel Dispatch methods we need to apply() parameters.
86 /// Contains the signals we have to connect to.
89 boost::signals::connection h_;
90 /// Redraw connection.
91 boost::signals::connection r_;
95 /** Base class to control connection/disconnection of signals with the LyX
96 kernel for Buffer Independent dialogs.
97 Such dialogs do not require an update Connection although they may use
98 an update() function which is also supported by the Restore button.
101 class ControlConnectBI : public ControlConnectBase
105 ControlConnectBI(LyXView &, Dialogs &);
109 virtual bool isBufferDependent() const { return false; }
111 virtual void connect();
115 /** Base class to control connection/disconnection of signals with the LyX
116 kernel for Buffer Dependent dialogs.
118 class ControlConnectBD : public ControlConnectBase
122 ControlConnectBD(LyXView &, Dialogs &);
126 virtual bool isBufferDependent() const { return true; }
128 virtual void connect();
129 /// Disconnect signals
130 virtual void disconnect();
133 /** Slot connected to update signal.
134 Bool indicates if a buffer switch took place.
135 Default behaviour is to ignore this and simply update().
137 virtual void updateSlot(bool) { update(); }
138 /// Update connection.
139 boost::signals::connection u_;
142 #endif // CONTROLCONNECTIONS_H