3 * \file PreviewedInset.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 * lyx::graphics::PreviewedInset is an abstract base class that can help
12 * insets to generate previews. The daughter class must instantiate two small
13 * methods. The Inset would own an instance of this daughter class.
16 #ifndef PREVIEWEDINSET_H
17 #define PREVIEWEDINSET_H
19 #include "support/std_string.h"
20 #include <boost/signals/trackable.hpp>
21 #include <boost/signals/connection.hpp>
34 class PreviewedInset : public boost::signals::trackable {
36 /// a wrapper for Previews::activated()
37 static bool activated();
40 PreviewedInset(InsetOld & inset);
42 /** Find the PreviewLoader, add a LaTeX snippet to it and
43 * start the loading process.
45 void generatePreview(Buffer const &);
47 /** Add a LaTeX snippet to the PreviewLoader but do not start the
50 void addPreview(PreviewLoader & ploader);
52 /** Remove a snippet from the cache of previews.
53 * Useful if previewing the contents of a file that has changed.
57 /// The preview has been generated and is ready to use.
58 bool previewReady() const;
60 /// If !previewReady() returns 0.
61 PreviewImage const * pimage() const;
65 virtual ~PreviewedInset() {}
66 /// Allow the daughter classes to cast up to the parent inset.
67 InsetOld const & inset() const;
69 BufferView * view() const;
72 /// This method is connected to the PreviewLoader::imageReady signal.
73 void imageReady(PreviewImage const &) const;
75 /// Does the owning inset want a preview?
76 virtual bool previewWanted(Buffer const &) const = 0;
77 /// a wrapper to Inset::latex
78 virtual string const latexString(Buffer const &) const = 0;
85 /// We don't own this. Cached for efficiency reasons.
86 mutable PreviewImage const * pimage_;
88 boost::signals::connection connection_;
93 PreviewImage const * PreviewedInset::pimage() const
100 InsetOld const & PreviewedInset::inset() const
105 } // namespace graphics
108 #endif // PREVIEWEDINSET_H