]> git.lyx.org Git - lyx.git/blob - src/insets/insetinclude.h
Re-add the RasterImage template.
[lyx.git] / src / insets / insetinclude.h
1 // -*- C++ -*-
2 /**
3  * \file insetinclude.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Lars Gullik Bjønnes
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef INSET_INCLUDE_H
13 #define INSET_INCLUDE_H
14
15 #include "inset.h"
16 #include "insetcommandparams.h"
17 #include "renderers.h"
18 #include <boost/scoped_ptr.hpp>
19
20
21 class Buffer;
22 class Dimension;
23 struct LaTeXFeatures;
24
25 // Created by AAS 970521
26
27 /// for including tex/lyx files
28 class InsetInclude: public InsetOld {
29 public:
30         ///
31         InsetInclude(InsetCommandParams const &);
32         InsetInclude(InsetInclude const &);
33         ~InsetInclude();
34
35         ///
36         virtual std::auto_ptr<InsetBase> clone() const;
37
38         ///
39         virtual dispatch_result localDispatch(FuncRequest const & cmd);
40
41         /// Override these InsetButton methods if Previewing
42         void metrics(MetricsInfo & mi, Dimension & dim) const;
43         ///
44         void draw(PainterInfo & pi, int x, int y) const;
45         ///
46         virtual BufferView * view() const;
47
48         /// get the parameters
49         InsetCommandParams const & params(void) const;
50
51         ///
52         InsetOld::Code lyxCode() const { return InsetOld::INCLUDE_CODE; }
53         /** Fills \c list
54          *  \param buffer the Buffer containing this inset.
55          *  \param list the list of labels in the child buffer.
56          */
57         void getLabelList(Buffer const & buffer,
58                           std::vector<string> & list) const;
59         /** Fills \c keys
60          *  \param buffer the Buffer containing this inset.
61          *  \param keys the list of bibkeys in the child buffer.
62          */
63         ///
64         void fillWithBibKeys(Buffer const & buffer,
65                 std::vector<std::pair<string,string> > & keys) const;
66         ///
67         EDITABLE editable() const { return IS_EDITABLE; }
68         ///
69         void write(Buffer const &, std::ostream &) const;
70         ///
71         void read(Buffer const &, LyXLex &);
72         ///
73         int latex(Buffer const &, std::ostream &, LatexRunParams const &) const;
74         ///
75         int ascii(Buffer const &, std::ostream &, int linelen) const;
76         ///
77         int linuxdoc(Buffer const &, std::ostream &) const;
78         ///
79         int docbook(Buffer const &, std::ostream &, bool mixcont) const;
80         ///
81         void validate(LaTeXFeatures &) const;
82         ///
83         void addPreview(lyx::graphics::PreviewLoader &) const;
84
85 private:
86         friend class InsetIncludeMailer;
87
88         /// set the parameters
89         void set(InsetCommandParams const & params, Buffer const &);
90         /// get the text displayed on the button
91         string const getScreenLabel(Buffer const &) const;
92         ///
93         void write(std::ostream &) const;
94         ///
95         void read(LyXLex &);
96
97         /// the parameters
98         InsetCommandParams params_;
99         /// holds the entity name that defines the file location (SGML)
100         string const include_label;
101
102         /// Use the Pimpl idiom to hide the internals of the previewer.
103         class PreviewImpl;
104         friend class PreviewImpl;
105         /// The pointer never changes although *preview_'s contents may.
106         boost::scoped_ptr<PreviewImpl> const preview_;
107
108         /// cache
109         mutable bool set_label_;
110         mutable ButtonRenderer button_;
111 };
112
113
114 #include "mailinset.h"
115
116 class InsetIncludeMailer : public MailInset {
117 public:
118         ///
119         InsetIncludeMailer(InsetInclude & inset);
120         ///
121         virtual InsetBase & inset() const { return inset_; }
122         ///
123         virtual string const & name() const { return name_; }
124         ///
125         virtual string const inset2string(Buffer const &) const;
126         ///
127         static void string2params(string const &, InsetCommandParams &);
128         ///
129         static string const params2string(InsetCommandParams const &);
130 private:
131         ///
132         static string const name_;
133         ///
134         InsetInclude & inset_;
135 };
136
137 #endif // INSETINCLUDE_H