]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/Dialogs.h
merge controllers/Makefile.am and controllers/tests/Makefile.am
[lyx.git] / src / frontends / Dialogs.h
index 03b988b8a716c12f0bbfaa0b7f1ee05b76d83c4b..f179ec56d71e0b3fddc5dc7689e3c52a9bc8fd4b 100644 (file)
 // -*- C++ -*-
-/* Dialogs.h
- * Container of all dialogs and signals a LyXView needs or uses to access them.
- * Author: Allan Rae <rae@lyx.org>
- * This file is part of
- * ======================================================
+/**
+ * \file Dialogs.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
  *
- *           LyX, The Document Processor
+ * \author Allan Rae
+ * \author Angus Leeming
  *
- *           Copyright 1995 Matthias Ettrich
- *           Copyright 1995-2000 The LyX Team.
- *
- *           This file Copyright 2000
- *           Allan Rae
- * ======================================================
+ * Full author contact details are available in file CREDITS.
  */
 
 #ifndef DIALOGS_H
 #define DIALOGS_H
 
-#include <vector>
-#include <sigc++/signal_system.h>
+#include <boost/signal.hpp>
+#include <boost/utility.hpp>
 
-#include "LString.h"
-#include "support/utility.hpp"
+#include <map>
 
-class DialogBase;
+namespace lyx {
 
-// Maybe this should be a UIFunc modelled on LyXFunc
+class Inset;
 class LyXView;
 
-class InsetGraphics;
-class InsetBibKey;
-class InsetBibtex;
-class InsetError;
-class InsetInclude;
-class InsetInfo;
-class InsetTabular;
-class InsetCommand;
-
-using std::vector;
-
-#ifdef SIGC_CXX_NAMESPACES
-using SigC::Signal0;
-using SigC::Signal1;
-#endif
+namespace frontend { class Dialog; }
 
-/** Container of all dialogs and signals a LyXView needs or uses to access them
-    The list of dialog signals isn't comprehensive but should be a good guide
-    for any future additions.  Remember don't go overboard -- think minimal.
+/** Container of all dialogs.
  */
-class Dialogs : public noncopyable
-{
+class Dialogs : boost::noncopyable {
 public:
-       /**@name Constructors and Deconstructors */
-       //@{
-       ///
-       Dialogs(LyXView *);
-       ///
-       ~Dialogs();
-       //@}
-       
-       /**@name Global Hide and Update Signals */
-       //@{
-       /// Hide all visible popups
-       Signal0<void> hideAll;
-       
-       /// Hide any popups that require a buffer for them to operate
-       Signal0<void> hideBufferDependent;
-       
-       /// Update visible, buffer-dependent popups
-       Signal0<void> updateBufferDependent;
-       //@}
-
-       /**@name Dialog Access Signals.
-          Put into some sort of alphabetical order */
-       //@{
-       /// Do we really have to push this?
-       Signal1<void, vector<string> const &> SetDocumentClassChoice;
-       ///
-       Signal1<void, InsetBibKey *> showBibkey;
-       ///
-       Signal1<void, InsetBibtex *> showBibtex;
-       ///
-       Signal0<void> showCharacter;
-       ///
-       Signal1<void, InsetCommand *> showCitation;
-       ///
-       Signal1<void, string const &> createCitation;
-       ///
-       Signal0<void> showCopyright;
-       ///
-       Signal0<void> showCredits;
-       ///
-       Signal1<void, InsetError *> showError;
-       ///
-       Signal1<void, InsetGraphics *> showGraphics;
-       ///
-       Signal1<void, InsetInclude *> showInclude;
-       ///
-       Signal1<void, InsetCommand *> showIndex;
-       ///
-       Signal1<void, string const &> createIndex;
-       ///
-       Signal1<void, InsetInfo *> showInfo;
-       ///
-       Signal0<void> showLayoutDocument;
-       ///
-       Signal0<void> showLayoutParagraph;
        ///
-       Signal0<void> showLogFile;
-       ///
-       Signal0<void> showPreamble;
-       ///
-       Signal0<void> showPreferences;
-       ///
-       Signal0<void> showPrint;
-       ///
-       Signal1<void, InsetCommand *> showRef;
-       ///
-       Signal1<void, string const &> createRef;
-       ///
-       Signal1<void, InsetTabular *> showTabular;
-       ///
-       Signal1<void, InsetTabular *> updateTabular;
-       ///
-       Signal1<void, InsetTabular *> hideTabular;
+       Dialogs(LyXView &);
+
+       /** Check the status of all visible dialogs and disable or reenable
+        *  them as appropriate.
+        *
+        *  Disabling is needed for example when a dialog is open and the
+        *  cursor moves to a position where the corresponding inset is not
+        *  allowed.
+        */
+       void checkStatus();
+
+       /// Are the tooltips on or off?
+       static bool tooltipsEnabled();
+
+       /// Hide all visible dialogs
+       void hideAll() const;
+       /// Hide any dialogs that require a buffer for them to operate
+       void hideBufferDependent() const;
+       /** Update visible, buffer-dependent dialogs
+           If the bool is true then a buffer change has occurred
+           else its still the same buffer.
+        */
+       void updateBufferDependent(bool) const ;
+
+       /** \param name == "about" etc; an identifier used to
+           launch a particular dialog.
+           \param data is a string encoding of the data used to populate
+           the dialog. Several of these dialogs do not need any data,
+           so it defaults to string().
+       */
+       void show(std::string const & name, std::string const & data = std::string());
+
+       /** \param name == "bibtex", "citation" etc; an identifier used to
+           launch a particular dialog.
+           \param data is a string representation of the Inset contents.
+           It is often little more than the output from Inset::write.
+           It is passed to, and parsed by, the frontend dialog.
+           \param inset is _not_ passed to the frontend dialog.
+           It is stored internally and used by the kernel to ascertain
+           what to do with the FuncRequest dispatched from the frontend
+           dialog on 'Apply'; should it be used to create a new inset at
+           the current cursor position or modify an existing, 'open' inset?
+       */
+       void show(std::string const & name, std::string const & data, Inset * inset);
+
+       /** \param name == "citation", "bibtex" etc; an identifier used
+           to update the contents of a particular dialog with \param data.
+           See the comments to 'show', above.
+       */
+       void update(std::string const & name, std::string const & data);
+
+       /// Is the dialog currently visible?
+       bool visible(std::string const & name) const;
+
+       /** All Dialogs of the given \param name will be closed if they are
+           connected to the given \param inset.
+       */
+       void hide(std::string const & name, Inset * inset);
+       ///
+       void disconnect(std::string const & name);
+       ///
+       Inset * getOpenInset(std::string const & name) const;
+private:
        ///
-       Signal0<void> showTabularCreate;
+       void redraw() const;
        ///
-       Signal1<void, InsetCommand *> showTOC;
+       bool isValidName(std::string const & name) const;
        ///
-       Signal1<void, string const &> createTOC;
+       frontend::Dialog * find_or_build(std::string const & name);
        ///
-       Signal1<void, InsetCommand *> showUrl;
+       typedef boost::shared_ptr<frontend::Dialog> DialogPtr;
        ///
-       Signal1<void, string const &> createUrl;
+       DialogPtr build(std::string const & name);
+
        ///
-       Signal0<void> updateCharacter;  // allow update as cursor moves
-       //@}
-private:
+       LyXView & lyxview_;
        ///
-       vector<DialogBase *> dialogs_;
-};
-
-#endif
-
-
-
+       std::map<std::string, Inset *> open_insets_;
 
+       ///
+       std::map<std::string, DialogPtr> dialogs_;
 
+       /// flag against a race condition due to multiclicks in Qt frontend, see bug #1119
+       bool in_show_;
 
+       ///
+       boost::signals::connection connection_;
+};
 
+} // namespace lyx
 
+#endif