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