]> git.lyx.org Git - lyx.git/blob - src/graphics/Previews.h
Preview fiddling (preparing the way for mathed previews).
[lyx.git] / src / graphics / Previews.h
1 // -*- C++ -*-
2 /**
3  * \file Previews.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Angus Leeming
8  *
9  * Full author contact details are available in file CREDITS.
10  *
11  * lyx::graphics::Previews is a singleton class that stores the
12  * lyx::graphics::PreviewLoader for each buffer requiring one.
13  */
14
15 #ifndef PREVIEWS_H
16 #define PREVIEWS_H
17
18 #include <boost/utility.hpp>
19 #include <boost/scoped_ptr.hpp>
20
21 class Buffer;
22
23 namespace lyx {
24 namespace graphics {
25
26 class PreviewLoader;
27
28 class Previews : boost::noncopyable {
29 public:
30         /// a wrapper for lyxrc.preview
31         static bool activated();
32
33         /// This is a singleton class. Get the instance.
34         static Previews & get();
35
36         /** Returns the PreviewLoader for this buffer.
37          *  Used by individual insets to update their own preview.
38          */
39         PreviewLoader & loader(Buffer const & buffer) const;
40
41         /// Called from the Buffer d-tor.
42         void removeLoader(Buffer const & buffer) const;
43
44         /** For a particular buffer, initiate the generation of previews
45          *  for each and every snippet of LaTeX that's of interest with
46          *  a single forked process.
47          */
48         void generateBufferPreviews(Buffer const & buffer) const;
49
50 private:
51         /** Make the c-tor, d-tor private so we can control how many objects
52          *  are instantiated.
53          */
54         Previews();
55         ~Previews();
56
57         /// Use the Pimpl idiom to hide the internals.
58         class Impl;
59         /// The pointer never changes although *pimpl_'s contents may.
60         boost::scoped_ptr<Impl> const pimpl_;
61 };
62
63 } // namespace graphics
64 } // namespace lyx
65
66 #endif // PREVIEWS_H