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 InsetPreview & operator=(InsetPreview const & other);
42 /// \name Methods inherited from Inset class
44 Inset * clone() const { return new InsetPreview(*this); }
46 bool neverIndent() const { return true; }
48 InsetCode lyxCode() const { return PREVIEW_CODE; }
50 docstring layoutName() const { return from_ascii("Preview"); }
52 bool descendable(BufferView const & /*bv*/) const { return true; }
54 std::string contextMenuName() const
55 { return "context-preview"; }
57 void metrics(MetricsInfo & mi, Dimension & dim) const;
59 Inset * editXY(Cursor & cur, int x, int y);
61 void draw(PainterInfo & pi, int x, int y) const;
63 void addPreview(DocIterator const & inset_pos,
64 graphics::PreviewLoader & ploader) const;
66 bool notifyCursorLeaves(Cursor const & old, Cursor & cur);
68 void write(std::ostream & os) const;
70 void edit(Cursor & cur, bool front, EntryDirection entry_from);
74 /// Retrieves the preview state. Returns true if preview
75 /// is enabled and the preview image is availabled.
76 bool previewState(BufferView * bv) const;
77 /// Recreates the preview if preview is enabled.
78 void reloadPreview(DocIterator const & pos) const;
79 /// Prepare the preview if preview is enabled.
80 void preparePreview(DocIterator const & pos) const;
83 boost::scoped_ptr<RenderPreview> preview_;