]> git.lyx.org Git - features.git/blob - src/insets/insetert.h
655953f502043956b724b2f164eafdfd72ee26c2
[features.git] / src / insets / insetert.h
1 // -*- C++ -*-
2 /* This file is part of
3  * ======================================================
4  * 
5  *           LyX, The Document Processor
6  *
7  *           Copyright 1998 The LyX Team.
8  *
9  *======================================================
10  */
11 // The pristine updatable inset: Text
12
13
14 #ifndef INSETERT_H
15 #define INSETERT_H
16
17 #ifdef __GNUG__
18 #pragma interface
19 #endif
20
21 #include "insetcollapsable.h"
22 #include <sigc++/signal_system.h>
23
24 /** A collapsable text inset for LaTeX insertions.
25   
26   To write full ert (including styles and other insets) in a given
27   space. 
28 */
29 class InsetERT : public InsetCollapsable {
30 public:
31         ///
32         enum ERTStatus {
33                 Open,
34                 Collapsed,
35                 Inlined
36         };
37         ///
38         InsetERT(bool collapsed=false);
39         ///
40         InsetERT(InsetERT const &, bool same_id = false);
41         ///
42         Inset * clone(Buffer const &, bool same_id = false) const;
43         ///
44         InsetERT(string const & contents, bool collapsed);
45         ///
46         ~InsetERT();
47         ///
48         Inset::Code lyxCode() const { return Inset::ERT_CODE; }
49         ///
50         void read(Buffer const * buf, LyXLex & lex);
51         ///
52         void write(Buffer const * buf, std::ostream & os) const;
53         ///
54         string const editMessage() const;
55         ///
56         bool insertInset(BufferView *, Inset *);
57         ///
58         bool insetAllowed(Inset::Code) const { return false; }
59         ///
60         void setFont(BufferView *, LyXFont const &,
61                              bool toggleall = false, bool selectall = false);
62         ///
63         void edit(BufferView *, int, int, unsigned int);
64         ///
65         void edit(BufferView * bv, bool front = true);
66         ///
67         EDITABLE editable() const;
68         ///
69         SigC::Signal0<void> hideDialog;
70         ///
71         void insetButtonRelease(BufferView * bv, int x, int y, int button);
72         ///
73         int latex(Buffer const *, std::ostream &, bool fragile,
74                   bool free_spc) const;
75         ///
76         int ascii(Buffer const *,
77                           std::ostream &, int linelen = 0) const;
78         ///
79         int linuxdoc(Buffer const *, std::ostream &) const;
80         ///
81         int docbook(Buffer const *, std::ostream &) const;
82         ///
83         void validate(LaTeXFeatures &) const {}
84         ///
85         UpdatableInset::RESULT localDispatch(BufferView *, kb_action,
86                                              string const &);
87         ///
88         bool checkInsertChar(LyXFont &);
89         ///
90         // this are needed here because of the label/inlined functionallity
91         ///
92         bool needFullRow() const { return status_ == Open; }
93         ///
94         bool isOpen() const { return status_ == Open || status_ == Inlined; }
95         ///
96         void open(BufferView *);
97         ///
98         void close(BufferView *) const;
99         ///
100         bool allowSpellcheck() { return false; }
101         string const selectNextWordToSpellcheck(BufferView *, float &) const;
102         ///
103         bool inlined() const { return status_ == Inlined; }
104         ///
105         int ascent(BufferView *, LyXFont const &) const;
106         ///
107         int descent(BufferView *, LyXFont const &) const;
108         ///
109         int width(BufferView *, LyXFont const &) const;
110         ///
111         void draw(BufferView *, const LyXFont &, int , float &, bool) const;
112         ///
113         ERTStatus status() const { return status_; }
114         ///
115         void status(BufferView *, ERTStatus const st) const;
116         ///
117         bool showInsetDialog(BufferView *) const;
118
119 private:
120         ///
121         void init();
122         ///
123         string const get_new_label() const;
124         ///
125         void setButtonLabel() const;
126         ///
127         void set_latex_font(BufferView *);
128
129         ///
130         mutable ERTStatus status_;
131 };
132
133 #endif