]> git.lyx.org Git - lyx.git/blob - src/insets/InsetPreview.h
Cleanup bv-dependent variables in InsetCollapsable
[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 <boost/scoped_ptr.hpp>
20
21 namespace lyx {
22
23 class RenderPreview;
24
25 namespace graphics {
26         class PreviewLoader;
27 }
28
29 /// An inset with an instant preview
30 class InsetPreview : public InsetText {
31         
32 public:
33         ///
34         InsetPreview(Buffer *);
35         ///
36         ~InsetPreview();
37         ///
38         InsetPreview(InsetPreview const & other);
39         ///
40         InsetPreview & operator=(InsetPreview const & other);
41
42         /// \name Methods inherited from Inset class
43         //@{
44         Inset * clone() const { return new InsetPreview(*this); }
45
46         bool neverIndent() const { return true; }
47         
48         InsetCode lyxCode() const { return PREVIEW_CODE; }
49         
50         docstring layoutName() const { return from_ascii("Preview"); }
51         
52         bool descendable(BufferView const & /*bv*/) const { return true; }
53
54         std::string contextMenuName() const
55                 { return "context-preview"; }
56
57         void metrics(MetricsInfo & mi, Dimension & dim) const;
58
59         Inset * editXY(Cursor & cur, int x, int y);
60
61         void draw(PainterInfo & pi, int x, int y) const;
62
63         void addPreview(DocIterator const & inset_pos,
64                 graphics::PreviewLoader & ploader) const;
65
66         bool notifyCursorLeaves(Cursor const & old, Cursor & cur);
67
68         void write(std::ostream & os) const;
69
70         void edit(Cursor & cur, bool front, EntryDirection entry_from);
71         //@}
72         
73 protected:
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;
81
82         ///
83         boost::scoped_ptr<RenderPreview> preview_;
84
85 };
86
87
88 } // namespace lyx
89
90
91 #endif
92