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
20 #include "insetcollapsable.h"
22 #include <boost/signals/signal0.hpp>
24 /** A collapsable text inset for LaTeX insertions.
26 To write full ert (including styles and other insets) in a given
29 Note that collapsed_ encompasses both the inline and collapsed button
30 versions of this inset.
35 class InsetERT : public InsetCollapsable {
44 InsetERT(BufferParams const &, bool collapsed = false);
46 InsetERT(InsetERT const &, bool same_id = false);
48 Inset * clone(Buffer const &, bool same_id = false) const;
50 InsetERT(BufferParams const &,
51 Language const *, string const & contents, bool collapsed);
55 Inset::Code lyxCode() const { return Inset::ERT_CODE; }
57 void read(Buffer const * buf, LyXLex & lex);
59 void write(Buffer const * buf, std::ostream & os) const;
61 string const editMessage() const;
63 bool insertInset(BufferView *, Inset *);
65 bool insetAllowed(Inset::Code) const { return false; }
67 void setFont(BufferView *, LyXFont const &,
68 bool toggleall = false, bool selectall = false);
70 void edit(BufferView *, int, int, mouse_button::state);
72 void edit(BufferView * bv, bool front = true);
74 EDITABLE editable() const;
76 boost::signal0<void> hideDialog;
78 int latex(Buffer const *, std::ostream &, bool fragile,
81 int ascii(Buffer const *,
82 std::ostream &, int linelen = 0) const;
84 int linuxdoc(Buffer const *, std::ostream &) const;
86 int docbook(Buffer const *, std::ostream &, bool mixcont) const;
88 void validate(LaTeXFeatures &) const {}
90 RESULT localDispatch(FuncRequest const &);
92 bool checkInsertChar(LyXFont &);
94 // this are needed here because of the label/inlined functionallity
96 bool needFullRow() const { return status_ == Open; }
98 bool isOpen() const { return status_ == Open || status_ == Inlined; }
100 bool inlined() const { return status_ == Inlined; }
102 ERTStatus status() const { return status_; }
104 void open(BufferView *);
106 void close(BufferView *) const;
108 bool allowSpellcheck() { return false; }
111 selectNextWordToSpellcheck(BufferView *, float &) const;
113 int ascent(BufferView *, LyXFont const &) const;
115 int descent(BufferView *, LyXFont const &) const;
117 int width(BufferView *, LyXFont const &) const;
119 void draw(BufferView *, const LyXFont &, int , float &, bool) const;
120 /// set the status of the inset
121 void status(BufferView *, ERTStatus const st) const;
123 bool showInsetDialog(BufferView *) const;
125 void getDrawFont(LyXFont &) const;
127 bool forceDefaultParagraphs(Inset const *) const {
131 int getMaxWidth(BufferView *, UpdatableInset const *) const;
133 void update(BufferView *, LyXFont const &, bool =false);
137 void lfunMousePress(FuncRequest const &);
139 // the bool return is used to see if we opened a dialog so that we can
140 // check this from an outer inset and open the dialog of the outer inset
141 // if that one has one!
143 bool lfunMouseRelease(FuncRequest const &);
145 void lfunMouseMotion(FuncRequest const &);
149 string const get_new_label() const;
151 void setButtonLabel() const;
153 void set_latex_font(BufferView *);
154 /// update status on button
155 void updateStatus(BufferView *, bool = false) const;
158 mutable ERTStatus status_;