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 { return code == InsetOld::NEWLINE_CODE; }
62 void setFont(BufferView *, LyXFont const &,
63 bool toggleall = false, bool selectall = false);
65 EDITABLE editable() const;
67 int latex(Buffer const &, std::ostream &,
68 OutputParams const &) const;
70 int plaintext(Buffer const &, std::ostream &,
71 OutputParams const & runparams) const;
73 int linuxdoc(Buffer const &, std::ostream &,
74 OutputParams const &) const;
76 int docbook(Buffer const &, std::ostream &,
77 OutputParams const & runparams) const;
79 void validate(LaTeXFeatures &) const {}
81 bool checkInsertChar(LyXFont &);
83 // these are needed here because of the label/inlined functionallity
85 bool isOpen() const { return status_ == Open || status_ == Inlined; }
87 bool inlined() const { return status_ == Inlined; }
89 ERTStatus status() const { return status_; }
91 void open(BufferView *);
93 void close(BufferView *) const;
95 void metrics(MetricsInfo &, Dimension &) const;
97 void draw(PainterInfo & pi, int x, int y) const;
98 /// set the status of the inset
99 void status(BufferView *, ERTStatus const st) const;
101 bool showInsetDialog(BufferView *) const;
103 void getDrawFont(LyXFont &) const;
105 bool forceDefaultParagraphs(InsetOld const *) const {
112 priv_dispatch(FuncRequest const &, idx_type &, pos_type &);
115 void lfunMousePress(FuncRequest const &);
117 // the bool return is used to see if we opened a dialog so that we can
118 // check this from an outer inset and open the dialog of the outer inset
119 // if that one has one!
121 bool lfunMouseRelease(FuncRequest const &);
123 void lfunMouseMotion(FuncRequest const &);
127 std::string const get_new_label() const;
129 void setButtonLabel() const;
131 void set_latex_font(BufferView *);
132 /// update status on button
133 void updateStatus(BufferView *, bool = false) const;
135 void edit(BufferView * bv, bool left);
137 bool allowSpellCheck() const { return false; }
140 mutable ERTStatus status_;
144 #include "mailinset.h"
146 class InsetERTMailer : public MailInset {
149 InsetERTMailer(InsetERT & inset);
151 virtual InsetBase & inset() const { return inset_; }
153 virtual std::string const & name() const { return name_; }
155 virtual std::string const inset2string(Buffer const &) const;
157 static void string2params(std::string const &, InsetERT::ERTStatus &);
159 static std::string const params2string(InsetERT::ERTStatus);
162 static std::string const name_;