]> git.lyx.org Git - lyx.git/blob - src/frontends/Dialogs.h
Cruft removal.
[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
17 class Dialog;
18 class InsetBase;
19 class LyXView;
20
21 /** Container of all dialogs.
22  */
23 class Dialogs : boost::noncopyable
24 {
25 public:
26         ///
27         Dialogs(LyXView &);
28
29         /** Redraw all visible dialogs because, for example, the GUI colours
30          *  have been re-mapped.
31          *
32          *  Note that static boost signals break some compilers, so we return a
33          *  reference to some hidden magic ;-)
34          */
35         static boost::signal0<void> & redrawGUI();
36
37         /// Toggle tooltips on/off in all dialogs.
38         static void toggleTooltips();
39
40         /// Are the tooltips on or off?
41         static bool tooltipsEnabled();
42
43         /// Hide all visible dialogs
44         void hideAll() const;
45         /// Hide any dialogs that require a buffer for them to operate
46         void hideBufferDependent() const;
47         /** Update visible, buffer-dependent dialogs
48             If the bool is true then a buffer change has occurred
49             else its still the same buffer.
50          */
51         void updateBufferDependent(bool) const ;
52
53         /** \param name == "about" etc; an identifier used to
54             launch a particular dialog.
55             \param data is a string encoding of the data used to populate
56             the dialog. Several of these dialogs do not need any data,
57             so it defaults to string().
58         */
59         void show(std::string const & name, std::string const & data = std::string());
60
61         /** \param name == "bibtex", "citation" etc; an identifier used to
62             launch a particular dialog.
63             \param data is a string representation of the Inset contents.
64             It is often little more than the output from Inset::write.
65             It is passed to, and parsed by, the frontend dialog.
66             \param inset is _not_ passed to the frontend dialog.
67             It is stored internally and used by the kernel to ascertain
68             what to do with the FuncRequest dispatched from the frontend
69             dialog on 'Apply'; should it be used to create a new inset at
70             the current cursor position or modify an existing, 'open' inset?
71         */
72         void show(std::string const & name, std::string const & data, InsetBase * inset);
73
74         /** \param name == "citation", "bibtex" etc; an identifier used
75             to update the contents of a particular dialog with \param data.
76             See the comments to 'show', above.
77         */
78         void update(std::string const & name, std::string const & data);
79
80         /// Is the dialog currently visible?
81         bool visible(std::string const & name) const;
82
83         /** All Dialogs of the given \param name will be closed if they are
84             connected to the given \param inset.
85         */
86         static void hide(std::string const & name, InsetBase * inset);
87         ///
88         void disconnect(std::string const & name);
89         ///
90         InsetBase * getOpenInset(std::string const & name) const;
91 private:
92         ///
93         void hideSlot(std::string const & name, InsetBase * inset);
94         ///
95         void redraw() const;
96         ///
97         bool isValidName(std::string const & name) const;
98         ///
99         Dialog * find_or_build(std::string const & name);
100         ///
101         typedef boost::shared_ptr<Dialog> DialogPtr;
102         ///
103         DialogPtr build(std::string const & name);
104
105         ///
106         LyXView & lyxview_;
107         ///
108         std::map<std::string, InsetBase *> open_insets_;
109
110         ///
111         std::map<std::string, DialogPtr> dialogs_;
112 };
113
114 #endif