3 * \file insetexternal.h
4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Asger Alstrup Nielsen
9 * Full author contact details are available in file CREDITS
12 #ifndef INSET_EXTERNAL_H
13 #define INSET_EXTERNAL_H
16 #include "graphics/GraphicsTypes.h"
17 #include "support/filename.h"
20 #include <boost/scoped_ptr.hpp>
21 #include <boost/signals/trackable.hpp>
27 class InsetExternal : public Inset, public boost::signals::trackable {
29 /// hold parameters settable from the GUI
34 lyx::support::FileName filename;
35 /// the current template used
37 /// The name of the tempfile used for manipulations.
39 /// how the inset is displayed by LyX
40 lyx::graphics::DisplayType display;
41 /// The scale of the displayed graphic (If shown).
42 unsigned int lyxscale;
47 InsetExternal(InsetExternal const &);
49 virtual ~InsetExternal();
51 virtual dispatch_result localDispatch(FuncRequest const & cmd);
53 void metrics(MetricsInfo &, Dimension &) const;
55 void draw(PainterInfo & pi, int x, int y) const;
56 /// what appears in the minibuffer when opening
57 virtual string const editMessage() const;
59 virtual EDITABLE editable() const { return IS_EDITABLE; }
61 virtual void write(Buffer const *, std::ostream &) const;
63 virtual void read(Buffer const *, LyXLex & lex);
65 /** returns the number of rows (\n's) of generated tex code.
66 fragile == true means, that the inset should take care about
67 fragile commands by adding a \protect before.
68 If the free_spc (freespacing) variable is set, then this inset
69 is in a free-spacing paragraph.
71 virtual int latex(Buffer const *, std::ostream &,
72 LatexRunParams const &) const;
73 /// write ASCII output to the ostream
74 virtual int ascii(Buffer const *, std::ostream &, int linelen) const;
75 /// write LinuxDoc output to the ostream
76 virtual int linuxdoc(Buffer const *, std::ostream &) const;
77 /// write DocBook output to the ostream
78 virtual int docbook(Buffer const *, std::ostream &, bool mixcont) const;
80 /// Updates needed features for this inset.
81 virtual void validate(LaTeXFeatures & features) const;
83 /// returns LyX code associated with the inset. Used for TOC, ...)
84 virtual Inset::Code lyxCode() const { return EXTERNAL_CODE; }
87 virtual InsetBase * clone() const;
89 /// return a copy of our current params
90 Params const & params() const;
92 /// Set the inset parameters.
93 virtual void setParams(Params const &);
95 virtual BufferView * view() const;
97 /** update the file represented by the template.
98 If \param external_in_tmpdir == true, then the generated file is
99 place in the buffer's temporary directory.
101 void updateExternal(string const &, Buffer const *,
102 bool external_in_tmpdir) const;
105 /** This method is connected to the graphics loader, so we are
106 * informed when the image has been loaded.
108 void statusChanged();
110 /** Write the output for a specific file format
111 and generate any external data files.
112 If \param external_in_tmpdir == true, then the generated file is
113 place in the buffer's temporary directory.
115 int write(string const & format, Buffer const *, std::ostream &,
116 bool external_in_tmpdir = false) const;
118 /// the current params
121 /// The thing that actually draws the image on LyX's screen.
122 boost::scoped_ptr<RenderInset> renderer_;
126 #include "mailinset.h"
128 class InsetExternalMailer : public MailInset {
131 InsetExternalMailer(InsetExternal & inset);
133 virtual InsetBase & inset() const { return inset_; }
135 virtual string const & name() const { return name_; }
137 virtual string const inset2string() const;
139 static void string2params(string const &, Buffer const *,
140 InsetExternal::Params &);
142 static string const params2string(InsetExternal::Params const &,
146 static string const name_;
148 InsetExternal & inset_;