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 * graphics::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
21 #include <boost/signal.hpp>
23 #include "ColorCode.h"
35 /** We need buffer because we require the preamble to the
38 PreviewLoader(Buffer const & buffer);
42 /** Is there an image already associated with this snippet of LaTeX?
43 * If so, returns a pointer to it, else returns 0.
45 PreviewImage const * preview(std::string const & latex_snippet) const;
59 /// How far have we got in loading the image?
60 Status status(std::string const & latex_snippet) const;
62 /// Add a snippet of LaTeX to the queue for processing.
63 void add(std::string const & latex_snippet) const;
65 /// Remove this snippet of LaTeX from the PreviewLoader.
66 void remove(std::string const & latex_snippet) const;
68 /** We have accumulated several latex snippets with status "InQueue".
69 * Initiate their transformation into bitmap images.
71 void startLoading(bool wait = false) const;
73 /** Connect and you'll be informed when the bitmap image file
74 * has been created and is ready for loading through
75 * lyx::graphics::PreviewImage::image().
77 typedef boost::signal<void(PreviewImage const &)> sig_type;
78 typedef sig_type::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;
87 /// Which buffer owns this loader.
88 Buffer const & buffer() const;
89 /// The background color used
90 static ColorCode backgroundColor() { return Color_background; }
91 /// The foreground color used
92 static ColorCode foregroundColor() { return Color_preview; }
96 PreviewLoader(PreviewLoader const &);
97 void operator=(PreviewLoader const &);
99 /// Use the Pimpl idiom to hide the internals.
101 /// The pointer never changes although *pimpl_'s contents may.
105 } // namespace graphics
108 #endif // PREVIEWLOADER_H