Consider the case where there is not any layout name.
[lyx.git] / src / frontends / Dialogs.h
bloba75019eb7dae6a6632f396dd7f3e007849f1ffc4
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.
7 * \author Allan Rae
8 * \author Angus Leeming
10 * Full author contact details are available in file CREDITS.
13 #ifndef DIALOGS_H
14 #define DIALOGS_H
16 #include <boost/signal.hpp>
17 #include <boost/utility.hpp>
19 #include <map>
21 class InsetBase;
22 class LyXView;
24 namespace lyx {
25 namespace frontend {
26 class Dialog;
27 } // namespace frontend
28 } // namespace lyx
30 /** Container of all dialogs.
32 class Dialogs : boost::noncopyable {
33 public:
34 ///
35 Dialogs(LyXView &);
37 /** Redraw all visible dialogs because, for example, the GUI colours
38 * have been re-mapped.
40 * Note that static boost signals break some compilers, so we return a
41 * reference to some hidden magic ;-)
43 static boost::signal<void()> & redrawGUI();
45 /** Check the status of all visible dialogs and disable or reenable
46 * them as appropriate.
48 * Disabling is needed for example when a dialog is open and the
49 * cursor moves to a position where the corresponding inset is not
50 * allowed.
52 void checkStatus();
54 /// Toggle tooltips on/off in all dialogs.
55 static void toggleTooltips();
57 /// Are the tooltips on or off?
58 static bool tooltipsEnabled();
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.
68 void updateBufferDependent(bool) const ;
70 /** \param name == "about" etc; an identifier used to
71 launch a particular dialog.
72 \param data is a string encoding of the data used to populate
73 the dialog. Several of these dialogs do not need any data,
74 so it defaults to string().
76 void show(std::string const & name, std::string const & data = std::string());
78 /** \param name == "bibtex", "citation" etc; an identifier used to
79 launch a particular dialog.
80 \param data is a string representation of the Inset contents.
81 It is often little more than the output from Inset::write.
82 It is passed to, and parsed by, the frontend dialog.
83 \param inset is _not_ passed to the frontend dialog.
84 It is stored internally and used by the kernel to ascertain
85 what to do with the FuncRequest dispatched from the frontend
86 dialog on 'Apply'; should it be used to create a new inset at
87 the current cursor position or modify an existing, 'open' inset?
89 void show(std::string const & name, std::string const & data, InsetBase * inset);
91 /** \param name == "citation", "bibtex" etc; an identifier used
92 to update the contents of a particular dialog with \param data.
93 See the comments to 'show', above.
95 void update(std::string const & name, std::string const & data);
97 /// Is the dialog currently visible?
98 bool visible(std::string const & name) const;
100 /** All Dialogs of the given \param name will be closed if they are
101 connected to the given \param inset.
103 static void hide(std::string const & name, InsetBase * inset);
105 void disconnect(std::string const & name);
107 InsetBase * getOpenInset(std::string const & name) const;
108 private:
110 void hideSlot(std::string const & name, InsetBase * inset);
112 void redraw() const;
114 bool isValidName(std::string const & name) const;
116 lyx::frontend::Dialog * find_or_build(std::string const & name);
118 typedef boost::shared_ptr<lyx::frontend::Dialog> DialogPtr;
120 DialogPtr build(std::string const & name);
123 LyXView & lyxview_;
125 std::map<std::string, InsetBase *> open_insets_;
128 std::map<std::string, DialogPtr> dialogs_;
130 /// flag against a race condition due to multiclicks in Qt frontend, see bug #1119
131 bool in_show_;
134 #endif