]> git.lyx.org Git - lyx.git/blob - src/frontends/Dialogs.h
Small clean-up.
[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 #include <boost/utility.hpp>
15 #include <boost/signals/signal0.hpp>
16 #include <boost/signals/signal1.hpp>
17
18 #include "support/std_string.h"
19
20
21 class Dialog;
22 class InsetBase;
23 class LyXView;
24
25 /** Container of all dialogs and signals a LyXView needs or uses to access them
26     The list of dialog signals isn't comprehensive but should be a good guide
27     for any future additions.  Remember don't go overboard -- think minimal.
28  */
29 class Dialogs : boost::noncopyable
30 {
31 public:
32         ///
33         Dialogs(LyXView &);
34         ///
35         ~Dialogs();
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::signal0<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         /// Signals slated to go
52         //@{
53         boost::signal0<void> hideAllSignal;
54         boost::signal0<void> hideBufferDependentSignal;
55         boost::signal1<void, bool> updateBufferDependentSignal;
56         //@}
57
58         /// Hide all visible dialogs
59         void hideAll() const;
60         /// Hide any dialogs that require a buffer for them to operate
61         void hideBufferDependent() const;
62         /** Update visible, buffer-dependent dialogs
63             If the bool is true then a buffer change has occurred
64             else its still the same buffer.
65          */
66         void updateBufferDependent(bool) const ;
67
68         /**@name Dialog Access Signals.
69            Put into some sort of alphabetical order */
70         //@{
71         ///
72         void showDocument();
73         /// show all forked child processes
74         void showForks();
75         ///
76         void showPreamble();
77         ///
78         void showPreferences();
79         ///
80         void showPrint();
81         ///
82         void showSearch();
83         ///
84         void showSendto();
85         /// bring up the spellchecker
86         void showSpellchecker();
87         //@}
88
89         /** \param name == "about" etc; an identifier used to
90             launch a particular dialog.
91             \param data is a string encoding of the data used to populate
92             the dialog. Several of these dialogs do not need any data,
93             so it defaults to string().
94         */
95         void show(string const & name, string const & data = string());
96
97         /** \param name == "bibtex", "citation" etc; an identifier used to
98             launch a particular dialog.
99             \param data is a string representation of the Inset contents.
100             It is often little more than the output from Inset::write.
101             It is passed to, and parsed by, the frontend dialog.
102             \param inset is _not_ passed to the frontend dialog.
103             It is stored internally and used by the kernel to ascertain
104             what to do with the FuncRequest dispatched from the frontend
105             dialog on 'Apply'; should it be used to create a new inset at
106             the current cursor position or modify an existing, 'open' inset?
107         */
108         void show(string const & name, string const & data, InsetBase * inset);
109
110         /** \param name == "citation", "bibtex" etc; an identifier used
111             to update the contents of a particular dialog with \param data .
112             See the comments to 'show', above.
113         */
114         void update(string const & name, string const & data);
115
116         /// is the dialog currently visible?
117         bool visible(string const & name) const;
118
119         /** All Dialogs of the given \param name will be closed if they are
120             connected to the given \param inset.
121         */
122         static void hide(string const & name, InsetBase * inset);
123         ///
124         void disconnect(string const & name);
125         ///
126         InsetBase * getOpenInset(string const & name) const;
127 private:
128         ///
129         void hideSlot(string const & name, InsetBase * inset);
130         ///
131         void redraw() const;
132         ///
133         bool isValidName(string const & name) const;
134         ///
135         Dialog * find_or_build(string const & name);
136         ///
137         Dialog * build(string const & name);
138
139         ///
140         LyXView & lyxview_;
141         ///
142         std::map<string, InsetBase *> open_insets_;
143
144         ///
145         typedef boost::shared_ptr<Dialog> DialogPtr;
146         ///
147         std::map<string, DialogPtr> dialogs_;
148
149         /// the stuff below is slated to go...
150         void init_pimpl();
151         ///
152         class Impl;
153         ///
154         Impl * pimpl_;
155 };
156
157 #endif