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 InsetBase * clone() 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 code) const { return code == Inset::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 LatexRunParams const &) const;
70 int ascii(Buffer const *,
71 std::ostream &, int linelen = 0) const;
73 int linuxdoc(Buffer const *, std::ostream &) const;
75 int docbook(Buffer const *, std::ostream &, bool mixcont) const;
77 void validate(LaTeXFeatures &) const {}
79 RESULT localDispatch(FuncRequest const &);
81 bool checkInsertChar(LyXFont &);
83 // this are needed here because of the label/inlined functionallity
85 bool needFullRow() const { return status_ == Open; }
87 bool isOpen() const { return status_ == Open || status_ == Inlined; }
89 bool inlined() const { return status_ == Inlined; }
91 ERTStatus status() const { return status_; }
93 void open(BufferView *);
95 void close(BufferView *) const;
97 bool allowSpellcheck() const { return false; }
100 selectNextWordToSpellcheck(BufferView *, float &) const;
102 void metrics(MetricsInfo &, Dimension &) const;
104 void draw(PainterInfo & pi, int x, int y) const;
105 /// set the status of the inset
106 void status(BufferView *, ERTStatus const st) const;
108 bool showInsetDialog(BufferView *) const;
110 void getDrawFont(LyXFont &) const;
112 bool forceDefaultParagraphs(Inset const *) const {
116 int getMaxWidth(BufferView *, UpdatableInset const *) const;
118 void update(BufferView *, bool =false);
122 void lfunMousePress(FuncRequest const &);
124 // the bool return is used to see if we opened a dialog so that we can
125 // check this from an outer inset and open the dialog of the outer inset
126 // if that one has one!
128 bool lfunMouseRelease(FuncRequest const &);
130 void lfunMouseMotion(FuncRequest const &);
134 string const get_new_label() const;
136 void setButtonLabel() const;
138 void set_latex_font(BufferView *);
139 /// update status on button
140 void updateStatus(BufferView *, bool = false) const;
143 mutable ERTStatus status_;
147 #include "mailinset.h"
149 class InsetERTMailer : public MailInset {
152 InsetERTMailer(InsetERT & inset);
154 virtual InsetBase & inset() const { return inset_; }
156 virtual string const & name() const { return name_; }
158 virtual string const inset2string() const;
160 static void string2params(string const &, InsetERT::ERTStatus &);
162 static string const params2string(InsetERT::ERTStatus);
165 static string const name_;