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"
43 /** Base class to control connection/disconnection of signals with the LyX
44 kernel. It is meant to be used solely as the parent class to
45 ControlConnectBI and ControlConnectBD.
47 class ControlConnectBase : public ControlButtons
62 ControlConnectBase(LyXView &, Dialogs &);
63 /// The View may need to know if the buffer is read-only.
64 bool isReadonly() const;
66 DocTypes docType() const;
69 /// True if the dialog depends on the buffer, else false.
70 virtual bool isBufferDependent() const = 0;
73 virtual void connect();
74 /// Disconnect signals
75 virtual void disconnect();
77 /** Redraw the dialog (on receipt of a Signal indicating, for example,
78 its colors have been re-mapped).
82 /// Get at the kernel Dispatch methods we need to apply() parameters.
84 /// Contains the signals we have to connect to.
88 /// Redraw connection.
93 /** Base class to control connection/disconnection of signals with the LyX
94 kernel for Buffer Independent dialogs.
95 Such dialogs do not require an update Connection although they may use
96 an update() function which is also supported by the Restore button.
99 class ControlConnectBI : public ControlConnectBase
103 ControlConnectBI(LyXView &, Dialogs &);
107 virtual bool isBufferDependent() const { return false; }
109 virtual void connect();
113 /** Base class to control connection/disconnection of signals with the LyX
114 kernel for Buffer Dependent dialogs.
116 class ControlConnectBD : public ControlConnectBase
120 ControlConnectBD(LyXView &, Dialogs &);
124 virtual bool isBufferDependent() const { return true; }
126 virtual void connect();
127 /// Disconnect signals
128 virtual void disconnect();
131 /** Slot connected to update signal.
132 Bool indicates if a buffer switch took place.
133 Default behaviour is to ignore this and simply update().
135 virtual void updateSlot(bool) { update(); }
136 /// Update connection.
140 #endif // CONTROLCONNECTIONS_H