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