4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
8 * \author Lars Gullik Bjønnes
10 * Full author contact details are available in file CREDITS.
16 #include "InsetCollapsable.h"
17 #include "RenderPreview.h"
18 #include "graphics/PreviewLoader.h"
20 #include <boost/scoped_ptr.hpp>
24 /** A collapsable text inset for LaTeX insertions.
26 To write full ert (including styles and other insets) in a given
29 Note that collapsed_ encompasses both the inline and collapsed button
30 versions of this inset.
35 class InsetERT : public InsetCollapsable {
38 InsetERT(Buffer *, CollapseStatus status = Open);
40 InsetERT(InsetERT const & other);
44 InsetERT & operator=(InsetERT const & other);
46 static CollapseStatus string2params(std::string const &);
48 static std::string params2string(CollapseStatus);
50 void addPreview(DocIterator const & inset_pos,
51 graphics::PreviewLoader & ploader) const;
53 void preparePreview(DocIterator const & pos) const;
55 void reloadPreview(DocIterator const & pos) const;
57 bool notifyCursorLeaves(Cursor const & old, Cursor & cur);
59 void draw(PainterInfo & pi, int x, int y) const;
61 Inset * editXY(Cursor & cur, int x, int y);
63 void metrics(MetricsInfo & mi, Dimension & dim) const;
65 bool previewState(BufferView * bv) const;
68 InsetCode lyxCode() const { return ERT_CODE; }
70 docstring name() const { return from_ascii("ERT"); }
72 void write(std::ostream & os) const;
74 int plaintext(odocstream &, OutputParams const &) const;
76 int docbook(odocstream &, OutputParams const &) const;
78 docstring xhtml(XHTMLStream &, OutputParams const &) const;
80 void validate(LaTeXFeatures &) const {}
82 bool showInsetDialog(BufferView *) const;
83 /// should paragraph indendation be omitted in any case?
84 bool neverIndent() const { return true; }
86 void doDispatch(Cursor & cur, FuncRequest & cmd);
88 bool getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus &) const;
90 Inset * clone() const { return new InsetERT(*this); }
92 docstring const buttonLabel(BufferView const & bv) const;
94 bool allowSpellCheck() const { return false; }
96 boost::scoped_ptr<RenderPreview> preview_;
98 mutable bool use_preview_;