]> git.lyx.org Git - lyx.git/blob - src/insets/insetert.h
Clean-up the behaviour of the inset when not displaying the image.
[lyx.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         string const selectNextWordToSpellcheck(BufferView *, float &) const;
101         ///
102         bool inlined() const { return status_ == Inlined; }
103         ///
104         int ascent(BufferView *, LyXFont const &) const;
105         ///
106         int descent(BufferView *, LyXFont const &) const;
107         ///
108         int width(BufferView *, LyXFont const &) const;
109         ///
110         void draw(BufferView *, const LyXFont &, int , float &, bool) const;
111         ///
112         ERTStatus status() const { return status_; }
113         ///
114         void status(BufferView *, ERTStatus const st) const;
115         ///
116         bool showInsetDialog(BufferView *) const;
117
118 private:
119         ///
120         void init();
121         ///
122         string const get_new_label() const;
123         ///
124         void setButtonLabel() const;
125         ///
126         void set_latex_font(BufferView *);
127
128         ///
129         mutable ERTStatus status_;
130 };
131
132 #endif