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