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 //InsetERT(InsetERT const &, bool same_id);
45 Inset * clone(Buffer const &) const;
47 //Inset * clone(Buffer const &, bool same_id) const;
49 InsetERT(BufferParams const &,
50 Language const *, string const & contents, bool collapsed);
54 Inset::Code lyxCode() const { return Inset::ERT_CODE; }
56 void read(Buffer const * buf, LyXLex & lex);
58 void write(Buffer const * buf, std::ostream & os) const;
60 string const editMessage() const;
62 bool insertInset(BufferView *, Inset *);
64 bool insetAllowed(Inset::Code code) const { return code == Inset::NEWLINE_CODE; }
66 void setFont(BufferView *, LyXFont const &,
67 bool toggleall = false, bool selectall = false);
69 EDITABLE editable() const;
71 int latex(Buffer const *, std::ostream &,
72 LatexRunParams const &) const;
74 int ascii(Buffer const *,
75 std::ostream &, int linelen = 0) const;
77 int linuxdoc(Buffer const *, std::ostream &) const;
79 int docbook(Buffer const *, std::ostream &, bool mixcont) const;
81 void validate(LaTeXFeatures &) const {}
83 RESULT localDispatch(FuncRequest const &);
85 bool checkInsertChar(LyXFont &);
87 // this are needed here because of the label/inlined functionallity
89 bool needFullRow() const { return status_ == Open; }
91 bool isOpen() const { return status_ == Open || status_ == Inlined; }
93 bool inlined() const { return status_ == Inlined; }
95 ERTStatus status() const { return status_; }
97 void open(BufferView *);
99 void close(BufferView *) const;
101 bool allowSpellcheck() const { return false; }
104 selectNextWordToSpellcheck(BufferView *, float &) const;
106 void dimension(BufferView *, LyXFont const &, Dimension &) const;
108 void draw(BufferView *, const LyXFont &, int , float &) const;
109 /// set the status of the inset
110 void status(BufferView *, ERTStatus const st) const;
112 bool showInsetDialog(BufferView *) const;
114 void getDrawFont(LyXFont &) const;
116 bool forceDefaultParagraphs(Inset const *) const {
120 int getMaxWidth(BufferView *, UpdatableInset const *) const;
122 void update(BufferView *, bool =false);
126 void lfunMousePress(FuncRequest const &);
128 // the bool return is used to see if we opened a dialog so that we can
129 // check this from an outer inset and open the dialog of the outer inset
130 // if that one has one!
132 bool lfunMouseRelease(FuncRequest const &);
134 void lfunMouseMotion(FuncRequest const &);
138 string const get_new_label() const;
140 void setButtonLabel() const;
142 void set_latex_font(BufferView *);
143 /// update status on button
144 void updateStatus(BufferView *, bool = false) const;
147 mutable ERTStatus status_;
151 #include "mailinset.h"
153 class InsetERTMailer : public MailInset {
156 InsetERTMailer(InsetERT & inset);
158 virtual InsetBase & inset() const { return inset_; }
160 virtual string const & name() const { return name_; }
162 virtual string const inset2string() const;
164 static void string2params(string const &, InsetERT::ERTStatus &);
166 static string const params2string(InsetERT::ERTStatus);
169 static string const name_;