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 "insetcommand.h"
18 #include <boost/signals/signal0.hpp>
19 #include <boost/scoped_ptr.hpp>
24 // Created by AAS 970521
26 /// for including tex/lyx files
27 class InsetInclude: public InsetButton, boost::noncopyable {
29 /// the type of inclusion
38 Params(InsetCommandParams const & cp = InsetCommandParams("input"),
40 string const & name = string())
41 : cparams(cp), flag(f),
42 masterFilename_(name) {}
44 InsetCommandParams cparams;
46 string masterFilename_;
49 bool operator==(Params const &) const;
51 bool operator!=(Params const &) const;
55 InsetInclude(Params const &);
57 InsetInclude(InsetCommandParams const &, Buffer const &);
61 /// Override these InsetButton methods if Previewing
62 int ascent(BufferView *, LyXFont const &) const;
64 int descent(BufferView *, LyXFont const &) const;
66 int width(BufferView *, LyXFont const &) const;
68 void draw(BufferView *, LyXFont const &, int, float &, bool) const;
70 /// get the parameters
71 Params const & params(void) const;
72 /// set the parameters
73 void set(Params const & params);
76 virtual Inset * clone(Buffer const &, bool same_id = false) const;
78 Inset::Code lyxCode() const { return Inset::INCLUDE_CODE; }
79 /// This returns the list of labels on the child buffer
80 std::vector<string> const getLabelList() const;
81 /// This returns the list of bibkeys on the child buffer
82 void fillWithBibKeys(std::vector<std::pair<string,string> > & keys) const;
84 void edit(BufferView *, int x, int y, mouse_button::state button);
86 void edit(BufferView * bv, bool front = true);
88 EDITABLE editable() const
92 /// With lyx3 we won't overload these 3 methods
93 void write(Buffer const *, std::ostream &) const;
95 void read(Buffer const *, LyXLex &);
97 int latex(Buffer const *, std::ostream &,
98 bool fragile, bool free_spc) const;
100 int ascii(Buffer const *, std::ostream &, int linelen) const;
102 int linuxdoc(Buffer const *, std::ostream &) const;
104 int docbook(Buffer const *, std::ostream &, bool mixcont) const;
106 void validate(LaTeXFeatures &) const;
108 /** Input inserts anything inside a paragraph.
109 Display can give some visual feedback
111 bool display() const;
113 /// return the filename stub of the included file
114 string const getRelFileBaseName() const;
116 /// return true if the file is or got loaded.
117 bool loadIfNeeded() const;
120 void addPreview(grfx::PreviewLoader &) const;
122 /// hide a dialog if about
123 boost::signal0<void> hideDialog;
125 /// get the text displayed on the button
126 string const getScreenLabel(Buffer const *) const;
127 /// is this a verbatim include ?
128 bool isVerbatim() const;
129 /// get the filename of the master buffer
130 string const getMasterFilename() const;
131 /// get the included file name
132 string const getFileName() const;
136 /// holds the entity name that defines the file location (SGML)
137 string const include_label;
139 /// Use the Pimpl idiom to hide the internals of the previewer.
141 friend class PreviewImpl;
142 /// The pointer never changes although *preview_'s contents may.
143 boost::scoped_ptr<PreviewImpl> const preview_;
147 inline bool InsetInclude::isVerbatim() const
149 return params_.flag == VERB || params_.flag == VERBAST;
152 #endif // INSETINCLUDE_H