]> git.lyx.org Git - lyx.git/blob - src/insets/insetert.h
Don't remove cell selections after fontchange.
[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   Note that collapsed_ encompasses both the inline and collapsed button
30   versions of this inset. 
31 */
32 class InsetERT : public InsetCollapsable {
33 public:
34         ///
35         enum ERTStatus {
36                 Open,
37                 Collapsed,
38                 Inlined
39         };
40         ///
41         InsetERT(bool collapsed=false);
42         ///
43         InsetERT(InsetERT const &, bool same_id = false);
44         ///
45         Inset * clone(Buffer const &, bool same_id = false) const;
46         ///
47         InsetERT(string const & contents, bool collapsed);
48         ///
49         ~InsetERT();
50         ///
51         Inset::Code lyxCode() const { return Inset::ERT_CODE; }
52         ///
53         void read(Buffer const * buf, LyXLex & lex);
54         ///
55         void write(Buffer const * buf, std::ostream & os) const;
56         ///
57         string const editMessage() const;
58         ///
59         bool insertInset(BufferView *, Inset *);
60         ///
61         bool insetAllowed(Inset::Code) const { return false; }
62         ///
63         void setFont(BufferView *, LyXFont const &,
64                              bool toggleall = false, bool selectall = false);
65         ///
66         void edit(BufferView *, int, int, unsigned int);
67         ///
68         void edit(BufferView * bv, bool front = true);
69         ///
70         EDITABLE editable() const;
71         ///
72         SigC::Signal0<void> hideDialog;
73         ///
74         void insetButtonPress(BufferView *, int x, int y, int button);
75         ///
76         bool insetButtonRelease(BufferView * bv, int x, int y, int button);
77         ///
78         void insetMotionNotify(BufferView *, int x, int y, int state);
79         ///
80         int latex(Buffer const *, std::ostream &, bool fragile,
81                   bool free_spc) const;
82         ///
83         int ascii(Buffer const *,
84                           std::ostream &, int linelen = 0) const;
85         ///
86         int linuxdoc(Buffer const *, std::ostream &) const;
87         ///
88         int docbook(Buffer const *, std::ostream &) const;
89         ///
90         void validate(LaTeXFeatures &) const {}
91         ///
92         UpdatableInset::RESULT localDispatch(BufferView *, kb_action,
93                                              string const &);
94         ///
95         bool checkInsertChar(LyXFont &);
96         ///
97         // this are needed here because of the label/inlined functionallity
98         ///
99         bool needFullRow() const { return status_ == Open; }
100         ///
101         bool isOpen() const { return status_ == Open || status_ == Inlined; }
102         ///
103         bool inlined() const { return status_ == Inlined; }
104         ///
105         ERTStatus status() const { return status_; }
106         ///
107         void open(BufferView *);
108         ///
109         void close(BufferView *) const;
110         ///
111         bool allowSpellcheck() { return false; }
112         string const selectNextWordToSpellcheck(BufferView *, float &) const;
113         ///
114         int ascent(BufferView *, LyXFont const &) const;
115         ///
116         int descent(BufferView *, LyXFont const &) const;
117         ///
118         int width(BufferView *, LyXFont const &) const;
119         ///
120         void draw(BufferView *, const LyXFont &, int , float &, bool) const;
121         /// set the status of the inset
122         void status(BufferView *, ERTStatus const st) const;
123         ///
124         bool showInsetDialog(BufferView *) const;
125         ///
126         bool forceDefaultParagraphs(Inset const *) const {
127                 return true;
128         }
129
130 private:
131         ///
132         void init();
133         ///
134         string const get_new_label() const;
135         ///
136         void setButtonLabel() const;
137         ///
138         void set_latex_font(BufferView *);
139         /// update status on button
140         void updateStatus(BufferView *, bool = false) const;
141
142         ///
143         mutable ERTStatus status_;
144 };
145
146 #endif