4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Lars Gullik Bjønnes
9 * Full author contact details are available in file CREDITS.
12 #ifndef INSET_INCLUDE_H
13 #define INSET_INCLUDE_H
16 #include "insetcommandparams.h"
17 #include "render_button.h"
18 #include <boost/scoped_ptr.hpp>
23 class RenderMonitoredPreview;
26 /// for including tex/lyx files
27 class InsetInclude: public InsetOld {
30 InsetInclude(InsetCommandParams const &);
31 InsetInclude(InsetInclude const &);
35 virtual std::auto_ptr<InsetBase> clone() const;
37 /// Override these InsetButton methods if Previewing
38 void metrics(MetricsInfo & mi, Dimension & dim) const;
40 void draw(PainterInfo & pi, int x, int y) const;
42 virtual bool display() const;
44 /// get the parameters
45 InsetCommandParams const & params(void) const;
48 InsetOld::Code lyxCode() const { return InsetOld::INCLUDE_CODE; }
50 * \param buffer the Buffer containing this inset.
51 * \param list the list of labels in the child buffer.
53 void getLabelList(Buffer const & buffer,
54 std::vector<std::string> & list) const;
56 * \param buffer the Buffer containing this inset.
57 * \param keys the list of bibkeys in the child buffer.
60 void fillWithBibKeys(Buffer const & buffer,
61 std::vector<std::pair<std::string,std::string> > & keys) const;
63 EDITABLE editable() const { return IS_EDITABLE; }
65 void write(Buffer const &, std::ostream &) const;
67 void read(Buffer const &, LyXLex &);
69 int latex(Buffer const &, std::ostream &,
70 OutputParams const &) const;
72 int plaintext(Buffer const &, std::ostream &,
73 OutputParams const &) const;
75 int linuxdoc(Buffer const &, std::ostream &,
76 OutputParams const &) const;
78 int docbook(Buffer const &, std::ostream &,
79 OutputParams const &) const;
81 void validate(LaTeXFeatures &) const;
83 void addPreview(lyx::graphics::PreviewLoader &) const;
86 virtual void priv_dispatch(LCursor & cur, FuncRequest & cmd);
88 /** Slot receiving a signal that the external file has changed
89 * and the preview should be regenerated.
91 void fileChanged() const;
93 friend class InsetIncludeMailer;
95 /// set the parameters
96 void set(InsetCommandParams const & params, Buffer const &);
97 /// get the text displayed on the button
98 std::string const getScreenLabel(Buffer const &) const;
100 void write(std::ostream &) const;
105 InsetCommandParams params_;
106 /// holds the entity name that defines the file location (SGML)
107 std::string const include_label;
109 /// The pointer never changes although *preview_'s contents may.
110 boost::scoped_ptr<RenderMonitoredPreview> const preview_;
113 mutable bool set_label_;
114 mutable RenderButton button_;
118 #include "mailinset.h"
120 class InsetIncludeMailer : public MailInset {
123 InsetIncludeMailer(InsetInclude & inset);
125 virtual InsetBase & inset() const { return inset_; }
127 virtual std::string const & name() const { return name_; }
129 virtual std::string const inset2string(Buffer const &) const;
131 static void string2params(std::string const &, InsetCommandParams &);
133 static std::string const params2string(InsetCommandParams const &);
136 static std::string const name_;
138 InsetInclude & inset_;
141 #endif // INSETINCLUDE_H