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 virtual ~PreviewedInset() {}
43 /** Find the PreviewLoader, add a LaTeX snippet to it and
44 * start the loading process.
46 void generatePreview();
48 /** Add a LaTeX snippet to the PreviewLoader but do not start the
51 void addPreview(PreviewLoader & ploader);
53 /// The preview has been generated and is ready to use.
54 bool previewReady() const;
56 /// If !previewReady() returns 0.
57 PreviewImage const * pimage() const { return pimage_; }
60 /// Allow the daughter classes to cast up to the parent inset.
61 Inset * inset() const { return &inset_; }
64 /** This method is connected to the grfx::PreviewLoader::imageReady
67 void imageReady(PreviewImage const &) const;
69 /// Does the owning inset want a preview?
70 virtual bool previewWanted() const = 0;
72 virtual BufferView * view() const = 0;
73 /// a wrapper to Inset::latex
74 virtual string const latexString() const = 0;
80 /// We don't own this. Cached for efficiency reasons.
81 mutable PreviewImage const * pimage_;
83 boost::signals::connection connection_;
89 #endif // PREVIEWEDINSET_H