3 * \file ControlInset.tmpl
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 * ControlInset is a base class and so these templatised methods will be
12 * instantiated if this file is #included in the derived classes' .C file.
15 #include "ControlInset.h"
17 #include "ButtonControllerBase.h"
19 #include "support/LAssert.h"
21 #include <boost/bind.hpp>
23 template <class Inset, class Params>
24 ControlInset<Inset, Params>::ControlInset(LyXView & lv, Dialogs & d)
25 : ControlConnectBD(lv, d),
26 inset_(0), params_(0), dialog_built_(false)
30 template <class Inset, class Params>
31 void ControlInset<Inset, Params>::showInset(Inset * inset)
33 if (inset == 0) return; // maybe we should Assert this?
36 show(getParams(*inset));
38 // The widgets may not be valid, so refresh the button controller
43 template <class Inset, class Params>
44 void ControlInset<Inset, Params>::createInset(string const & arg)
49 bc().valid(); // so that the user can press Ok
55 template <class Inset, class Params>
56 void ControlInset<Inset, Params>::show(Params const & params)
59 if (params_) delete params_;
61 params_ = new Params(params);
64 if (emergency_exit_) {
74 bc().readOnly(bufferIsReadonly());
79 template <class Inset, class Params>
80 void ControlInset<Inset, Params>::update()
83 if (params_) delete params_;
86 params_ = new Params(getParams(*inset_));
88 params_ = new Params();
90 if (emergency_exit_) {
95 bc().readOnly(bufferIsReadonly());
98 // The widgets may not be valid, so refresh the button controller
103 template <class Inset, class Params>
104 void ControlInset<Inset, Params>::hide()
106 emergency_exit_ = false;
113 clearDaughterParams();
121 template <class Inset, class Params>
122 void ControlInset<Inset, Params>::apply()
124 if (bufferIsReadonly())
130 if (params() != getParams(*inset_)) {
131 applyParamsToInset();
134 applyParamsNoInset();
137 if (disconnectOnApply() && !isClosing()) {
138 *params_ = getParams(string());
147 template <class Inset, class Params>
148 Params & ControlInset<Inset, Params>::params()
150 lyx::Assert(params_);
155 template <class Inset, class Params>
156 Params const & ControlInset<Inset, Params>::params() const
158 lyx::Assert(params_);
163 template <class Inset, class Params>
164 Inset * ControlInset<Inset, Params>::inset() const
171 template <class Inset, class Params>
172 void ControlInset<Inset, Params>::updateSlot(bool switched)
181 template <class Inset, class Params>
182 void ControlInset<Inset, Params>::connectInset(Inset * inset)
184 // If connected to another inset, disconnect from it.
192 ih_ = inset->hideDialog.connect(
193 boost::bind(&ControlInset::hide, this));