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 "support/unique_ptr.h"
30 /// An inset with an instant preview
31 class InsetPreview : public InsetText {
35 explicit InsetPreview(Buffer *);
39 InsetPreview(InsetPreview const & other);
41 InsetPreview & operator=(InsetPreview const & other);
43 /// \name Methods inherited from Inset class
45 Inset * clone() const { return new InsetPreview(*this); }
47 bool neverIndent() const { return true; }
49 bool inheritFont() const { return false; }
51 InsetCode lyxCode() const { return PREVIEW_CODE; }
53 docstring layoutName() const { return from_ascii("Preview"); }
55 bool descendable(BufferView const & /*bv*/) const { return true; }
57 std::string contextMenuName() const
58 { return "context-preview"; }
60 void metrics(MetricsInfo & mi, Dimension & dim) const;
62 Inset * editXY(Cursor & cur, int x, int y);
64 void draw(PainterInfo & pi, int x, int y) const;
66 void addPreview(DocIterator const & inset_pos,
67 graphics::PreviewLoader & ploader) const;
69 bool notifyCursorLeaves(Cursor const & old, Cursor & cur);
71 void write(std::ostream & os) const;
73 void edit(Cursor & cur, bool front, EntryDirection entry_from);
75 bool canPaintChange(BufferView const &) const { return true; };
79 /// Retrieves the preview state. Returns true if preview
80 /// is enabled and the preview image is available.
81 bool previewState(BufferView * bv) const;
82 /// Recreates the preview if preview is enabled.
83 void reloadPreview(DocIterator const & pos) const;
84 /// Prepare the preview if preview is enabled.
85 void preparePreview(DocIterator const & pos) const;
88 unique_ptr<RenderPreview> preview_;