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"
22 #include <sigc++/signal_system.h>
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, unsigned int);
72 void edit(BufferView * bv, bool front = true);
74 EDITABLE editable() const;
76 SigC::Signal0<void> hideDialog;
78 void insetButtonPress(BufferView *, int x, int y, int button);
80 bool insetButtonRelease(BufferView * bv, int x, int y, int button);
82 void insetMotionNotify(BufferView *, int x, int y, int state);
84 int latex(Buffer const *, std::ostream &, bool fragile,
87 int ascii(Buffer const *,
88 std::ostream &, int linelen = 0) const;
90 int linuxdoc(Buffer const *, std::ostream &) const;
92 int docbook(Buffer const *, std::ostream &) const;
94 void validate(LaTeXFeatures &) const {}
96 UpdatableInset::RESULT localDispatch(BufferView *, kb_action,
99 bool checkInsertChar(LyXFont &);
101 // this are needed here because of the label/inlined functionallity
103 bool needFullRow() const { return status_ == Open; }
105 bool isOpen() const { return status_ == Open || status_ == Inlined; }
107 bool inlined() const { return status_ == Inlined; }
109 ERTStatus status() const { return status_; }
111 void open(BufferView *);
113 void close(BufferView *) const;
115 bool allowSpellcheck() { return false; }
116 string const selectNextWordToSpellcheck(BufferView *, float &) const;
118 int ascent(BufferView *, LyXFont const &) const;
120 int descent(BufferView *, LyXFont const &) const;
122 int width(BufferView *, LyXFont const &) const;
124 void draw(BufferView *, const LyXFont &, int , float &, bool) const;
125 /// set the status of the inset
126 void status(BufferView *, ERTStatus const st) const;
128 bool showInsetDialog(BufferView *) const;
130 void getDrawFont(LyXFont &) const;
132 bool forceDefaultParagraphs(Inset const *) const {
136 int getMaxWidth(BufferView *, UpdatableInset const *) 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_;