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