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