]> git.lyx.org Git - lyx.git/blob - src/insets/insetert.h
The markDirty() and fitCursor() changes
[lyx.git] / src / insets / insetert.h
1 // -*- C++ -*-
2 /**
3  * \file insetert.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Jürgen Vigna
8  * \author Lars Gullik Bjønnes
9  *
10  * Full author contact details are available in file CREDITS
11  */
12
13 #ifndef INSETERT_H
14 #define INSETERT_H
15
16
17 #include "insetcollapsable.h"
18
19 /** A collapsable text inset for LaTeX insertions.
20
21   To write full ert (including styles and other insets) in a given
22   space.
23
24   Note that collapsed_ encompasses both the inline and collapsed button
25   versions of this inset.
26 */
27
28 class Language;
29
30 class InsetERT : public InsetCollapsable {
31 public:
32         ///
33         enum ERTStatus {
34                 Open,
35                 Collapsed,
36                 Inlined
37         };
38         ///
39         InsetERT(BufferParams const &, bool collapsed = false);
40         ///
41         InsetERT(InsetERT const &, bool same_id = false);
42         ///
43         Inset * clone(Buffer const &, bool same_id = false) const;
44         ///
45         InsetERT(BufferParams const &,
46                  Language const *, string const & contents, bool collapsed);
47         ///
48         ~InsetERT();
49         ///
50         Inset::Code lyxCode() const { return Inset::ERT_CODE; }
51         ///
52         void read(Buffer const * buf, LyXLex & lex);
53         ///
54         void write(Buffer const * buf, std::ostream & os) const;
55         ///
56         string const editMessage() const;
57         ///
58         bool insertInset(BufferView *, Inset *);
59         ///
60         bool insetAllowed(Inset::Code code) const { return code == Inset::NEWLINE_CODE; }
61         ///
62         void setFont(BufferView *, LyXFont const &,
63                              bool toggleall = false, bool selectall = false);
64         ///
65         void edit(BufferView *, int, int, mouse_button::state);
66         ///
67         void edit(BufferView * bv, bool front = true);
68         ///
69         EDITABLE editable() const;
70         ///
71         int latex(Buffer const *, std::ostream &, bool fragile,
72                   bool free_spc) const;
73         ///
74         int ascii(Buffer const *,
75                           std::ostream &, int linelen = 0) const;
76         ///
77         int linuxdoc(Buffer const *, std::ostream &) const;
78         ///
79         int docbook(Buffer const *, std::ostream &, bool mixcont) const;
80         ///
81         void validate(LaTeXFeatures &) const {}
82         ///
83         RESULT localDispatch(FuncRequest const &);
84         ///
85         bool checkInsertChar(LyXFont &);
86         ///
87         // this are needed here because of the label/inlined functionallity
88         ///
89         bool needFullRow() const { return status_ == Open; }
90         ///
91         bool isOpen() const { return status_ == Open || status_ == Inlined; }
92         ///
93         bool inlined() const { return status_ == Inlined; }
94         ///
95         ERTStatus status() const { return status_; }
96         ///
97         void open(BufferView *);
98         ///
99         void close(BufferView *) const;
100         ///
101         bool allowSpellcheck() const { return false; }
102
103         WordLangTuple const
104         selectNextWordToSpellcheck(BufferView *, float &) const;
105         ///
106         int ascent(BufferView *, LyXFont const &) const;
107         ///
108         int descent(BufferView *, LyXFont const &) const;
109         ///
110         int width(BufferView *, LyXFont const &) const;
111         ///
112         void draw(BufferView *, const LyXFont &, int , float &) const;
113         /// set the status of the inset
114         void status(BufferView *, ERTStatus const st) const;
115         ///
116         bool showInsetDialog(BufferView *) const;
117         ///
118         void getDrawFont(LyXFont &) const;
119         ///
120         bool forceDefaultParagraphs(Inset const *) const {
121                 return true;
122         }
123         ///
124         int getMaxWidth(BufferView *, UpdatableInset const *) const;
125         ///
126         void update(BufferView *, LyXFont const &, bool =false);
127
128 private:
129         ///
130         void lfunMousePress(FuncRequest const &);
131         ///
132         // the bool return is used to see if we opened a dialog so that we can
133         // check this from an outer inset and open the dialog of the outer inset
134         // if that one has one!
135         ///
136         bool lfunMouseRelease(FuncRequest const &);
137         ///
138         void lfunMouseMotion(FuncRequest const &);
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
155 #include "mailinset.h"
156
157 class InsetERTMailer : public MailInset {
158 public:
159         ///
160         InsetERTMailer(InsetERT & inset);
161         ///
162         virtual InsetBase & inset() const { return inset_; }
163         ///
164         virtual string const & name() const { return name_; }
165         ///
166         virtual string const inset2string() const;
167         ///
168         static void string2params(string const &, InsetERT::ERTStatus &);
169         ///
170         static string const params2string(InsetERT::ERTStatus);
171 private:
172         ///
173         static string const name_;
174         ///
175         InsetERT & inset_;
176 };
177
178 #endif