]> git.lyx.org Git - lyx.git/blob - src/insets/InsetPreview.h
Do not reset font in preview inset
[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 "support/unique_ptr.h"
18
19
20 namespace lyx {
21
22 class Dimension;
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         explicit 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 override { return new InsetPreview(*this); }
45
46         bool neverIndent() const override { return true; }
47
48         InsetCode lyxCode() const override { return PREVIEW_CODE; }
49
50         docstring layoutName() const override { return from_ascii("Preview"); }
51
52         bool descendable(BufferView const & /*bv*/) const override { return true; }
53
54         std::string contextMenuName() const override
55                 { return "context-preview"; }
56
57         void metrics(MetricsInfo & mi, Dimension & dim) const override;
58
59         Inset * editXY(Cursor & cur, int x, int y) override;
60
61         void draw(PainterInfo & pi, int x, int y) const override;
62
63         void addPreview(DocIterator const & inset_pos,
64                 graphics::PreviewLoader & ploader) const override;
65
66         bool notifyCursorLeaves(Cursor const & old, Cursor & cur) override;
67
68         void write(std::ostream & os) const override;
69
70         void edit(Cursor & cur, bool front, EntryDirection entry_from) override;
71
72         bool canPaintChange(BufferView const &) const override { return true; };
73         //@}
74
75 protected:
76         /// Retrieves the preview state. Returns true if preview
77         /// is enabled and the preview image is available.
78         bool previewState(BufferView * bv) const;
79         /// Recreates the preview if preview is enabled.
80         void reloadPreview(DocIterator const & pos) const;
81         /// Prepare the preview if preview is enabled.
82         void preparePreview(DocIterator const & pos) const;
83
84         ///
85         unique_ptr<RenderPreview> preview_;
86
87 };
88
89
90 } // namespace lyx
91
92
93 #endif
94