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.
17 #include "insetcollapsable.h"
19 /** A collapsable text inset for LaTeX insertions.
21 To write full ert (including styles and other insets) in a given
24 Note that collapsed_ encompasses both the inline and collapsed button
25 versions of this inset.
30 class InsetERT : public InsetCollapsable {
39 InsetERT(BufferParams const &, bool collapsed = false);
41 InsetERT(InsetERT const &);
43 virtual std::auto_ptr<InsetBase> clone() const;
45 InsetERT(BufferParams const &,
46 Language const *, std::string const & contents, bool collapsed);
50 InsetOld::Code lyxCode() const { return InsetOld::ERT_CODE; }
52 void read(Buffer const & buf, LyXLex & lex);
54 void write(Buffer const & buf, std::ostream & os) const;
56 std::string const editMessage() const;
58 bool insertInset(BufferView *, InsetOld *);
60 bool insetAllowed(InsetOld::Code code) const {
61 return code == InsetOld::NEWLINE_CODE;
64 EDITABLE editable() const;
66 int latex(Buffer const &, std::ostream &,
67 OutputParams const &) const;
69 int plaintext(Buffer const &, std::ostream &,
70 OutputParams const & runparams) const;
72 int linuxdoc(Buffer const &, std::ostream &,
73 OutputParams const &) const;
75 int docbook(Buffer const &, std::ostream &,
76 OutputParams const & runparams) const;
78 void validate(LaTeXFeatures &) const {}
80 bool checkInsertChar(LyXFont &);
82 // these are needed here because of the label/inlined functionallity
84 bool isOpen() const { return status_ == Open || status_ == Inlined; }
86 bool inlined() const { return status_ == Inlined; }
88 ERTStatus status() const { return status_; }
94 void metrics(MetricsInfo &, Dimension &) const;
96 void draw(PainterInfo & pi, int x, int y) const;
97 /// set the status of the inset
98 void status(ERTStatus const st) const;
100 bool showInsetDialog(BufferView *) const;
102 void getDrawFont(LyXFont &) const;
104 bool forceDefaultParagraphs(InsetOld const *) const { return true; }
109 priv_dispatch(FuncRequest const &, idx_type &, pos_type &);
112 void lfunMousePress(FuncRequest const &);
114 // the bool return is used to see if we opened a dialog so that we can
115 // check this from an outer inset and open the dialog of the outer inset
116 // if that one has one!
118 bool lfunMouseRelease(FuncRequest const &);
120 void lfunMouseMotion(FuncRequest const &);
124 std::string const getNewLabel() const;
126 void setButtonLabel() const;
128 void setLatexFont(BufferView *);
129 /// update status on button
130 void updateStatus(bool = false) const;
132 void edit(BufferView * bv, bool left);
134 bool allowSpellCheck() const { return false; }
137 mutable ERTStatus status_;
141 #include "mailinset.h"
143 class InsetERTMailer : public MailInset {
146 InsetERTMailer(InsetERT & inset);
148 virtual InsetBase & inset() const { return inset_; }
150 virtual std::string const & name() const { return name_; }
152 virtual std::string const inset2string(Buffer const &) const;
154 static void string2params(std::string const &, InsetERT::ERTStatus &);
156 static std::string const params2string(InsetERT::ERTStatus);
159 static std::string const name_;