]> git.lyx.org Git - features.git/blob - src/insets/InsetIPA.h
Implement a native IPA inset (bug #2591) with instant preview.
[features.git] / src / insets / InsetIPA.h
1 // -*- C++ -*-
2 /**
3  * \file InsetIPA.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Jürgen Spitzmüller
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef INSETIPA_H
13 #define INSETIPA_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 IPA inset with instant preview
30 class InsetIPA : public InsetText {
31         
32 public:
33         ///
34         InsetIPA(Buffer *);
35         ///
36         ~InsetIPA();
37         ///
38         InsetIPA(InsetIPA const & other);
39
40         /// \name Methods inherited from Inset class
41         //@{
42         Inset * clone() const { return new InsetIPA(*this); }
43
44         bool neverIndent() const { return true; }
45         
46         InsetCode lyxCode() const { return IPA_CODE; }
47         
48         docstring layoutName() const { return from_ascii("IPA"); }
49         
50         bool descendable(BufferView const & /*bv*/) const { return true; }
51
52         void metrics(MetricsInfo & mi, Dimension & dim) const;
53
54         Inset * editXY(Cursor & cur, int x, int y);
55
56         void draw(PainterInfo & pi, int x, int y) const;
57
58         void addPreview(DocIterator const & inset_pos,
59                 graphics::PreviewLoader & ploader) const;
60
61         bool notifyCursorLeaves(Cursor const & old, Cursor & cur);
62
63         void write(std::ostream & os) const;
64
65         void edit(Cursor & cur, bool front, EntryDirection entry_from);
66         
67         ///
68         void latex(otexstream &, OutputParams const &) const;
69         ///
70         void validate(LaTeXFeatures & features) const;
71         ///
72         bool allowSpellCheck() const { return false; }
73         ///
74         bool insetAllowed(InsetCode code) const;
75         //@}
76         
77 protected:
78         /// Retrieves the preview state. Returns true if preview
79         /// is enabled and the preview image is availabled.
80         bool previewState(BufferView * bv) const;
81         /// Recreates the preview if preview is enabled.
82         void reloadPreview(DocIterator const & pos) const;
83         /// Prepare the preview if preview is enabled.
84         void preparePreview(DocIterator const & pos) const;
85
86         ///
87         boost::scoped_ptr<RenderPreview> preview_;
88         ///
89         mutable bool use_preview_;
90
91 private:
92         ///
93         mutable Dimension dim_;
94 };
95
96
97 } // namespace lyx
98
99
100 #endif
101