3 * \file PreviewLoader.h
4 * Copyright 2002 the LyX Team
5 * Read the file COPYING
7 * \author Angus Leeming <leeming@lyx.org>
9 * grfx::PreviewLoader collects latex snippets together. Then, on a
10 * startLoading() call, these are dumped to file and processed, converting
11 * each snippet to a separate bitmap image file. Once a bitmap file is ready
12 * to be loaded back into LyX, the PreviewLoader emits a signal to inform
13 * the initiating process.
16 #ifndef PREVIEWLOADER_H
17 #define PREVIEWLOADER_H
24 #include <boost/utility.hpp>
25 #include <boost/scoped_ptr.hpp>
26 #include <boost/signals/signal1.hpp>
34 class PreviewLoader : boost::noncopyable {
36 /** We need buffer because we require the preamble to the
39 PreviewLoader(Buffer const & buffer);
43 /** Is there an image already associated with this snippet of LaTeX?
44 * If so, returns a pointer to it, else returns 0.
46 PreviewImage const * preview(string const & latex_snippet) const;
60 /// How far have we got in loading the image?
61 Status status(string const & latex_snippet) const;
63 /// Add a snippet of LaTeX to the queue for processing.
64 void add(string const & latex_snippet) const;
66 /// Remove this snippet of LaTeX from the PreviewLoader.
67 void remove(string const & latex_snippet) const;
69 /** We have accumulated several latex snippets with status "InQueue".
70 * Initiate their transformation into bitmap images.
72 void startLoading() const;
74 /** Connect and you'll be informed when the bitmap image file
75 * has been created and is ready for loading through
76 * grfx::PreviewImage::image().
78 typedef boost::signal1<void, PreviewImage const &>::slot_type slot_type;
80 boost::signals::connection connect(slot_type const &) const;
82 /** When PreviewImage has finished loading the image file into memory,
83 * it tells the PreviewLoader to tell the outside world
85 void emitSignal(PreviewImage const &) const;
88 /// Use the Pimpl idiom to hide the internals.
90 /// The pointer never changes although *pimpl_'s contents may.
91 boost::scoped_ptr<Impl> const pimpl_;
96 #endif // PREVIEWLOADER_H