2 /* This file is part of
3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright 1998 The LyX Team.
9 *======================================================
11 // The pristine updatable inset: Text
21 #include "insetcollapsable.h"
23 #include <boost/signals/signal0.hpp>
25 /** A collapsable text inset for LaTeX insertions.
27 To write full ert (including styles and other insets) in a given
30 Note that collapsed_ encompasses both the inline and collapsed button
31 versions of this inset.
36 class InsetERT : public InsetCollapsable {
45 InsetERT(BufferParams const &, bool collapsed = false);
47 InsetERT(InsetERT const &, bool same_id = false);
49 Inset * clone(Buffer const &, bool same_id = false) const;
51 InsetERT(BufferParams const &,
52 Language const *, string const & contents, bool collapsed);
56 Inset::Code lyxCode() const { return Inset::ERT_CODE; }
58 void read(Buffer const * buf, LyXLex & lex);
60 void write(Buffer const * buf, std::ostream & os) const;
62 string const editMessage() const;
64 bool insertInset(BufferView *, Inset *);
66 bool insetAllowed(Inset::Code) const { return false; }
68 void setFont(BufferView *, LyXFont const &,
69 bool toggleall = false, bool selectall = false);
71 void edit(BufferView *, int, int, mouse_button::state);
73 void edit(BufferView * bv, bool front = true);
75 EDITABLE editable() const;
77 boost::signal0<void> hideDialog;
79 void insetButtonPress(BufferView *, int x, int y, mouse_button::state button);
81 bool insetButtonRelease(BufferView * bv, int x, int y, mouse_button::state button);
83 void insetMotionNotify(BufferView *, int x, int y, mouse_button::state state);
85 int latex(Buffer const *, std::ostream &, bool fragile,
88 int ascii(Buffer const *,
89 std::ostream &, int linelen = 0) const;
91 int linuxdoc(Buffer const *, std::ostream &) const;
93 int docbook(Buffer const *, std::ostream &) const;
95 void validate(LaTeXFeatures &) const {}
97 UpdatableInset::RESULT localDispatch(BufferView *, kb_action,
100 bool checkInsertChar(LyXFont &);
102 // this are needed here because of the label/inlined functionallity
104 bool needFullRow() const { return status_ == Open; }
106 bool isOpen() const { return status_ == Open || status_ == Inlined; }
108 bool inlined() const { return status_ == Inlined; }
110 ERTStatus status() const { return status_; }
112 void open(BufferView *);
114 void close(BufferView *) const;
116 bool allowSpellcheck() { return false; }
117 string const selectNextWordToSpellcheck(BufferView *, float &) const;
119 int ascent(BufferView *, LyXFont const &) const;
121 int descent(BufferView *, LyXFont const &) const;
123 int width(BufferView *, LyXFont const &) const;
125 void draw(BufferView *, const LyXFont &, int , float &, bool) const;
126 /// set the status of the inset
127 void status(BufferView *, ERTStatus const st) const;
129 bool showInsetDialog(BufferView *) const;
131 void getDrawFont(LyXFont &) const;
133 bool forceDefaultParagraphs(Inset const *) const {
137 int getMaxWidth(BufferView *, UpdatableInset const *) const;
143 string const get_new_label() const;
145 void setButtonLabel() const;
147 void set_latex_font(BufferView *);
148 /// update status on button
149 void updateStatus(BufferView *, bool = false) const;
152 mutable ERTStatus status_;