]> git.lyx.org Git - lyx.git/blob - src/frontends/Dialogs.h
Move Color::color enum to ColorCode.h
[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  *
7  * \author Allan Rae
8  * \author Angus Leeming
9  *
10  * Full author contact details are available in file CREDITS.
11  */
12
13 #ifndef DIALOGS_H
14 #define DIALOGS_H
15
16 #include <boost/signal.hpp>
17 #include <boost/noncopyable.hpp>
18
19 #include <map>
20
21 namespace lyx {
22
23 class Inset;
24
25 namespace frontend {
26
27 class Dialog;
28 class LyXView;
29
30 /** Container of all dialogs.
31  */
32 class Dialogs : boost::noncopyable {
33 public:
34         ///
35         Dialogs(LyXView &);
36
37         /** Check the status of all visible dialogs and disable or reenable
38          *  them as appropriate.
39          *
40          *  Disabling is needed for example when a dialog is open and the
41          *  cursor moves to a position where the corresponding inset is not
42          *  allowed.
43          */
44         void checkStatus();
45
46         /// Are the tooltips on or off?
47         static bool tooltipsEnabled();
48
49         /// Hide all visible dialogs
50         void hideAll() const;
51         /// Hide any dialogs that require a buffer for them to operate
52         void hideBufferDependent() const;
53         /** Update visible, buffer-dependent dialogs
54             If the bool is true then a buffer change has occurred
55             else it is still the same buffer.
56          */
57         void updateBufferDependent(bool) const;
58
59         /** \param name == "bibtex", "citation" etc; an identifier used to
60             launch a particular dialog.
61             \param data is a string representation of the Inset contents.
62             It is often little more than the output from Inset::write.
63             It is passed to, and parsed by, the frontend dialog.
64             Several of these dialogs do not need any data,
65             so it defaults to string().
66             \param inset ownership 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,
73                 std::string const & data = std::string(), Inset * inset = 0);
74
75         /** \param name == "citation", "bibtex" etc; an identifier used
76             to update the contents of a particular dialog with \param data.
77             See the comments to 'show', above.
78         */
79         void update(std::string const & name, std::string const & data);
80
81         /// Is the dialog currently visible?
82         bool visible(std::string const & name) const;
83
84         /** All Dialogs of the given \param name will be closed if they are
85             connected to the given \param inset.
86         */
87         void hide(std::string const & name, Inset * inset);
88         ///
89         void disconnect(std::string const & name);
90         ///
91         Inset * getOpenInset(std::string const & name) const;
92 private:
93         ///
94         void redraw() const;
95         ///
96         bool isValidName(std::string const & name) const;
97         ///
98         Dialog * find_or_build(std::string const & name);
99         ///
100         typedef boost::shared_ptr<Dialog> DialogPtr;
101         ///
102         Dialog * build(std::string const & name);
103
104         ///
105         LyXView & lyxview_;
106         ///
107         std::map<std::string, Inset *> open_insets_;
108
109         ///
110         std::map<std::string, DialogPtr> dialogs_;
111
112         /// flag against a race condition due to multiclicks in Qt frontend,
113         /// see bug #1119
114         bool in_show_;
115
116         ///
117         boost::signals::connection connection_;
118 };
119
120 } // namespace frontend
121 } // namespace lyx
122
123 #endif