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
18 #include "RenderPreview.h"
\r
20 #include "graphics/PreviewLoader.h"
\r
22 #include <boost/scoped_ptr.hpp>
\r
26 /// An inset with an instant preview
\r
27 class InsetPreview : public InsetText {
\r
31 InsetPreview(Buffer *);
\r
35 InsetPreview(InsetPreview const & other);
\r
37 /// \name Methods inherited from Inset class
\r
39 Inset * clone() const { return new InsetPreview(*this); }
\r
41 bool neverIndent() const { return true; }
\r
43 InsetCode lyxCode() const { return PREVIEW_CODE; }
\r
45 docstring name() const { return from_ascii("Preview"); }
\r
47 bool descendable(BufferView const & /*bv*/) const { return true; }
\r
49 docstring contextMenu(BufferView const &, int, int) const
\r
50 { return from_ascii("context-preview"); }
\r
52 void metrics(MetricsInfo & mi, Dimension & dim) const;
\r
54 Inset * editXY(Cursor & cur, int x, int y);
\r
56 void draw(PainterInfo & pi, int x, int y) const;
\r
58 void addPreview(DocIterator const & inset_pos,
\r
59 graphics::PreviewLoader & ploader) const;
\r
61 bool notifyCursorLeaves(Cursor const & old, Cursor & cur);
\r
63 void write(std::ostream & os) const;
\r
65 void edit(Cursor & cur, bool front, EntryDirection entry_from);
\r
69 /// Retrieves the preview state. Returns true if preview
\r
70 /// is enabled and the preview image is availabled.
\r
71 bool previewState(BufferView * bv) const;
\r
72 /// Recreates the preview if preview is enabled.
\r
73 void reloadPreview(DocIterator const & pos) const;
\r
74 /// Prepare the preview if preview is enabled.
\r
75 void preparePreview(DocIterator const & pos) const;
\r
78 boost::scoped_ptr<RenderPreview> preview_;
\r
80 mutable bool use_preview_;
\r
84 mutable Dimension dim_;
\r