2 /* This file is part of
3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright 2000 The LyX Team.
9 * ======================================================
11 * \file ControlConnections.h
12 * \author Angus Leeming <a.leeming@ic.ac.uk>
15 #ifndef CONTROLCONNECTIONS_H
16 #define CONTROLCONNECTIONS_H
22 #include "ControlBase.h"
24 /** Base class to control connection/disconnection of signals with the LyX
25 kernel. It is meant to be used solely as the parent class to
26 ControlConnectBI and ControlConnectBD.
28 class ControlConnectBase : public ControlBase
32 ControlConnectBase(LyXView &, Dialogs &);
36 virtual void connect();
37 /// Disconnect signals
38 virtual void disconnect();
40 /** Redraw the dialog (on receipt of a Signal indicating, for example,
41 its colors have been re-mapped).
45 /// Contains the signals we have to connect to.
49 /// Redraw connection.
54 /** Base class to control connection/disconnection of signals with the LyX
55 kernel for Buffer Independent dialogs.
56 Such dialogs do not require an update Connection although they may use
57 an update() function which is also supported by the Restore button.
60 class ControlConnectBI : public ControlConnectBase
64 ControlConnectBI(LyXView &, Dialogs &);
68 virtual void connect();
72 /** Base class to control connection/disconnection of signals with the LyX
73 kernel for Buffer Dependent dialogs.
75 class ControlConnectBD : public ControlConnectBase
79 ControlConnectBD(LyXView &, Dialogs &);
82 /** Slot connected to update signal.
83 Bool indicates if a buffer switch took place.
84 Default behaviour is to ignore this and simply update().
86 virtual void updateSlot(bool) { update(); }
88 virtual void connect();
89 /// Disconnect signals
90 virtual void disconnect();
93 /// Update connection.
97 /** Base class to control connection/disconnection of signals with the LyX
98 kernel for Inset dialogs.
102 template <class Inset>
103 class ControlConnectInset : public ControlConnectBD
107 ControlConnectInset(LyXView &, Dialogs &);
110 /// Slot connected to update signal.
111 virtual void updateSlot(bool);
113 void connectInset(Inset * = 0);
114 /// Disconnect signals
115 virtual void disconnect();
117 void disconnectInset();
120 /// pointer to the inset passed through connectInset
124 /// inset::hide connection.
125 SigC::Connection ih_;
129 template <class Inset>
130 ControlConnectInset<Inset>::ControlConnectInset(LyXView & lv, Dialogs & d)
131 : ControlConnectBD(lv, d),
136 template <class Inset>
137 void ControlConnectInset<Inset>::updateSlot(bool switched)
146 template <class Inset>
147 void ControlConnectInset<Inset>::disconnect()
151 ControlConnectBD::disconnect();
155 template <class Inset>
156 void ControlConnectInset<Inset>::connectInset(Inset * inset)
158 // If connected to another inset, disconnect from it.
166 ih_ = inset->hideDialog.connect(
167 SigC::slot(this, &ControlConnectInset::hide));
173 template <class Inset>
174 void ControlConnectInset<Inset>::disconnectInset()
180 #endif // CONTROLCONNECTIONS_H