]> git.lyx.org Git - lyx.git/blob - src/insets/InsetPreview.h
Do not check again and again for non existing files
[lyx.git] / src / insets / InsetPreview.h
1 // -*- C++ -*-
2 /**
3  * \file InsetPreview.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Vincent van Ravesteijn
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef INSETPREVIEW_H
13 #define INSETPREVIEW_H
14
15 #include "InsetText.h"
16
17 #include "Dimension.h"
18
19 #include "support/unique_ptr.h"
20
21
22 namespace lyx {
23
24 class RenderPreview;
25
26 namespace graphics {
27         class PreviewLoader;
28 }
29
30 /// An inset with an instant preview
31 class InsetPreview : public InsetText {
32
33 public:
34         ///
35         InsetPreview(Buffer *);
36         ///
37         ~InsetPreview();
38         ///
39         InsetPreview(InsetPreview const & other);
40         ///
41         InsetPreview & operator=(InsetPreview const & other);
42
43         /// \name Methods inherited from Inset class
44         //@{
45         Inset * clone() const { return new InsetPreview(*this); }
46
47         bool neverIndent() const { return true; }
48
49         bool inheritFont() const { return false; }
50
51         InsetCode lyxCode() const { return PREVIEW_CODE; }
52
53         docstring layoutName() const { return from_ascii("Preview"); }
54
55         bool descendable(BufferView const & /*bv*/) const { return true; }
56
57         std::string contextMenuName() const
58                 { return "context-preview"; }
59
60         void metrics(MetricsInfo & mi, Dimension & dim) const;
61
62         Inset * editXY(Cursor & cur, int x, int y);
63
64         void draw(PainterInfo & pi, int x, int y) const;
65
66         void addPreview(DocIterator const & inset_pos,
67                 graphics::PreviewLoader & ploader) const;
68
69         bool notifyCursorLeaves(Cursor const & old, Cursor & cur);
70
71         void write(std::ostream & os) const;
72
73         void edit(Cursor & cur, bool front, EntryDirection entry_from);
74
75         bool canPaintChange(BufferView const &) const { return true; };
76         //@}
77
78 protected:
79         /// Retrieves the preview state. Returns true if preview
80         /// is enabled and the preview image is availabled.
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;
86
87         ///
88         unique_ptr<RenderPreview> preview_;
89
90 };
91
92
93 } // namespace lyx
94
95
96 #endif
97