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"),
41 string const & name = string())
42 : cparams(cp), flag(f),
43 masterFilename_(name) {}
45 InsetCommandParams cparams;
47 string masterFilename_;
50 bool operator==(Params const &) const;
52 bool operator!=(Params const &) const;
56 InsetInclude(Params const &);
58 InsetInclude(InsetCommandParams const &, Buffer const &);
62 /// Override these InsetButton methods if Previewing
63 int ascent(BufferView *, LyXFont const &) const;
65 int descent(BufferView *, LyXFont const &) const;
67 int width(BufferView *, LyXFont const &) const;
69 void draw(BufferView *, LyXFont const &, int, float &, bool) const;
71 /// get the parameters
72 Params const & params(void) const;
73 /// set the parameters
74 void set(Params const & params);
77 virtual Inset * clone(Buffer const &, bool same_id = false) const;
79 Inset::Code lyxCode() const { return Inset::INCLUDE_CODE; }
80 /// This returns the list of labels on the child buffer
81 std::vector<string> const getLabelList() const;
82 /// This returns the list of bibkeys on the child buffer
83 std::vector< std::pair<string,string> > const getKeys() const;
85 void edit(BufferView *, int x, int y, mouse_button::state button);
87 void edit(BufferView * bv, bool front = true);
89 EDITABLE editable() const
93 /// With lyx3 we won't overload these 3 methods
94 void write(Buffer const *, std::ostream &) const;
96 void read(Buffer const *, LyXLex &);
98 int latex(Buffer const *, std::ostream &,
99 bool fragile, bool free_spc) const;
101 int ascii(Buffer const *, std::ostream &, int linelen) const;
103 int linuxdoc(Buffer const *, std::ostream &) const;
105 int docbook(Buffer const *, std::ostream &, bool mixcont) const;
107 void validate(LaTeXFeatures &) const;
109 /** Input inserts anything inside a paragraph.
110 Display can give some visual feedback
112 bool display() const;
114 /// return the filename stub of the included file
115 string const getRelFileBaseName() const;
117 /// return true if the file is or got loaded.
118 bool loadIfNeeded() const;
121 void addPreview(grfx::PreviewLoader &) const;
123 /// hide a dialog if about
124 boost::signal0<void> hideDialog;
126 /// get the text displayed on the button
127 string const getScreenLabel(Buffer const *) const;
128 /// is this a verbatim include ?
129 bool isVerbatim() const;
130 /// get the filename of the master buffer
131 string const getMasterFilename() const;
132 /// get the included file name
133 string const getFileName() const;
137 /// holds the entity name that defines the file location (SGML)
138 string const include_label;
140 /// Use the Pimpl idiom to hide the internals of the previewer.
142 friend class PreviewImpl;
143 /// The pointer never changes although *preview_'s contents may.
144 boost::scoped_ptr<PreviewImpl> const preview_;
148 inline bool InsetInclude::isVerbatim() const
150 return params_.flag == VERB || params_.flag == VERBAST;
153 #endif // INSETINCLUDE_H