]> git.lyx.org Git - lyx.git/blob - src/insets/insetert.h
First step towards unified insets...
[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 #include <boost/signals/signal0.hpp>
20
21 /** A collapsable text inset for LaTeX insertions.
22
23   To write full ert (including styles and other insets) in a given
24   space.
25
26   Note that collapsed_ encompasses both the inline and collapsed button
27   versions of this inset.
28 */
29
30 class Language;
31
32 class InsetERT : public InsetCollapsable {
33 public:
34         ///
35         enum ERTStatus {
36                 Open,
37                 Collapsed,
38                 Inlined
39         };
40         ///
41         InsetERT(BufferParams const &, bool collapsed = false);
42         ///
43         InsetERT(InsetERT const &, bool same_id = false);
44         ///
45         Inset * clone(Buffer const &, bool same_id = false) const;
46         ///
47         InsetERT(BufferParams const &,
48                  Language const *, string const & contents, bool collapsed);
49         ///
50         ~InsetERT();
51         ///
52         Inset::Code lyxCode() const { return Inset::ERT_CODE; }
53         ///
54         void read(Buffer const * buf, LyXLex & lex);
55         ///
56         void write(Buffer const * buf, std::ostream & os) const;
57         ///
58         string const editMessage() const;
59         ///
60         bool insertInset(BufferView *, Inset *);
61         ///
62         bool insetAllowed(Inset::Code) const { return false; }
63         ///
64         void setFont(BufferView *, LyXFont const &,
65                              bool toggleall = false, bool selectall = false);
66         ///
67         void edit(BufferView *, int, int, mouse_button::state);
68         ///
69         void edit(BufferView * bv, bool front = true);
70         ///
71         EDITABLE editable() const;
72         ///
73         boost::signal0<void> hideDialog;
74         ///
75         int latex(Buffer const *, std::ostream &, bool fragile,
76                   bool free_spc) const;
77         ///
78         int ascii(Buffer const *,
79                           std::ostream &, int linelen = 0) const;
80         ///
81         int linuxdoc(Buffer const *, std::ostream &) const;
82         ///
83         int docbook(Buffer const *, std::ostream &, bool mixcont) const;
84         ///
85         void validate(LaTeXFeatures &) const {}
86         ///
87         RESULT localDispatch(FuncRequest const &);
88         ///
89         bool checkInsertChar(LyXFont &);
90         ///
91         // this are needed here because of the label/inlined functionallity
92         ///
93         bool needFullRow() const { return status_ == Open; }
94         ///
95         bool isOpen() const { return status_ == Open || status_ == Inlined; }
96         ///
97         bool inlined() const { return status_ == Inlined; }
98         ///
99         ERTStatus status() const { return status_; }
100         ///
101         void open(BufferView *);
102         ///
103         void close(BufferView *) const;
104         ///
105         bool allowSpellcheck() const { return false; }
106
107         WordLangTuple const
108         selectNextWordToSpellcheck(BufferView *, float &) const;
109         ///
110         int ascent(BufferView *, LyXFont const &) const;
111         ///
112         int descent(BufferView *, LyXFont const &) const;
113         ///
114         int width(BufferView *, LyXFont const &) const;
115         ///
116         void draw(BufferView *, const LyXFont &, int , float &, bool) const;
117         /// set the status of the inset
118         void status(BufferView *, ERTStatus const st) const;
119         ///
120         bool showInsetDialog(BufferView *) const;
121         ///
122         void getDrawFont(LyXFont &) const;
123         ///
124         bool forceDefaultParagraphs(Inset const *) const {
125                 return true;
126         }
127         ///
128         int getMaxWidth(BufferView *, UpdatableInset const *) const;
129         ///
130         void update(BufferView *, LyXFont const &, bool =false);
131
132 private:
133         ///
134         void lfunMousePress(FuncRequest const &);
135         ///
136         // the bool return is used to see if we opened a dialog so that we can
137         // check this from an outer inset and open the dialog of the outer inset
138         // if that one has one!
139         ///
140         bool lfunMouseRelease(FuncRequest const &);
141         ///
142         void lfunMouseMotion(FuncRequest const &);
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