]> git.lyx.org Git - lyx.git/blob - src/insets/insetinclude.h
72dc2eed46b8138e5a1b355b3546ab8a9f09f229
[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 "render_button.h"
18 #include <boost/scoped_ptr.hpp>
19
20 class Buffer;
21 class Dimension;
22 struct LaTeXFeatures;
23 class RenderMonitoredPreview;
24
25
26 /// for including tex/lyx files
27 class InsetInclude: public InsetOld {
28 public:
29         ///
30         InsetInclude(InsetCommandParams const &);
31         InsetInclude(InsetInclude const &);
32         ~InsetInclude();
33
34         ///
35         virtual std::auto_ptr<InsetBase> clone() const;
36
37         /// Override these InsetButton methods if Previewing
38         void metrics(MetricsInfo & mi, Dimension & dim) const;
39         ///
40         void draw(PainterInfo & pi, int x, int y) const;
41
42         /// get the parameters
43         InsetCommandParams const & params(void) const;
44
45         ///
46         InsetOld::Code lyxCode() const { return InsetOld::INCLUDE_CODE; }
47         /** Fills \c list
48          *  \param buffer the Buffer containing this inset.
49          *  \param list the list of labels in the child buffer.
50          */
51         void getLabelList(Buffer const & buffer,
52                           std::vector<std::string> & list) const;
53         /** Fills \c keys
54          *  \param buffer the Buffer containing this inset.
55          *  \param keys the list of bibkeys in the child buffer.
56          */
57         ///
58         void fillWithBibKeys(Buffer const & buffer,
59                 std::vector<std::pair<std::string,std::string> > & keys) const;
60         ///
61         EDITABLE editable() const { return IS_EDITABLE; }
62         ///
63         void write(Buffer const &, std::ostream &) const;
64         ///
65         void read(Buffer const &, LyXLex &);
66         ///
67         int latex(Buffer const &, std::ostream &, LatexRunParams const &) const;
68         ///
69         int ascii(Buffer const &, std::ostream &, int linelen) const;
70         ///
71         int linuxdoc(Buffer const &, std::ostream &) const;
72         ///
73         int docbook(Buffer const &, std::ostream &, bool mixcont) const;
74         ///
75         void validate(LaTeXFeatures &) const;
76         ///
77         void addPreview(lyx::graphics::PreviewLoader &) const;
78 protected:
79         ///
80         virtual
81         dispatch_result
82         priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &);
83 private:
84         /// Slot receiving a signal that the preview is ready to display.
85         void statusChanged() const;
86         /** Slot receiving a signal that the external file has changed
87          *  and the preview should be regenerated.
88          */
89         void fileChanged() const;
90
91         friend class InsetIncludeMailer;
92
93         /// set the parameters
94         void set(InsetCommandParams const & params, Buffer const &);
95         /// get the text displayed on the button
96         std::string const getScreenLabel(Buffer const &) const;
97         ///
98         void write(std::ostream &) const;
99         ///
100         void read(LyXLex &);
101
102         /// the parameters
103         InsetCommandParams params_;
104         /// holds the entity name that defines the file location (SGML)
105         std::string const include_label;
106
107         /// The pointer never changes although *preview_'s contents may.
108         boost::scoped_ptr<RenderMonitoredPreview> const preview_;
109
110         /// cache
111         mutable bool set_label_;
112         mutable RenderButton button_;
113 };
114
115
116 #include "mailinset.h"
117
118 class InsetIncludeMailer : public MailInset {
119 public:
120         ///
121         InsetIncludeMailer(InsetInclude & inset);
122         ///
123         virtual InsetBase & inset() const { return inset_; }
124         ///
125         virtual std::string const & name() const { return name_; }
126         ///
127         virtual std::string const inset2string(Buffer const &) const;
128         ///
129         static void string2params(std::string const &, InsetCommandParams &);
130         ///
131         static std::string const params2string(InsetCommandParams const &);
132 private:
133         ///
134         static std::string const name_;
135         ///
136         InsetInclude & inset_;
137 };
138
139 #endif // INSETINCLUDE_H