]> git.lyx.org Git - lyx.git/blob - src/insets/insetert.h
redraw fix 1.
[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         void insetButtonPress(BufferView *, int x, int y, mouse_button::state button);
80         ///
81         bool insetButtonRelease(BufferView * bv, int x, int y, mouse_button::state button);
82         ///
83         void insetMotionNotify(BufferView *, int x, int y, mouse_button::state state);
84         ///
85         int latex(Buffer const *, std::ostream &, bool fragile,
86                   bool free_spc) const;
87         ///
88         int ascii(Buffer const *,
89                           std::ostream &, int linelen = 0) const;
90         ///
91         int linuxdoc(Buffer const *, std::ostream &) const;
92         ///
93         int docbook(Buffer const *, std::ostream &, bool mixcont) const;
94         ///
95         void validate(LaTeXFeatures &) const {}
96         ///
97         UpdatableInset::RESULT localDispatch(BufferView *, kb_action,
98                                              string const &);
99         ///
100         bool checkInsertChar(LyXFont &);
101         ///
102         // this are needed here because of the label/inlined functionallity
103         ///
104         bool needFullRow() const { return status_ == Open; }
105         ///
106         bool isOpen() const { return status_ == Open || status_ == Inlined; }
107         ///
108         bool inlined() const { return status_ == Inlined; }
109         ///
110         ERTStatus status() const { return status_; }
111         ///
112         void open(BufferView *);
113         ///
114         void close(BufferView *) const;
115         ///
116         bool allowSpellcheck() { return false; }
117         string const selectNextWordToSpellcheck(BufferView *, float &) const;
118         ///
119         int ascent(BufferView *, LyXFont const &) const;
120         ///
121         int descent(BufferView *, LyXFont const &) const;
122         ///
123         int width(BufferView *, LyXFont const &) const;
124         ///
125         void draw(BufferView *, const LyXFont &, int , float &, bool) const;
126         /// set the status of the inset
127         void status(BufferView *, ERTStatus const st) const;
128         ///
129         bool showInsetDialog(BufferView *) const;
130         ///
131         void getDrawFont(LyXFont &) const;
132         ///
133         bool forceDefaultParagraphs(Inset const *) const {
134                 return true;
135         }
136         ///
137         int getMaxWidth(BufferView *, UpdatableInset const *) const;
138         ///
139         void update(BufferView *, LyXFont const &, bool =false);
140
141 private:
142         ///
143         void init();
144         ///
145         string const get_new_label() const;
146         ///
147         void setButtonLabel() const;
148         ///
149         void set_latex_font(BufferView *);
150         /// update status on button
151         void updateStatus(BufferView *, bool = false) const;
152
153         ///
154         mutable ERTStatus status_;
155 };
156
157 #endif