]> git.lyx.org Git - features.git/blob - src/insets/insetert.h
skak support, John's ERT fixes, loclae blunder fix
[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   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 insetButtonRelease(BufferView * bv, int x, int y, int button);
75         ///
76         int latex(Buffer const *, std::ostream &, bool fragile,
77                   bool free_spc) const;
78         ///
79         int ascii(Buffer const *,
80                           std::ostream &, int linelen = 0) const;
81         ///
82         int linuxdoc(Buffer const *, std::ostream &) const;
83         ///
84         int docbook(Buffer const *, std::ostream &) const;
85         ///
86         void validate(LaTeXFeatures &) const {}
87         ///
88         UpdatableInset::RESULT localDispatch(BufferView *, kb_action,
89                                              string const &);
90         ///
91         bool checkInsertChar(LyXFont &);
92         ///
93         // this are needed here because of the label/inlined functionallity
94         ///
95         bool needFullRow() const { return status_ == Open; }
96         ///
97         bool isOpen() const { return status_ == Open || status_ == Inlined; }
98         ///
99         bool inlined() const { return status_ == Inlined; }
100         ///
101         ERTStatus status() const { return status_; }
102         ///
103         void open(BufferView *);
104         ///
105         void close(BufferView *) const;
106         ///
107         bool allowSpellcheck() { return false; }
108         string const selectNextWordToSpellcheck(BufferView *, float &) const;
109         ///
110         int ascent(BufferView *, LyXFont const &) const;
111         ///
112         int descent(BufferView *, LyXFont const &) const;
113         ///
114         int width(BufferView *, LyXFont const &) const;
115         ///
116         void draw(BufferView *, const LyXFont &, int , float &, bool) const;
117         /// set the status of the inset
118         void status(BufferView *, ERTStatus const st) const;
119         ///
120         bool showInsetDialog(BufferView *) const;
121
122 private:
123         ///
124         void init();
125         ///
126         string const get_new_label() const;
127         ///
128         void setButtonLabel() const;
129         ///
130         void set_latex_font(BufferView *);
131         /// update status on button
132         void updateStatus(BufferView *, bool = false) const;
133
134         ///
135         mutable ERTStatus status_;
136 };
137
138 #endif