3 * \file PreviewedInset.h
4 * Copyright 2002 the LyX Team
5 * Read the file COPYING
7 * \author Angus Leeming <leeming@lyx.org>
9 * grfx::PreviewedInset is an abstract base class that can help insets to
10 * generate previews. The daughter class must instantiate three small
11 * methods. The Inset would own an instance of this daughter class.
14 #ifndef PREVIEWEDINSET_H
15 #define PREVIEWEDINSET_H
22 #include <boost/signals/trackable.hpp>
23 #include <boost/signals/connection.hpp>
33 class PreviewedInset : public boost::signals::trackable {
35 /// a wrapper for Previews::activated()
36 static bool activated();
39 PreviewedInset(Inset & inset) : inset_(inset), pimage_(0) {}
41 /** Find the PreviewLoader, add a LaTeX snippet to it and
42 * start the loading process.
44 void generatePreview();
46 /** Add a LaTeX snippet to the PreviewLoader but do not start the
49 void addPreview(PreviewLoader & ploader);
51 /// The preview has been generated and is ready to use.
52 bool previewReady() const;
54 /// If !previewReady() returns 0.
55 PreviewImage const * pimage() const { return pimage_; }
58 /// Allow the daughter classes to cast up to the parent inset.
59 Inset * inset() const { return &inset_; }
62 /** This method is connected to the grfx::PreviewLoader::imageReady
65 void imageReady(PreviewImage const &) const;
67 /// Does the owning inset want a preview?
68 virtual bool previewWanted() const = 0;
70 virtual BufferView * view() const = 0;
71 /// a wrapper to Inset::latex
72 virtual string const latexString() const = 0;
78 /// We don't own this. Cached for efficiency reasons.
79 mutable PreviewImage const * pimage_;
81 boost::signals::connection connection_;
87 #endif // PREVIEWEDINSET_H