]> git.lyx.org Git - lyx.git/blob - src/insets/InsetPreview.h
typo
[lyx.git] / src / insets / InsetPreview.h
1 // -*- C++ -*-\r
2 /**\r
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
6  *\r
7  * \author Vincent van Ravesteijn\r
8  *\r
9  * Full author contact details are available in file CREDITS.\r
10  */\r
11 \r
12 #ifndef INSETPREVIEW_H\r
13 #define INSETPREVIEW_H\r
14 \r
15 #include "InsetText.h"\r
16 \r
17 #include "Dimension.h"\r
18 #include "RenderPreview.h"\r
19 \r
20 #include "graphics/PreviewLoader.h"\r
21 \r
22 #include <boost/scoped_ptr.hpp>\r
23 \r
24 namespace lyx {\r
25 \r
26 /// An inset with an instant preview\r
27 class InsetPreview : public InsetText {\r
28         \r
29 public:\r
30         ///\r
31         InsetPreview(Buffer *);\r
32         ///\r
33         ~InsetPreview();\r
34         ///\r
35         InsetPreview(InsetPreview const & other);\r
36 \r
37         /// \name Methods inherited from Inset class\r
38         //@{\r
39         Inset * clone() const { return new InsetPreview(*this); }\r
40 \r
41         bool neverIndent() const { return true; }\r
42         \r
43         InsetCode lyxCode() const { return PREVIEW_CODE; }\r
44         \r
45         docstring name() const { return from_ascii("Preview"); }\r
46         \r
47         bool descendable(BufferView const & /*bv*/) const { return true; }\r
48 \r
49         docstring contextMenu(BufferView const &, int, int) const\r
50                 { return from_ascii("context-preview"); }\r
51 \r
52         void metrics(MetricsInfo & mi, Dimension & dim) const;\r
53 \r
54         Inset * editXY(Cursor & cur, int x, int y);\r
55 \r
56         void draw(PainterInfo & pi, int x, int y) const;\r
57 \r
58         void addPreview(DocIterator const & inset_pos,\r
59                 graphics::PreviewLoader & ploader) const;\r
60 \r
61         bool notifyCursorLeaves(Cursor const & old, Cursor & cur);\r
62 \r
63         void write(std::ostream & os) const;\r
64 \r
65         void edit(Cursor & cur, bool front, EntryDirection entry_from);\r
66         //@}\r
67         \r
68 protected:\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
76 \r
77         ///\r
78         boost::scoped_ptr<RenderPreview> preview_;\r
79         ///\r
80         mutable bool use_preview_;\r
81 \r
82 private:\r
83         ///\r
84         mutable Dimension dim_;\r
85 };\r
86 \r
87 \r
88 } // namespace lyx\r
89 \r
90 \r
91 #endif\r
92 \r