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