]> git.lyx.org Git - lyx.git/blob - src/insets/insetert.h
68ab64ce4298207dd1aef3731df096afa4bd9fba
[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
23 #include <boost/signals/signal0.hpp>
24
25 /** A collapsable text inset for LaTeX insertions.
26
27   To write full ert (including styles and other insets) in a given
28   space.
29
30   Note that collapsed_ encompasses both the inline and collapsed button
31   versions of this inset.
32 */
33
34 class Language;
35
36 class InsetERT : public InsetCollapsable {
37 public:
38         ///
39         enum ERTStatus {
40                 Open,
41                 Collapsed,
42                 Inlined
43         };
44         ///
45         InsetERT(BufferParams const &, bool collapsed = false);
46         ///
47         InsetERT(InsetERT const &, bool same_id = false);
48         ///
49         Inset * clone(Buffer const &, bool same_id = false) const;
50         ///
51         InsetERT(BufferParams const &,
52                  Language const *, string const & contents, bool collapsed);
53         ///
54         ~InsetERT();
55         ///
56         Inset::Code lyxCode() const { return Inset::ERT_CODE; }
57         ///
58         void read(Buffer const * buf, LyXLex & lex);
59         ///
60         void write(Buffer const * buf, std::ostream & os) const;
61         ///
62         string const editMessage() const;
63         ///
64         bool insertInset(BufferView *, Inset *);
65         ///
66         bool insetAllowed(Inset::Code) const { return false; }
67         ///
68         void setFont(BufferView *, LyXFont const &,
69                              bool toggleall = false, bool selectall = false);
70         ///
71         void edit(BufferView *, int, int, mouse_button::state);
72         ///
73         void edit(BufferView * bv, bool front = true);
74         ///
75         EDITABLE editable() const;
76         ///
77         boost::signal0<void> hideDialog;
78         ///
79         void insetButtonPress(BufferView *, int x, int y, mouse_button::state button);
80         ///
81         bool insetButtonRelease(BufferView * bv, int x, int y, mouse_button::state button);
82         ///
83         void insetMotionNotify(BufferView *, int x, int y, mouse_button::state state);
84         ///
85         int latex(Buffer const *, std::ostream &, bool fragile,
86                   bool free_spc) const;
87         ///
88         int ascii(Buffer const *,
89                           std::ostream &, int linelen = 0) const;
90         ///
91         int linuxdoc(Buffer const *, std::ostream &) const;
92         ///
93         int docbook(Buffer const *, std::ostream &, bool mixcont) const;
94         ///
95         void validate(LaTeXFeatures &) const {}
96         ///
97         RESULT localDispatch(FuncRequest 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
117         WordLangTuple const
118         selectNextWordToSpellcheck(BufferView *, float &) const;
119         ///
120         int ascent(BufferView *, LyXFont const &) const;
121         ///
122         int descent(BufferView *, LyXFont const &) const;
123         ///
124         int width(BufferView *, LyXFont const &) const;
125         ///
126         void draw(BufferView *, const LyXFont &, int , float &, bool) const;
127         /// set the status of the inset
128         void status(BufferView *, ERTStatus const st) const;
129         ///
130         bool showInsetDialog(BufferView *) const;
131         ///
132         void getDrawFont(LyXFont &) const;
133         ///
134         bool forceDefaultParagraphs(Inset const *) const {
135                 return true;
136         }
137         ///
138         int getMaxWidth(BufferView *, UpdatableInset const *) const;
139         ///
140         void update(BufferView *, LyXFont const &, bool =false);
141
142 private:
143         ///
144         void init();
145         ///
146         string const get_new_label() const;
147         ///
148         void setButtonLabel() const;
149         ///
150         void set_latex_font(BufferView *);
151         /// update status on button
152         void updateStatus(BufferView *, bool = false) const;
153
154         ///
155         mutable ERTStatus status_;
156 };
157
158 #endif