X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fgraphics%2FPreviewLoader.h;h=3239ffcf173c466f810b66a5ca6890ab4ec92d55;hb=f6d4bce12303a2f30ea129ee86e7f7d879668260;hp=1270a59ea921abf86b97f2bf2b4b34de57d196c4;hpb=a674f70d4a013e69a88343e5b6d13357d8a33493;p=lyx.git diff --git a/src/graphics/PreviewLoader.h b/src/graphics/PreviewLoader.h index 1270a59ea9..3239ffcf17 100644 --- a/src/graphics/PreviewLoader.h +++ b/src/graphics/PreviewLoader.h @@ -1,37 +1,38 @@ // -*- C++ -*- /** - * \file PreviewLoader.h - * Copyright 2002 the LyX Team - * Read the file COPYING + * \file PreviewLoader.h + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. * - * \author Angus Leeming + * \author Angus Leeming * - * grfx::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 readyToDisplay signal - * to inform the initiating process. + * Full author contact details are available in file CREDITS. + * + * 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. */ #ifndef PREVIEWLOADER_H #define PREVIEWLOADER_H -#ifdef __GNUG__ -#pragma interface -#endif +#include +#include + +#include "ColorCode.h" -#include "LString.h" -#include -#include -#include +namespace lyx { class Buffer; -namespace grfx { +namespace graphics { class PreviewImage; -class PreviewLoader : boost::noncopyable { +class PreviewLoader : public QObject { + Q_OBJECT public: /** We need buffer because we require the preamble to the * LaTeX file. @@ -43,7 +44,7 @@ public: /** Is there an image already associated with this snippet of LaTeX? * If so, returns a pointer to it, else returns 0. */ - PreviewImage const * preview(string const & latex_snippet) const; + PreviewImage const * preview(std::string const & latex_snippet) const; /// enum Status { @@ -58,29 +59,58 @@ public: }; /// How far have we got in loading the image? - Status status(string const & latex_snippet) const; - + Status status(std::string const & latex_snippet) const; + /// Add a snippet of LaTeX to the queue for processing. - void add(string const & latex_snippet); + void add(std::string const & latex_snippet) const; /// Remove this snippet of LaTeX from the PreviewLoader. - void remove(string const & latex_snippet); - + void remove(std::string const & latex_snippet) const; + /** We have accumulated several latex snippets with status "InQueue". * Initiate their transformation into bitmap images. */ - void startLoading(); + void startLoading(bool wait = false) const; - /// Emit this signal when an image is ready for display. - boost::signal1 imageReady; + /** Connect and you'll be informed when the bitmap image file + * has been created and is ready for loading through + * lyx::graphics::PreviewImage::image(). + */ + typedef boost::signals2::signal sig_type; + typedef sig_type::slot_type slot_type; + /// + boost::signals2::connection connect(slot_type const &) const; + + /** When PreviewImage has finished loading the image file into memory, + * it tells the PreviewLoader to tell the outside world + */ + void emitSignal(PreviewImage const &) const; + + /// Which buffer owns this loader. + Buffer const & buffer() const; + /// The background color used + static ColorCode backgroundColor() { return Color_background; } + /// The foreground color used + static ColorCode foregroundColor() { return Color_preview; } + + double displayPixelRatio() const ; + +public Q_SLOTS: + /// + void refreshPreviews(); private: + /// noncopyable + PreviewLoader(PreviewLoader const &); + void operator=(PreviewLoader const &); + /// Use the Pimpl idiom to hide the internals. class Impl; /// The pointer never changes although *pimpl_'s contents may. - boost::scoped_ptr const pimpl_; + Impl * const pimpl_; }; -} // namespace grfx +} // namespace graphics +} // namespace lyx #endif // PREVIEWLOADER_H