]> git.lyx.org Git - lyx.git/blob - src/frontends/Dialogs.h
Remove all the cruft needed by the original MVC dialog code.
[lyx.git] / src / frontends / Dialogs.h
1 // -*- C++ -*-
2 /**
3  * \file Dialogs.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  * \author Allan Rae
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #ifndef DIALOGS_H
12 #define DIALOGS_H
13
14 #include <boost/utility.hpp>
15 #include <boost/signals/signal0.hpp>
16 #include <boost/signals/signal1.hpp>
17
18 class Dialog;
19 class InsetBase;
20 class LyXView;
21
22 /** Container of all dialogs and signals a LyXView needs or uses to access them
23     The list of dialog signals isn't comprehensive but should be a good guide
24     for any future additions.  Remember don't go overboard -- think minimal.
25  */
26 class Dialogs : boost::noncopyable
27 {
28 public:
29         ///
30         Dialogs(LyXView &);
31
32         /** Redraw all visible dialogs because, for example, the GUI colours
33          *  have been re-mapped.
34          *
35          *  Note that static boost signals break some compilers, so we return a
36          *  reference to some hidden magic ;-)
37          */
38         static boost::signal0<void> & redrawGUI();
39
40         /// Toggle tooltips on/off in all dialogs.
41         static void toggleTooltips();
42
43         /// Are the tooltips on or off?
44         static bool tooltipsEnabled();
45
46         /// Hide all visible dialogs
47         void hideAll() const;
48         /// Hide any dialogs that require a buffer for them to operate
49         void hideBufferDependent() const;
50         /** Update visible, buffer-dependent dialogs
51             If the bool is true then a buffer change has occurred
52             else its still the same buffer.
53          */
54         void updateBufferDependent(bool) const ;
55
56         /** \param name == "about" etc; an identifier used to
57             launch a particular dialog.
58             \param data is a string encoding of the data used to populate
59             the dialog. Several of these dialogs do not need any data,
60             so it defaults to string().
61         */
62         void show(std::string const & name, std::string const & data = std::string());
63
64         /** \param name == "bibtex", "citation" etc; an identifier used to
65             launch a particular dialog.
66             \param data is a string representation of the Inset contents.
67             It is often little more than the output from Inset::write.
68             It is passed to, and parsed by, the frontend dialog.
69             \param inset is _not_ passed to the frontend dialog.
70             It is stored internally and used by the kernel to ascertain
71             what to do with the FuncRequest dispatched from the frontend
72             dialog on 'Apply'; should it be used to create a new inset at
73             the current cursor position or modify an existing, 'open' inset?
74         */
75         void show(std::string const & name, std::string const & data, InsetBase * inset);
76
77         /** \param name == "citation", "bibtex" etc; an identifier used
78             to update the contents of a particular dialog with \param data .
79             See the comments to 'show', above.
80         */
81         void update(std::string const & name, std::string const & data);
82
83         /// is the dialog currently visible?
84         bool visible(std::string const & name) const;
85
86         /** All Dialogs of the given \param name will be closed if they are
87             connected to the given \param inset.
88         */
89         static void hide(std::string const & name, InsetBase * inset);
90         ///
91         void disconnect(std::string const & name);
92         ///
93         InsetBase * getOpenInset(std::string const & name) const;
94 private:
95         ///
96         void hideSlot(std::string const & name, InsetBase * inset);
97         ///
98         void redraw() const;
99         ///
100         bool isValidName(std::string const & name) const;
101         ///
102         Dialog * find_or_build(std::string const & name);
103         ///
104         typedef boost::shared_ptr<Dialog> DialogPtr;
105         ///
106         DialogPtr build(std::string const & name);
107
108         ///
109         LyXView & lyxview_;
110         ///
111         std::map<std::string, InsetBase *> open_insets_;
112
113         ///
114         std::map<std::string, DialogPtr> dialogs_;
115 };
116
117 #endif