]> git.lyx.org Git - lyx.git/blob - src/insets/insetert.h
The free_spacing patch and fix to the mess that Rob discovered.
[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         EDITABLE editable() const;
66         ///
67         int latex(Buffer const *, std::ostream &,
68                   LatexRunParams const &) const;
69         ///
70         int ascii(Buffer const *,
71                           std::ostream &, int linelen = 0) const;
72         ///
73         int linuxdoc(Buffer const *, std::ostream &) const;
74         ///
75         int docbook(Buffer const *, std::ostream &, bool mixcont) const;
76         ///
77         void validate(LaTeXFeatures &) const {}
78         ///
79         RESULT localDispatch(FuncRequest const &);
80         ///
81         bool checkInsertChar(LyXFont &);
82         ///
83         // this are needed here because of the label/inlined functionallity
84         ///
85         bool needFullRow() const { return status_ == Open; }
86         ///
87         bool isOpen() const { return status_ == Open || status_ == Inlined; }
88         ///
89         bool inlined() const { return status_ == Inlined; }
90         ///
91         ERTStatus status() const { return status_; }
92         ///
93         void open(BufferView *);
94         ///
95         void close(BufferView *) const;
96         ///
97         bool allowSpellcheck() const { return false; }
98
99         WordLangTuple const
100         selectNextWordToSpellcheck(BufferView *, float &) const;
101         ///
102         void dimension(BufferView *, LyXFont const &, Dimension &) const;
103         ///
104         void draw(BufferView *, const LyXFont &, int , float &) const;
105         /// set the status of the inset
106         void status(BufferView *, ERTStatus const st) const;
107         ///
108         bool showInsetDialog(BufferView *) const;
109         ///
110         void getDrawFont(LyXFont &) const;
111         ///
112         bool forceDefaultParagraphs(Inset const *) const {
113                 return true;
114         }
115         ///
116         int getMaxWidth(BufferView *, UpdatableInset const *) const;
117         ///
118         void update(BufferView *, bool =false);
119
120 private:
121         ///
122         void lfunMousePress(FuncRequest const &);
123         ///
124         // the bool return is used to see if we opened a dialog so that we can
125         // check this from an outer inset and open the dialog of the outer inset
126         // if that one has one!
127         ///
128         bool lfunMouseRelease(FuncRequest const &);
129         ///
130         void lfunMouseMotion(FuncRequest const &);
131         ///
132         void init();
133         ///
134         string const get_new_label() const;
135         ///
136         void setButtonLabel() const;
137         ///
138         void set_latex_font(BufferView *);
139         /// update status on button
140         void updateStatus(BufferView *, bool = false) const;
141
142         ///
143         mutable ERTStatus status_;
144 };
145
146
147 #include "mailinset.h"
148
149 class InsetERTMailer : public MailInset {
150 public:
151         ///
152         InsetERTMailer(InsetERT & inset);
153         ///
154         virtual InsetBase & inset() const { return inset_; }
155         ///
156         virtual string const & name() const { return name_; }
157         ///
158         virtual string const inset2string() const;
159         ///
160         static void string2params(string const &, InsetERT::ERTStatus &);
161         ///
162         static string const params2string(InsetERT::ERTStatus);
163 private:
164         ///
165         static string const name_;
166         ///
167         InsetERT & inset_;
168 };
169
170 #endif