4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Vincent van Ravesteijn
9 * Full author contact details are available in file CREDITS.
12 #ifndef INSETPREVIEW_H
13 #define INSETPREVIEW_H
15 #include "InsetText.h"
17 #include "Dimension.h"
19 #include <boost/scoped_ptr.hpp>
29 /// An inset with an instant preview
30 class InsetPreview : public InsetText {
34 InsetPreview(Buffer *);
38 InsetPreview(InsetPreview const & other);
40 /// \name Methods inherited from Inset class
42 Inset * clone() const { return new InsetPreview(*this); }
44 bool neverIndent() const { return true; }
46 InsetCode lyxCode() const { return PREVIEW_CODE; }
48 docstring name() const { return from_ascii("Preview"); }
50 bool descendable(BufferView const & /*bv*/) const { return true; }
52 docstring contextMenu(BufferView const &, int, int) const
53 { return from_ascii("context-preview"); }
55 void metrics(MetricsInfo & mi, Dimension & dim) const;
57 Inset * editXY(Cursor & cur, int x, int y);
59 void draw(PainterInfo & pi, int x, int y) const;
61 void addPreview(DocIterator const & inset_pos,
62 graphics::PreviewLoader & ploader) const;
64 bool notifyCursorLeaves(Cursor const & old, Cursor & cur);
66 void write(std::ostream & os) const;
68 void edit(Cursor & cur, bool front, EntryDirection entry_from);
72 /// Retrieves the preview state. Returns true if preview
73 /// is enabled and the preview image is availabled.
74 bool previewState(BufferView * bv) const;
75 /// Recreates the preview if preview is enabled.
76 void reloadPreview(DocIterator const & pos) const;
77 /// Prepare the preview if preview is enabled.
78 void preparePreview(DocIterator const & pos) const;
81 boost::scoped_ptr<RenderPreview> preview_;
83 mutable bool use_preview_;
87 mutable Dimension dim_;