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