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 &);
33 /// Override these InsetButton methods if Previewing
34 void metrics(MetricsInfo & mi, Dimension & dim) const;
36 void draw(PainterInfo & pi, int x, int y) const;
38 virtual bool display() const;
40 /// get the parameters
41 InsetCommandParams const & params(void) const;
44 InsetBase::Code lyxCode() const { return InsetBase::INCLUDE_CODE; }
46 * \param buffer the Buffer containing this inset.
47 * \param list the list of labels in the child buffer.
49 void getLabelList(Buffer const & buffer,
50 std::vector<std::string> & list) const;
52 * \param buffer the Buffer containing this inset.
53 * \param keys the list of bibkeys in the child buffer.
56 void fillWithBibKeys(Buffer const & buffer,
57 std::vector<std::pair<std::string,std::string> > & keys) const;
59 EDITABLE editable() const { return IS_EDITABLE; }
61 void write(Buffer const &, std::ostream &) const;
63 void read(Buffer const &, LyXLex &);
65 int latex(Buffer const &, std::ostream &,
66 OutputParams const &) const;
68 int plaintext(Buffer const &, std::ostream &,
69 OutputParams const &) const;
71 int linuxdoc(Buffer const &, std::ostream &,
72 OutputParams const &) const;
74 int docbook(Buffer const &, std::ostream &,
75 OutputParams const &) const;
77 void validate(LaTeXFeatures &) const;
79 void addPreview(lyx::graphics::PreviewLoader &) const;
81 InsetInclude(InsetInclude const &);
83 virtual void doDispatch(LCursor & cur, FuncRequest & cmd);
85 virtual std::auto_ptr<InsetBase> doClone() const;
87 /** Slot receiving a signal that the external file has changed
88 * and the preview should be regenerated.
90 void fileChanged() const;
92 friend class InsetIncludeMailer;
94 /// set the parameters
95 void set(InsetCommandParams const & params, Buffer const &);
96 /// get the text displayed on the button
97 std::string const getScreenLabel(Buffer const &) const;
99 void write(std::ostream &) const;
104 InsetCommandParams params_;
105 /// holds the entity name that defines the file location (SGML)
106 std::string const include_label;
108 /// The pointer never changes although *preview_'s contents may.
109 boost::scoped_ptr<RenderMonitoredPreview> const preview_;
112 mutable bool set_label_;
113 mutable RenderButton button_;
117 #include "mailinset.h"
119 class InsetIncludeMailer : public MailInset {
122 InsetIncludeMailer(InsetInclude & inset);
124 virtual InsetBase & inset() const { return inset_; }
126 virtual std::string const & name() const { return name_; }
128 virtual std::string const inset2string(Buffer const &) const;
130 static void string2params(std::string const &, InsetCommandParams &);
132 static std::string const params2string(InsetCommandParams const &);
135 static std::string const name_;
137 InsetInclude & inset_;
140 #endif // INSETINCLUDE_H