]> git.lyx.org Git - lyx.git/blob - src/frontends/Dialogs.h
some tabular fixes for the problems reported by Helge
[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         /// Toggle tooltips on/off in all dialogs.
46         static void toggleTooltips();
47
48         /// Are the tooltips on or off?
49         static bool tooltipsEnabled();
50
51         /// Hide all visible dialogs
52         void hideAll() const;
53         /// Hide any dialogs that require a buffer for them to operate
54         void hideBufferDependent() const;
55         /** Update visible, buffer-dependent dialogs
56             If the bool is true then a buffer change has occurred
57             else its still the same buffer.
58          */
59         void updateBufferDependent(bool) const ;
60
61         /** \param name == "about" etc; an identifier used to
62             launch a particular dialog.
63             \param data is a string encoding of the data used to populate
64             the dialog. Several of these dialogs do not need any data,
65             so it defaults to string().
66         */
67         void show(std::string const & name, std::string const & data = std::string());
68
69         /** \param name == "bibtex", "citation" etc; an identifier used to
70             launch a particular dialog.
71             \param data is a string representation of the Inset contents.
72             It is often little more than the output from Inset::write.
73             It is passed to, and parsed by, the frontend dialog.
74             \param inset is _not_ passed to the frontend dialog.
75             It is stored internally and used by the kernel to ascertain
76             what to do with the FuncRequest dispatched from the frontend
77             dialog on 'Apply'; should it be used to create a new inset at
78             the current cursor position or modify an existing, 'open' inset?
79         */
80         void show(std::string const & name, std::string const & data, InsetBase * inset);
81
82         /** \param name == "citation", "bibtex" etc; an identifier used
83             to update the contents of a particular dialog with \param data.
84             See the comments to 'show', above.
85         */
86         void update(std::string const & name, std::string const & data);
87
88         /// Is the dialog currently visible?
89         bool visible(std::string const & name) const;
90
91         /** All Dialogs of the given \param name will be closed if they are
92             connected to the given \param inset.
93         */
94         static void hide(std::string const & name, InsetBase * inset);
95         ///
96         void disconnect(std::string const & name);
97         ///
98         InsetBase * getOpenInset(std::string const & name) const;
99 private:
100         ///
101         void hideSlot(std::string const & name, InsetBase * inset);
102         ///
103         void redraw() const;
104         ///
105         bool isValidName(std::string const & name) const;
106         ///
107         lyx::frontend::Dialog * find_or_build(std::string const & name);
108         ///
109         typedef boost::shared_ptr<lyx::frontend::Dialog> DialogPtr;
110         ///
111         DialogPtr build(std::string const & name);
112
113         ///
114         LyXView & lyxview_;
115         ///
116         std::map<std::string, InsetBase *> open_insets_;
117
118         ///
119         std::map<std::string, DialogPtr> dialogs_;
120
121         /// flag against a race condition due to multiclicks in Qt frontend, see bug #1119
122         bool in_show_;
123 };
124
125 #endif