2002-07-05 21:24:15 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/**
|
2003-08-23 00:17:00 +00:00
|
|
|
* \file PreviewLoader.h
|
2002-09-05 15:14:23 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
2002-07-05 21:24:15 +00:00
|
|
|
*
|
2002-12-01 22:59:25 +00:00
|
|
|
* \author Angus Leeming
|
2002-09-05 11:31:30 +00:00
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
* Full author contact details are available in file CREDITS.
|
2002-07-05 21:24:15 +00:00
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
* lyx::graphics::PreviewLoader collects latex snippets together. Then, on a
|
|
|
|
* startLoading() call, these are dumped to file and processed, converting
|
|
|
|
* each snippet to a separate bitmap image file. Once a bitmap file is ready
|
|
|
|
* to be loaded back into LyX, the PreviewLoader emits a signal to inform
|
|
|
|
* the initiating process.
|
2002-07-05 21:24:15 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef PREVIEWLOADER_H
|
|
|
|
#define PREVIEWLOADER_H
|
|
|
|
|
|
|
|
#include <boost/utility.hpp>
|
|
|
|
#include <boost/scoped_ptr.hpp>
|
2004-09-26 14:19:47 +00:00
|
|
|
#include <boost/signal.hpp>
|
2002-07-05 21:24:15 +00:00
|
|
|
|
|
|
|
|
2003-07-04 08:23:23 +00:00
|
|
|
namespace lyx {
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
class Buffer;
|
|
|
|
|
2003-07-04 08:23:23 +00:00
|
|
|
namespace graphics {
|
2002-07-05 21:24:15 +00:00
|
|
|
|
|
|
|
class PreviewImage;
|
|
|
|
|
|
|
|
class PreviewLoader : boost::noncopyable {
|
|
|
|
public:
|
|
|
|
/** We need buffer because we require the preamble to the
|
|
|
|
* LaTeX file.
|
|
|
|
*/
|
|
|
|
PreviewLoader(Buffer const & buffer);
|
|
|
|
///
|
|
|
|
~PreviewLoader();
|
|
|
|
|
|
|
|
/** Is there an image already associated with this snippet of LaTeX?
|
|
|
|
* If so, returns a pointer to it, else returns 0.
|
|
|
|
*/
|
2003-10-06 15:43:21 +00:00
|
|
|
PreviewImage const * preview(std::string const & latex_snippet) const;
|
2002-07-05 21:24:15 +00:00
|
|
|
|
|
|
|
///
|
|
|
|
enum Status {
|
|
|
|
///
|
|
|
|
NotFound,
|
|
|
|
///
|
|
|
|
InQueue,
|
|
|
|
///
|
|
|
|
Processing,
|
|
|
|
///
|
|
|
|
Ready
|
|
|
|
};
|
|
|
|
|
|
|
|
/// How far have we got in loading the image?
|
2003-10-06 15:43:21 +00:00
|
|
|
Status status(std::string const & latex_snippet) const;
|
2002-07-17 16:56:42 +00:00
|
|
|
|
2002-07-05 21:24:15 +00:00
|
|
|
/// Add a snippet of LaTeX to the queue for processing.
|
2003-10-06 15:43:21 +00:00
|
|
|
void add(std::string const & latex_snippet) const;
|
2002-07-05 21:24:15 +00:00
|
|
|
|
|
|
|
/// Remove this snippet of LaTeX from the PreviewLoader.
|
2003-10-06 15:43:21 +00:00
|
|
|
void remove(std::string const & latex_snippet) const;
|
2002-07-17 16:56:42 +00:00
|
|
|
|
2002-07-05 21:24:15 +00:00
|
|
|
/** We have accumulated several latex snippets with status "InQueue".
|
|
|
|
* Initiate their transformation into bitmap images.
|
|
|
|
*/
|
2002-07-17 16:56:42 +00:00
|
|
|
void startLoading() const;
|
|
|
|
|
|
|
|
/** Connect and you'll be informed when the bitmap image file
|
|
|
|
* has been created and is ready for loading through
|
2003-07-21 21:30:57 +00:00
|
|
|
* lyx::graphics::PreviewImage::image().
|
2002-07-17 16:56:42 +00:00
|
|
|
*/
|
2004-09-26 14:19:47 +00:00
|
|
|
typedef boost::signal<void(PreviewImage const &)> sig_type;
|
|
|
|
typedef sig_type::slot_type slot_type;
|
2002-07-17 16:56:42 +00:00
|
|
|
///
|
|
|
|
boost::signals::connection connect(slot_type const &) const;
|
2002-07-05 21:24:15 +00:00
|
|
|
|
2002-07-17 16:56:42 +00:00
|
|
|
/** When PreviewImage has finished loading the image file into memory,
|
|
|
|
* it tells the PreviewLoader to tell the outside world
|
|
|
|
*/
|
|
|
|
void emitSignal(PreviewImage const &) const;
|
2002-07-05 21:24:15 +00:00
|
|
|
|
2002-08-02 16:30:58 +00:00
|
|
|
/// Which buffer owns this loader.
|
|
|
|
Buffer const & buffer() const;
|
|
|
|
|
2002-07-05 21:24:15 +00:00
|
|
|
private:
|
|
|
|
/// Use the Pimpl idiom to hide the internals.
|
|
|
|
class Impl;
|
|
|
|
/// The pointer never changes although *pimpl_'s contents may.
|
|
|
|
boost::scoped_ptr<Impl> const pimpl_;
|
|
|
|
};
|
|
|
|
|
2003-07-04 08:23:23 +00:00
|
|
|
} // namespace graphics
|
|
|
|
} // namespace lyx
|
2002-07-05 21:24:15 +00:00
|
|
|
|
|
|
|
#endif // PREVIEWLOADER_H
|