X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fcontrollers%2FControlInset.h;h=99236cdc84321118cfa7b6a74d938cd4e77a61a3;hb=ce708d095c65866617424f940c1dac6b7e236d61;hp=d7798e4d48e0c765b4d86a74919936fa255aa421;hpb=cda84cbcdfa4e4b0881c7dda6d91862b4356ac0e;p=lyx.git diff --git a/src/frontends/controllers/ControlInset.h b/src/frontends/controllers/ControlInset.h index d7798e4d48..99236cdc84 100644 --- a/src/frontends/controllers/ControlInset.h +++ b/src/frontends/controllers/ControlInset.h @@ -1,47 +1,48 @@ -/* This file is part of - * ====================================================== +// -*- C++ -*- +/** + * \file ControlInset.h + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. * - * LyX, The Document Processor + * \author Angus Leeming * - * Copyright 2001 The LyX Team. + * Full author contact details are available in file CREDITS * - * ====================================================== - * - * \file ControlInsets.h - * \author Angus Leeming - * - * ControlInset is to be used as a parent class for popups that display and + * ControlInset is to be used as a parent class for dialogs that display and * can perhaps modify the contents of an individual inset. An example being the - * ubiquitous Citation popup. + * ubiquitous Citation dialog. */ #ifndef CONTROLINSET_H #define CONTROLINSET_H #include "ControlConnections.h" +#include "LString.h" + +#include class Inset; template -class ControlInset : public ControlConnectBD -{ +class ControlInset : public ControlConnectBD { public: /// ControlInset(LyXView &, Dialogs &); /// Allow the View access to the local copy. - Params & params() const; + Params & params(); + /// + Params const & params() const; -protected: /// Slots connected in the daughter classes c-tor. /// Slot launching dialog to (possibly) create a new inset. void createInset(string const &); /// Slot launching dialog to an existing inset. void showInset(Inset *); +protected: /// Allow the daughter methods to access the inset. Inset * inset() const; - private: - /** These 6 methods are all that the individual daughter classes + /** These 7 methods are all that the individual daughter classes should need to instantiate. */ /// if the inset exists then do this... @@ -62,10 +63,12 @@ private: /// clean-up any daughter class-particular data on hide(). virtual void clearDaughterParams() {} + /** Some dialogs may find it beneficial to disconnect from the inset + when the Apply button is pressed. E.g., doing this with the citation + dialog allows multiple citiations to be inserted easily. */ + virtual bool disconnectOnApply() { return false; } - - - /// Instantiation of ControlBase virtual methods. + /// Instantiation of ControlButtons virtual methods. /// Get changed parameters and Dispatch them to the kernel. virtual void apply(); @@ -84,150 +87,18 @@ private: void connectInset(Inset * = 0); /// pointer to the inset passed through connectInset - Inset * inset_; + Inset * inset_; /// inset::hide connection. - SigC::Connection ih_; + boost::signals::connection ih_; /** A local copy of the inset's params. Memory is allocated only whilst the dialog is visible. */ Params * params_; -}; - - -#include "LyXView.h" -#include "support/LAssert.h" - - - -template -ControlInset::ControlInset(LyXView & lv, Dialogs & d) - : ControlConnectBD(lv, d), - inset_(0), ih_(0), params_(0) -{} - - -template -void ControlInset::showInset(Inset * inset) -{ - if (inset == 0) return; // maybe we should Assert this? - - connectInset(inset); - show(getParams(*inset)); -} - - -template -void ControlInset::createInset(string const & arg) -{ - connectInset(); - - if ( !arg.empty() ) - bc().valid(); // so that the user can press Ok - - show(getParams(arg)); -} - - -template -void ControlInset::show(Params const & params) -{ - if (params_) delete params_; - params_ = new Params(params); - setDaughterParams(); - - bc().readOnly(isReadonly()); - view().show(); -} - - -template -void ControlInset::hide() -{ - if (params_) { - delete params_; - params_ = 0; - } - inset_ = 0; - - clearDaughterParams(); - - ih_.disconnect(); - disconnect(); - view().hide(); -} - - -template -void ControlInset::update() -{ - if (params_) delete params_; - - if (inset_) - params_ = new Params(getParams(*inset_)); - else - params_ = new Params(); - - bc().readOnly(isReadonly()); - view().update(); -} - - -template -void ControlInset::apply() -{ - if (lv_.buffer()->isReadonly()) - return; - - view().apply(); - - if (inset_ && params() != getParams(*inset_)) - applyParamsToInset(); - else - applyParamsNoInset(); -} - - -template -Params & ControlInset::params() const -{ - Assert(params_); - return *params_; -} - - -template -Inset * ControlInset::inset() const -{ - Assert(inset_); - return inset_; -} - - -template -void ControlInset::updateSlot(bool switched) -{ - if (switched) - hide(); - else - update(); -} + /// is the dialog built ? + bool dialog_built_; +}; +#include "ControlInset.tmpl" -template -void ControlInset::connectInset(Inset * inset) -{ - // If connected to another inset, disconnect from it. - if (inset_) { - ih_.disconnect(); - inset_ = 0; - } - - if (inset) { - inset_ = inset; - ih_ = inset->hideDialog.connect( - SigC::slot(this, &ControlInset::hide)); - } - connect(); -} #endif // CONTROLINSET_H