]> git.lyx.org Git - lyx.git/blob - src/graphics/Previews.h
ws changes
[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  *  grfx::Previews is a singleton class that stores the grfx::PreviewLoader
12  *  for each buffer requiring one.
13  */
14
15 #ifndef PREVIEWS_H
16 #define PREVIEWS_H
17
18 #ifdef __GNUG__
19 #pragma interface
20 #endif
21
22 #include "LString.h"
23 #include <boost/utility.hpp>
24 #include <boost/scoped_ptr.hpp>
25
26 class Buffer;
27
28 namespace grfx {
29
30 class PreviewLoader;
31
32 class Previews : boost::noncopyable {
33 public:
34         /// a wrapper for lyxrc.preview
35         static bool activated();
36
37         /// This is a singleton class. Get the instance.
38         static Previews & get();
39
40         /** Returns the PreviewLoader for this buffer.
41          *  Used by individual insets to update their own preview.
42          *  We assert that (buffer != 0) but do not pass a Buffer &
43          *  so that insets do not need to #include buffer.h
44          */
45         PreviewLoader & loader(Buffer const * buffer) const;
46
47         /** Called from the Buffer d-tor.
48          *  If (buffer == 0), does nothing.
49          */
50         void removeLoader(Buffer const * buffer) const;
51
52         /** For a particular buffer, initiate the generation of previews
53          *  for each and every snippetof LaTeX that's of interest with
54          *  a single forked process.
55          *  If (buffer == 0), does nothing.
56          */
57         void generateBufferPreviews(Buffer const & buffer) const;
58
59 private:
60         /** Make the c-tor, d-tor private so we can control how many objects
61          *  are instantiated.
62          */
63         Previews();
64         ///
65         ~Previews();
66
67         /// Use the Pimpl idiom to hide the internals.
68         class Impl;
69         /// The pointer never changes although *pimpl_'s contents may.
70         boost::scoped_ptr<Impl> const pimpl_;
71 };
72
73 } // namespace grfx
74
75 #endif // PREVIEWS_H