]> git.lyx.org Git - lyx.git/blob - src/insets/insetert.h
cursor changes
[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 /** A collapsable text inset for LaTeX insertions.
20
21   To write full ert (including styles and other insets) in a given
22   space.
23
24   Note that collapsed_ encompasses both the inline and collapsed button
25   versions of this inset.
26 */
27
28 class Language;
29
30 class InsetERT : public InsetCollapsable {
31 public:
32         ///
33         enum ERTStatus {
34                 Open,
35                 Collapsed,
36                 Inlined
37         };
38         ///
39         InsetERT(BufferParams const &, bool collapsed = false);
40         ///
41         InsetERT(InsetERT const &);
42         ///
43         virtual std::auto_ptr<InsetBase> clone() const;
44         ///
45         InsetERT(BufferParams const &,
46                  Language const *, std::string const & contents, bool collapsed);
47         ///
48         ~InsetERT();
49         ///
50         InsetOld::Code lyxCode() const { return InsetOld::ERT_CODE; }
51         ///
52         void read(Buffer const & buf, LyXLex & lex);
53         ///
54         void write(Buffer const & buf, std::ostream & os) const;
55         ///
56         std::string const editMessage() const;
57         ///
58         bool insertInset(BufferView *, InsetOld *);
59         ///
60         bool insetAllowed(InsetOld::Code code) const { return code == InsetOld::NEWLINE_CODE; }
61         ///
62         void setFont(BufferView *, LyXFont const &,
63                              bool toggleall = false, bool selectall = false);
64         ///
65         EDITABLE editable() const;
66         ///
67         int latex(Buffer const &, std::ostream &,
68                   LatexRunParams const &) const;
69         ///
70         int ascii(Buffer const &, std::ostream &,
71                   LatexRunParams const & runparams) const;
72         ///
73         int linuxdoc(Buffer const &, std::ostream &,
74                      LatexRunParams const &) const;
75         ///
76         int docbook(Buffer const &, std::ostream &,
77                     LatexRunParams const & runparams) const;
78         ///
79         void validate(LaTeXFeatures &) const {}
80         ///
81         bool checkInsertChar(LyXFont &);
82         ///
83         // these are needed here because of the label/inlined functionallity
84         ///
85         bool isOpen() const { return status_ == Open || status_ == Inlined; }
86         ///
87         bool inlined() const { return status_ == Inlined; }
88         ///
89         ERTStatus status() const { return status_; }
90         ///
91         void open(BufferView *);
92         ///
93         void close(BufferView *) const;
94         ///
95         void metrics(MetricsInfo &, Dimension &) const;
96         ///
97         void draw(PainterInfo & pi, int x, int y) const;
98         /// set the status of the inset
99         void status(BufferView *, ERTStatus const st) const;
100         ///
101         bool showInsetDialog(BufferView *) const;
102         ///
103         void getDrawFont(LyXFont &) const;
104         ///
105         bool forceDefaultParagraphs(InsetOld const *) const {
106                 return true;
107         }
108 protected:
109         ///
110         virtual
111         DispatchResult
112         priv_dispatch(FuncRequest const &, idx_type &, pos_type &);
113 private:
114         ///
115         void lfunMousePress(FuncRequest const &);
116         ///
117         // the bool return is used to see if we opened a dialog so that we can
118         // check this from an outer inset and open the dialog of the outer inset
119         // if that one has one!
120         ///
121         bool lfunMouseRelease(FuncRequest const &);
122         ///
123         void lfunMouseMotion(FuncRequest const &);
124         ///
125         void init();
126         ///
127         std::string const get_new_label() const;
128         ///
129         void setButtonLabel() const;
130         ///
131         void set_latex_font(BufferView *);
132         /// update status on button
133         void updateStatus(BufferView *, bool = false) const;
134         ///
135         void edit(BufferView * bv, bool left);
136
137         ///
138         mutable ERTStatus status_;
139 };
140
141
142 #include "mailinset.h"
143
144 class InsetERTMailer : public MailInset {
145 public:
146         ///
147         InsetERTMailer(InsetERT & inset);
148         ///
149         virtual InsetBase & inset() const { return inset_; }
150         ///
151         virtual std::string const & name() const { return name_; }
152         ///
153         virtual std::string const inset2string(Buffer const &) const;
154         ///
155         static void string2params(std::string const &, InsetERT::ERTStatus &);
156         ///
157         static std::string const params2string(InsetERT::ERTStatus);
158 private:
159         ///
160         static std::string const name_;
161         ///
162         InsetERT & inset_;
163 };
164
165 #endif