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