]> git.lyx.org Git - lyx.git/blob - src/insets/insetert.h
Fix for #143. Changed handling of Font stuff for ERTInsets so that the
[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 #include <sigc++/signal_system.h>
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(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(Language const *, string const & contents, bool collapsed);
51         ///
52         ~InsetERT();
53         ///
54         Inset::Code lyxCode() const { return Inset::ERT_CODE; }
55         ///
56         void read(Buffer const * buf, LyXLex & lex);
57         ///
58         void write(Buffer const * buf, std::ostream & os) const;
59         ///
60         string const editMessage() const;
61         ///
62         bool insertInset(BufferView *, Inset *);
63         ///
64         bool insetAllowed(Inset::Code) const { return false; }
65         ///
66         void setFont(BufferView *, LyXFont const &,
67                              bool toggleall = false, bool selectall = false);
68         ///
69         void edit(BufferView *, int, int, unsigned int);
70         ///
71         void edit(BufferView * bv, bool front = true);
72         ///
73         EDITABLE editable() const;
74         ///
75         SigC::Signal0<void> hideDialog;
76         ///
77         void insetButtonPress(BufferView *, int x, int y, int button);
78         ///
79         bool insetButtonRelease(BufferView * bv, int x, int y, int button);
80         ///
81         void insetMotionNotify(BufferView *, int x, int y, int state);
82         ///
83         int latex(Buffer const *, std::ostream &, bool fragile,
84                   bool free_spc) const;
85         ///
86         int ascii(Buffer const *,
87                           std::ostream &, int linelen = 0) const;
88         ///
89         int linuxdoc(Buffer const *, std::ostream &) const;
90         ///
91         int docbook(Buffer const *, std::ostream &) const;
92         ///
93         void validate(LaTeXFeatures &) const {}
94         ///
95         UpdatableInset::RESULT localDispatch(BufferView *, kb_action,
96                                              string const &);
97         ///
98         bool checkInsertChar(LyXFont &);
99         ///
100         // this are needed here because of the label/inlined functionallity
101         ///
102         bool needFullRow() const { return status_ == Open; }
103         ///
104         bool isOpen() const { return status_ == Open || status_ == Inlined; }
105         ///
106         bool inlined() const { return status_ == Inlined; }
107         ///
108         ERTStatus status() const { return status_; }
109         ///
110         void open(BufferView *);
111         ///
112         void close(BufferView *) const;
113         ///
114         bool allowSpellcheck() { return false; }
115         string const selectNextWordToSpellcheck(BufferView *, float &) const;
116         ///
117         int ascent(BufferView *, LyXFont const &) const;
118         ///
119         int descent(BufferView *, LyXFont const &) const;
120         ///
121         int width(BufferView *, LyXFont const &) const;
122         ///
123         void draw(BufferView *, const LyXFont &, int , float &, bool) const;
124         /// set the status of the inset
125         void status(BufferView *, ERTStatus const st) const;
126         ///
127         bool showInsetDialog(BufferView *) const;
128         ///
129         void getDrawFont(LyXFont &) const;
130         ///
131         bool forceDefaultParagraphs(Inset const *) const {
132                 return true;
133         }
134
135 private:
136         ///
137         void init();
138         ///
139         string const get_new_label() const;
140         ///
141         void setButtonLabel() const;
142         ///
143         void set_latex_font(BufferView *);
144         /// update status on button
145         void updateStatus(BufferView *, bool = false) const;
146
147         ///
148         mutable ERTStatus status_;
149 };
150
151 #endif