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