3 * \file PreviewLoader.h
4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Angus Leeming
9 * Full author contact details are available in file CREDITS
11 * grfx::PreviewLoader collects latex snippets together. Then, on a
12 * startLoading() call, these are dumped to file and processed, converting
13 * each snippet to a separate bitmap image file. Once a bitmap file is ready
14 * to be loaded back into LyX, the PreviewLoader emits a signal to inform
15 * the initiating process.
18 #ifndef PREVIEWLOADER_H
19 #define PREVIEWLOADER_H
26 #include <boost/utility.hpp>
27 #include <boost/scoped_ptr.hpp>
28 #include <boost/signals/signal1.hpp>
36 class PreviewLoader : boost::noncopyable {
38 /** We need buffer because we require the preamble to the
41 PreviewLoader(Buffer const & buffer);
45 /** Is there an image already associated with this snippet of LaTeX?
46 * If so, returns a pointer to it, else returns 0.
48 PreviewImage const * preview(string const & latex_snippet) const;
62 /// How far have we got in loading the image?
63 Status status(string const & latex_snippet) const;
65 /// Add a snippet of LaTeX to the queue for processing.
66 void add(string const & latex_snippet) const;
68 /// Remove this snippet of LaTeX from the PreviewLoader.
69 void remove(string const & latex_snippet) const;
71 /** We have accumulated several latex snippets with status "InQueue".
72 * Initiate their transformation into bitmap images.
74 void startLoading() const;
76 /** Connect and you'll be informed when the bitmap image file
77 * has been created and is ready for loading through
78 * grfx::PreviewImage::image().
80 typedef boost::signal1<void, PreviewImage const &>::slot_type slot_type;
82 boost::signals::connection connect(slot_type const &) const;
84 /** When PreviewImage has finished loading the image file into memory,
85 * it tells the PreviewLoader to tell the outside world
87 void emitSignal(PreviewImage const &) const;
89 /// Which buffer owns this loader.
90 Buffer const & buffer() const;
93 /// Use the Pimpl idiom to hide the internals.
95 /// The pointer never changes although *pimpl_'s contents may.
96 boost::scoped_ptr<Impl> const pimpl_;
101 #endif // PREVIEWLOADER_H