4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * Full author contact details are available in file CREDITS
10 #ifndef INSET_INCLUDE_H
11 #define INSET_INCLUDE_H
17 #include "insetcommand.h"
19 #include <boost/signals/signal0.hpp>
20 #include <boost/scoped_ptr.hpp>
25 // Created by AAS 970521
27 /// for including tex/lyx files
28 class InsetInclude: public InsetButton, boost::noncopyable {
30 /// the type of inclusion
39 Params(InsetCommandParams const & cp = InsetCommandParams("input"),
42 string const & name = string())
43 : cparams(cp), flag(f),
44 masterFilename_(name) {}
46 InsetCommandParams cparams;
48 string masterFilename_;
51 bool operator==(Params const &) const;
53 bool operator!=(Params const &) const;
57 InsetInclude(Params const &);
59 InsetInclude(InsetCommandParams const &, Buffer const &);
63 /// Override these InsetButton methods if Previewing
64 int ascent(BufferView *, LyXFont const &) const;
66 int descent(BufferView *, LyXFont const &) const;
68 int width(BufferView *, LyXFont const &) const;
70 void draw(BufferView *, LyXFont const &, int, float &, bool) const;
72 /// get the parameters
73 Params const & params(void) const;
74 /// set the parameters
75 void set(Params const & params);
78 virtual Inset * clone(Buffer const &, bool same_id = false) const;
80 Inset::Code lyxCode() const { return Inset::INCLUDE_CODE; }
81 /// This returns the list of labels on the child buffer
82 std::vector<string> const getLabelList() const;
83 /// This returns the list of bibkeys on the child buffer
84 std::vector< std::pair<string,string> > const getKeys() const;
86 void edit(BufferView *, int x, int y, mouse_button::state button);
88 void edit(BufferView * bv, bool front = true);
90 EDITABLE editable() const
94 /// With lyx3 we won't overload these 3 methods
95 void write(Buffer const *, std::ostream &) const;
97 void read(Buffer const *, LyXLex &);
99 int latex(Buffer const *, std::ostream &,
100 bool fragile, bool free_spc) const;
102 int ascii(Buffer const *, std::ostream &, int linelen) const;
104 int linuxdoc(Buffer const *, std::ostream &) const;
106 int docbook(Buffer const *, std::ostream &, bool mixcont) const;
108 void validate(LaTeXFeatures &) const;
110 /** Input inserts anything inside a paragraph.
111 Display can give some visual feedback
113 bool display() const;
115 /// return the filename stub of the included file
116 string const getRelFileBaseName() const;
118 /// return true if the file is or got loaded.
119 bool loadIfNeeded() const;
122 void addPreview(grfx::PreviewLoader &) const;
124 /// hide a dialog if about
125 boost::signal0<void> hideDialog;
127 /// get the text displayed on the button
128 string const getScreenLabel(Buffer const *) const;
129 /// is this a verbatim include ?
130 bool isVerbatim() const;
131 /// get the filename of the master buffer
132 string const getMasterFilename() const;
133 /// get the included file name
134 string const getFileName() const;
138 /// holds the entity name that defines the file location (SGML)
139 string const include_label;
141 /// Use the Pimpl idiom to hide the internals of the previewer.
143 friend class PreviewImpl;
144 /// The pointer never changes although *preview_'s contents may.
145 boost::scoped_ptr<PreviewImpl> const preview_;
149 inline bool InsetInclude::isVerbatim() const
151 return params_.flag == VERB || params_.flag == VERBAST;
154 #endif // INSETINCLUDE_H