]> git.lyx.org Git - lyx.git/blob - src/insets/insetert.h
89f211c137d6842a4c80231fe3a7a39c6111aaeb
[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 &);
42         ///
43         //InsetERT(InsetERT const &, bool same_id);
44         ///
45         Inset * clone(Buffer const &) const;
46         ///
47         //Inset * clone(Buffer const &, bool same_id) const;
48         ///
49         InsetERT(BufferParams const &,
50                  Language const *, string const & contents, bool collapsed);
51         ///
52         ~InsetERT();
53         ///
54         Inset::Code lyxCode() const { return Inset::ERT_CODE; }
55         ///
56         void read(Buffer const * buf, LyXLex & lex);
57         ///
58         void write(Buffer const * buf, std::ostream & os) const;
59         ///
60         string const editMessage() const;
61         ///
62         bool insertInset(BufferView *, Inset *);
63         ///
64         bool insetAllowed(Inset::Code code) const { return code == Inset::NEWLINE_CODE; }
65         ///
66         void setFont(BufferView *, LyXFont const &,
67                              bool toggleall = false, bool selectall = false);
68         ///
69         EDITABLE editable() const;
70         ///
71         int latex(Buffer const *, std::ostream &,
72                   LatexRunParams const &) 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         void dimension(BufferView *, LyXFont const &, Dimension &) const;
107         ///
108         void draw(BufferView *, const LyXFont &, int , float &) const;
109         /// set the status of the inset
110         void status(BufferView *, ERTStatus const st) const;
111         ///
112         bool showInsetDialog(BufferView *) const;
113         ///
114         void getDrawFont(LyXFont &) const;
115         ///
116         bool forceDefaultParagraphs(Inset const *) const {
117                 return true;
118         }
119         ///
120         int getMaxWidth(BufferView *, UpdatableInset const *) const;
121         ///
122         void update(BufferView *, bool =false);
123
124 private:
125         ///
126         void lfunMousePress(FuncRequest const &);
127         ///
128         // the bool return is used to see if we opened a dialog so that we can
129         // check this from an outer inset and open the dialog of the outer inset
130         // if that one has one!
131         ///
132         bool lfunMouseRelease(FuncRequest const &);
133         ///
134         void lfunMouseMotion(FuncRequest const &);
135         ///
136         void init();
137         ///
138         string const get_new_label() const;
139         ///
140         void setButtonLabel() const;
141         ///
142         void set_latex_font(BufferView *);
143         /// update status on button
144         void updateStatus(BufferView *, bool = false) const;
145
146         ///
147         mutable ERTStatus status_;
148 };
149
150
151 #include "mailinset.h"
152
153 class InsetERTMailer : public MailInset {
154 public:
155         ///
156         InsetERTMailer(InsetERT & inset);
157         ///
158         virtual InsetBase & inset() const { return inset_; }
159         ///
160         virtual string const & name() const { return name_; }
161         ///
162         virtual string const inset2string() const;
163         ///
164         static void string2params(string const &, InsetERT::ERTStatus &);
165         ///
166         static string const params2string(InsetERT::ERTStatus);
167 private:
168         ///
169         static string const name_;
170         ///
171         InsetERT & inset_;
172 };
173
174 #endif