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
19 #include "insetcommand.h"
21 #include <boost/signals/signal0.hpp>
22 #include <boost/scoped_ptr.hpp>
27 // Created by AAS 970521
29 /// for including tex/lyx files
30 class InsetInclude: public InsetButton, boost::noncopyable {
32 /// the type of inclusion
41 Params(InsetCommandParams const & cp = InsetCommandParams("input"),
43 string const & name = string())
44 : cparams(cp), flag(f),
45 masterFilename_(name) {}
47 InsetCommandParams cparams;
49 string masterFilename_;
52 bool operator==(Params const &) const;
54 bool operator!=(Params const &) const;
58 InsetInclude(Params const &);
60 InsetInclude(InsetCommandParams const &, Buffer const &);
64 /// Override these InsetButton methods if Previewing
65 int ascent(BufferView *, LyXFont const &) const;
67 int descent(BufferView *, LyXFont const &) const;
69 int width(BufferView *, LyXFont const &) const;
71 void draw(BufferView *, LyXFont const &, int, float &, bool) const;
73 /// get the parameters
74 Params const & params(void) const;
75 /// set the parameters
76 void set(Params const & params);
79 virtual Inset * clone(Buffer const &, bool same_id = false) const;
81 Inset::Code lyxCode() const { return Inset::INCLUDE_CODE; }
82 /// This returns the list of labels on the child buffer
83 std::vector<string> const getLabelList() const;
84 /// This returns the list of bibkeys on the child buffer
85 std::vector< std::pair<string,string> > const getKeys() const;
87 void edit(BufferView *, int x, int y, mouse_button::state button);
89 void edit(BufferView * bv, bool front = true);
91 EDITABLE editable() const
95 /// With lyx3 we won't overload these 3 methods
96 void write(Buffer const *, std::ostream &) const;
98 void read(Buffer const *, LyXLex &);
100 int latex(Buffer const *, std::ostream &,
101 bool fragile, bool free_spc) const;
103 int ascii(Buffer const *, std::ostream &, int linelen) const;
105 int linuxdoc(Buffer const *, std::ostream &) const;
107 int docbook(Buffer const *, std::ostream &, bool mixcont) const;
109 void validate(LaTeXFeatures &) const;
111 /** Input inserts anything inside a paragraph.
112 Display can give some visual feedback
114 bool display() const;
116 /// return the filename stub of the included file
117 string const getRelFileBaseName() const;
119 /// return true if the file is or got loaded.
120 bool loadIfNeeded() const;
123 void addPreview(grfx::PreviewLoader &) const;
125 /// hide a dialog if about
126 boost::signal0<void> hideDialog;
128 /// get the text displayed on the button
129 string const getScreenLabel(Buffer const *) const;
130 /// is this a verbatim include ?
131 bool isVerbatim() const;
132 /// get the filename of the master buffer
133 string const getMasterFilename() const;
134 /// get the included file name
135 string const getFileName() const;
139 /// holds the entity name that defines the file location (SGML)
140 string const include_label;
142 /// Use the Pimpl idiom to hide the internals of the previewer.
144 friend class PreviewImpl;
145 /// The pointer never changes although *preview_'s contents may.
146 boost::scoped_ptr<PreviewImpl> const preview_;
150 inline bool InsetInclude::isVerbatim() const
152 return params_.flag == VERB || params_.flag == VERBAST;
155 #endif // INSETINCLUDE_H