]> git.lyx.org Git - lyx.git/blob - src/frontends/Dialogs.h
Martin's changes to the Note inset.
[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  * \author Allan Rae
7  *
8  * Full author contact details are available in file CREDITS
9  */
10
11 #ifndef DIALOGS_H
12 #define DIALOGS_H
13
14
15 #include "LString.h"
16
17 #include <boost/utility.hpp>
18 #include <boost/scoped_ptr.hpp>
19 #include <boost/signals/signal0.hpp>
20 #include <boost/signals/signal1.hpp>
21
22
23 class Dialog;
24 class InsetBase;
25 class LyXView;
26
27 /** Container of all dialogs and signals a LyXView needs or uses to access them
28     The list of dialog signals isn't comprehensive but should be a good guide
29     for any future additions.  Remember don't go overboard -- think minimal.
30  */
31 class Dialogs : boost::noncopyable
32 {
33 public:
34         ///
35         Dialogs(LyXView &);
36         /// Define an empty d-tor out-of-line to keep boost::scoped_ptr happy.
37         ~Dialogs();
38
39         /** Redraw all visible dialogs because, for example, the GUI colours
40          *  have been re-mapped.
41          *
42          *  Note that static boost signals break some compilers, so we return a
43          *  reference to some hidden magic ;-)
44          */
45         static boost::signal0<void> & redrawGUI();
46
47         /// Toggle tooltips on/off in all dialogs.
48         static void toggleTooltips();
49
50         /// Are the tooltips on or off?
51         static bool tooltipsEnabled();
52
53         /// Signals slated to go
54         //@{
55         boost::signal0<void> hideAllSignal;
56         boost::signal0<void> hideBufferDependentSignal;
57         boost::signal1<void, bool> updateBufferDependentSignal;
58         //@}
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         /**@name Dialog Access Signals.
71            Put into some sort of alphabetical order */
72         //@{
73         ///
74         void showDocument();
75         /// show all forked child processes
76         void showForks();
77         ///
78         void showPreamble();
79         ///
80         void showPreferences();
81         ///
82         void showPrint();
83         ///
84         void showSearch();
85         ///
86         void showSendto();
87         /// bring up the spellchecker
88         void showSpellchecker();
89         //@}
90
91         /** \param name == "about" etc; an identifier used to
92             launch a particular dialog.
93             \param data is a string encoding of the data used to populate
94             the dialog. Several of these dialogs do not need any data,
95             so it defaults to string().
96         */
97         void show(string const & name, string const & data = string());
98
99         /** \param name == "bibtex", "citation" etc; an identifier used to
100             launch a particular dialog.
101             \param data is a string representation of the Inset contents.
102             It is often little more than the output from Inset::write.
103             It is passed to, and parsed by, the frontend dialog.
104             \param inset is _not_ passed to the frontend dialog.
105             It is stored internally and used by the kernel to ascertain
106             what to do with the FuncRequest dispatched from the frontend
107             dialog on 'Apply'; should it be used to create a new inset at
108             the current cursor position or modify an existing, 'open' inset?
109         */
110         void show(string const & name, string const & data, InsetBase * inset);
111
112         /** \param name == "citation", "bibtex" etc; an identifier used
113             to update the contents of a particular dialog with \param data .
114             See the comments to 'show', above.
115         */
116         void update(string const & name, string const & data);
117
118         /// is the dialog currently visible?
119         bool visible(string const & name) const;
120
121         /** All Dialogs of the given \param name will be closed if they are
122             connected to the given \param inset.
123         */
124         static void hide(string const & name, InsetBase * inset);
125         ///
126         void disconnect(string const & name);
127         ///
128         InsetBase * getOpenInset(string const & name) const;
129 private:
130         ///
131         void hideSlot(string const & name, InsetBase * inset);
132         ///
133         void redraw() const;
134         ///
135         bool isValidName(string const & name) const;
136         ///
137         Dialog * find(string const & name);
138         ///
139         Dialog * build(string const & name);
140
141         ///
142         LyXView & lyxview_;
143         ///
144         std::map<string, InsetBase *> open_insets_;
145
146         ///
147         typedef boost::shared_ptr<Dialog> DialogPtr;
148         ///
149         std::map<string, DialogPtr> dialogs_;
150
151         /// the stuff below is slated to go...
152         void init_pimpl();
153         ///
154         class Impl;
155         ///
156         Impl * pimpl_;
157 };
158
159 #endif