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 #include <boost/signals/signal0.hpp>
21 /** A collapsable text inset for LaTeX insertions.
23 To write full ert (including styles and other insets) in a given
26 Note that collapsed_ encompasses both the inline and collapsed button
27 versions of this inset.
32 class InsetERT : public InsetCollapsable {
41 InsetERT(BufferParams const &, bool collapsed = false);
43 InsetERT(InsetERT const &, bool same_id = false);
45 Inset * clone(Buffer const &, bool same_id = false) const;
47 InsetERT(BufferParams const &,
48 Language const *, string const & contents, bool collapsed);
52 Inset::Code lyxCode() const { return Inset::ERT_CODE; }
54 void read(Buffer const * buf, LyXLex & lex);
56 void write(Buffer const * buf, std::ostream & os) const;
58 string const editMessage() const;
60 bool insertInset(BufferView *, Inset *);
62 bool insetAllowed(Inset::Code) const { return false; }
64 void setFont(BufferView *, LyXFont const &,
65 bool toggleall = false, bool selectall = false);
67 void edit(BufferView *, int, int, mouse_button::state);
69 void edit(BufferView * bv, bool front = true);
71 EDITABLE editable() const;
73 boost::signal0<void> hideDialog;
75 int latex(Buffer const *, std::ostream &, bool fragile,
78 int ascii(Buffer const *,
79 std::ostream &, int linelen = 0) const;
81 int linuxdoc(Buffer const *, std::ostream &) const;
83 int docbook(Buffer const *, std::ostream &, bool mixcont) const;
85 void validate(LaTeXFeatures &) const {}
87 RESULT localDispatch(FuncRequest const &);
89 bool checkInsertChar(LyXFont &);
91 // this are needed here because of the label/inlined functionallity
93 bool needFullRow() const { return status_ == Open; }
95 bool isOpen() const { return status_ == Open || status_ == Inlined; }
97 bool inlined() const { return status_ == Inlined; }
99 ERTStatus status() const { return status_; }
101 void open(BufferView *);
103 void close(BufferView *) const;
105 bool allowSpellcheck() const { return false; }
108 selectNextWordToSpellcheck(BufferView *, float &) const;
110 int ascent(BufferView *, LyXFont const &) const;
112 int descent(BufferView *, LyXFont const &) const;
114 int width(BufferView *, LyXFont const &) const;
116 void draw(BufferView *, const LyXFont &, int , float &, bool) const;
117 /// set the status of the inset
118 void status(BufferView *, ERTStatus const st) const;
120 bool showInsetDialog(BufferView *) const;
122 void getDrawFont(LyXFont &) const;
124 bool forceDefaultParagraphs(Inset const *) const {
128 int getMaxWidth(BufferView *, UpdatableInset const *) const;
130 void update(BufferView *, LyXFont const &, bool =false);
134 void lfunMousePress(FuncRequest const &);
136 // the bool return is used to see if we opened a dialog so that we can
137 // check this from an outer inset and open the dialog of the outer inset
138 // if that one has one!
140 bool lfunMouseRelease(FuncRequest const &);
142 void lfunMouseMotion(FuncRequest const &);
146 string const get_new_label() const;
148 void setButtonLabel() const;
150 void set_latex_font(BufferView *);
151 /// update status on button
152 void updateStatus(BufferView *, bool = false) const;
155 mutable ERTStatus status_;