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>
24 class RenderMonitoredPreview;
27 /// for including tex/lyx files
28 class InsetInclude: public InsetOld {
31 InsetInclude(InsetCommandParams const &);
32 InsetInclude(InsetInclude const &);
36 virtual std::auto_ptr<InsetBase> clone() const;
39 virtual dispatch_result localDispatch(FuncRequest const & cmd);
41 /// Override these InsetButton methods if Previewing
42 void metrics(MetricsInfo & mi, Dimension & dim) const;
44 void draw(PainterInfo & pi, int x, int y) const;
46 virtual BufferView * view() const;
48 /// get the parameters
49 InsetCommandParams const & params(void) const;
52 InsetOld::Code lyxCode() const { return InsetOld::INCLUDE_CODE; }
54 * \param buffer the Buffer containing this inset.
55 * \param list the list of labels in the child buffer.
57 void getLabelList(Buffer const & buffer,
58 std::vector<std::string> & list) const;
60 * \param buffer the Buffer containing this inset.
61 * \param keys the list of bibkeys in the child buffer.
64 void fillWithBibKeys(Buffer const & buffer,
65 std::vector<std::pair<std::string,std::string> > & keys) const;
67 EDITABLE editable() const { return IS_EDITABLE; }
69 void write(Buffer const &, std::ostream &) const;
71 void read(Buffer const &, LyXLex &);
73 int latex(Buffer const &, std::ostream &, LatexRunParams const &) const;
75 int ascii(Buffer const &, std::ostream &, int linelen) const;
77 int linuxdoc(Buffer const &, std::ostream &) const;
79 int docbook(Buffer const &, std::ostream &, bool mixcont) const;
81 void validate(LaTeXFeatures &) const;
83 void addPreview(lyx::graphics::PreviewLoader &) const;
86 /// Slot receiving a signal that the preview is ready to display.
87 void statusChanged() const;
88 /** Slot receiving a signal that the external file has changed
89 * and the preview should be regenerated.
91 void fileChanged() const;
94 friend class InsetIncludeMailer;
96 /// set the parameters
97 void set(InsetCommandParams const & params, Buffer const &);
98 /// get the text displayed on the button
99 std::string const getScreenLabel(Buffer const &) const;
101 void write(std::ostream &) const;
106 InsetCommandParams params_;
107 /// holds the entity name that defines the file location (SGML)
108 std::string const include_label;
110 /// The pointer never changes although *preview_'s contents may.
111 boost::scoped_ptr<RenderMonitoredPreview> const preview_;
114 mutable bool set_label_;
115 mutable RenderButton button_;
119 #include "mailinset.h"
121 class InsetIncludeMailer : public MailInset {
124 InsetIncludeMailer(InsetInclude & inset);
126 virtual InsetBase & inset() const { return inset_; }
128 virtual std::string const & name() const { return name_; }
130 virtual std::string const inset2string(Buffer const &) const;
132 static void string2params(std::string const &, InsetCommandParams &);
134 static std::string const params2string(InsetCommandParams const &);
137 static std::string const name_;
139 InsetInclude & inset_;
142 #endif // INSETINCLUDE_H