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 &, bool same_id = false);
43 Inset * clone(Buffer const &, bool same_id = false) const;
45 InsetERT(BufferParams const &,
46 Language const *, string const & contents, bool collapsed);
50 Inset::Code lyxCode() const { return Inset::ERT_CODE; }
52 void read(Buffer const * buf, LyXLex & lex);
54 void write(Buffer const * buf, std::ostream & os) const;
56 string const editMessage() const;
58 bool insertInset(BufferView *, Inset *);
60 bool insetAllowed(Inset::Code) const { return false; }
62 void setFont(BufferView *, LyXFont const &,
63 bool toggleall = false, bool selectall = false);
65 void edit(BufferView *, int, int, mouse_button::state);
67 void edit(BufferView * bv, bool front = true);
69 EDITABLE editable() const;
71 int latex(Buffer const *, std::ostream &, bool fragile,
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 int ascent(BufferView *, LyXFont const &) const;
108 int descent(BufferView *, LyXFont const &) const;
110 int width(BufferView *, LyXFont const &) const;
112 void draw(BufferView *, const LyXFont &, int , float &, bool) const;
113 /// set the status of the inset
114 void status(BufferView *, ERTStatus const st) const;
116 bool showInsetDialog(BufferView *) const;
118 void getDrawFont(LyXFont &) const;
120 bool forceDefaultParagraphs(Inset const *) const {
124 int getMaxWidth(BufferView *, UpdatableInset const *) const;
126 void update(BufferView *, LyXFont const &, bool =false);
130 void lfunMousePress(FuncRequest const &);
132 // the bool return is used to see if we opened a dialog so that we can
133 // check this from an outer inset and open the dialog of the outer inset
134 // if that one has one!
136 bool lfunMouseRelease(FuncRequest const &);
138 void lfunMouseMotion(FuncRequest const &);
142 string const get_new_label() const;
144 void setButtonLabel() const;
146 void set_latex_font(BufferView *);
147 /// update status on button
148 void updateStatus(BufferView *, bool = false) const;
151 mutable ERTStatus status_;
155 #include "mailinset.h"
157 class InsetERTMailer : public MailInset {
160 InsetERTMailer(InsetERT & inset);
162 virtual Inset & inset() const { return inset_; }
164 virtual string const & name() const { return name_; }
166 virtual string const inset2string() const;
168 static void string2params(string const &, InsetERT::ERTStatus &);
170 static string const params2string(string const & name,
171 InsetERT::ERTStatus);