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