1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
6 * Copyright 2001 The LyX Team.
8 * ======================================================
10 * \file ControlDialogs.h
11 * \author Angus Leeming <a.leeming@ic.ac.uk>
13 * ControlDialogs.h contains the definition of two template controller classes,
14 * ControlDialog and ControlInset, rather clumsy names for classes that
15 * control the showing, updating and hiding of popups.
17 * ControlInset is to be used as a parent class for popups that display and
18 * can perhaps modify the contents of an individual inset. An example being the
19 * ubiquitous Citation popup.
21 * ControlDialog is to be used as a parent class for popups that are not
22 * Inset-popups. (An ugly description I know, but I hope the meaning is clear!
23 * Can anyone do any better?) Examples would be the Document and Paragraph
26 * At the moment, ControlDialog is reaching a state of maturity as several
27 * controllers are now derived from it and its required functionality
30 * ControlInset is still in a state of flux as currently only InsetCommand-type
31 * insets have a controller.
35 #ifndef CONTROLCONNECTIONS2_H
36 #define CONTROLCONNECTIONS2_H
38 #include "ControlConnections.h"
41 /** Base class to control connection/disconnection of signals with the LyX
42 kernel for dialogs NOT used with insets.
43 The Base class will be either ControlConnectBI or ControlConnectBD.
46 class ControlDialog : public Base
50 ControlDialog(LyXView &, Dialogs &);
57 /// Update the dialog.
58 virtual void update();
60 /// set the params before show or update
61 virtual void setParams() {}
63 virtual void clearParams() {}
67 /** Base class to control connection/disconnection of signals with the LyX
68 kernel for Inset dialogs.
72 template <class Inset>
73 class ControlInset : public ControlConnectBD
77 ControlInset(LyXView &, Dialogs &);
80 /// Slot connected to update signal.
81 virtual void updateSlot(bool);
83 void connectInset(Inset * = 0);
84 /// Disconnect signals
85 virtual void disconnect();
87 void disconnectInset();
90 /// pointer to the inset passed through connectInset
94 /// inset::hide connection.
102 template <class Base>
103 ControlDialog<Base>::ControlDialog(LyXView & lv, Dialogs & d)
108 template <class Base>
109 void ControlDialog<Base>::show()
111 if (isBufferDependent() && !lv_.view()->available())
116 bc().readOnly(isReadonly());
120 template <class Base>
121 void ControlDialog<Base>::update()
123 if (isBufferDependent() && !lv_.view()->available())
128 bc().readOnly(isReadonly());
132 template <class Base>
133 void ControlDialog<Base>::hide()
142 template <class Inset>
143 ControlInset<Inset>::ControlInset(LyXView & lv, Dialogs & d)
144 : ControlConnectBD(lv, d),
149 template <class Inset>
150 void ControlInset<Inset>::updateSlot(bool switched)
159 template <class Inset>
160 void ControlInset<Inset>::disconnect()
164 ControlConnectBD::disconnect();
168 template <class Inset>
169 void ControlInset<Inset>::connectInset(Inset * inset)
171 // If connected to another inset, disconnect from it.
179 ih_ = inset->hideDialog.connect(
180 SigC::slot(this, &ControlInset::hide));
186 template <class Inset>
187 void ControlInset<Inset>::disconnectInset()
193 #endif // CONTROLCONNECTIONS2_H