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
17 #include "graphics/GraphicsTypes.h"
19 #include "support/filename.h"
21 #include <boost/scoped_ptr.hpp>
22 #include <boost/signals/trackable.hpp>
25 /** No two InsetExternalParams variables can have the same temporary file.
26 * This struct has copy-semantics but the copy constructor
27 * and assignment operator simply call the default constructor.
28 * Use of this struct enables us to use the compiler-generated
29 * copy constructor and assignment operator for the
30 * InsetExternalParams struct.
37 TempName(TempName const &);
39 TempName & operator=(TempName const &);
40 std::string const & operator()() const { return tempname_; }
42 std::string tempname_;
45 } // namespace external
49 /// hold parameters settable from the GUI
50 struct InsetExternalParams {
51 InsetExternalParams();
53 void write(Buffer const &, std::ostream &) const;
54 bool read(Buffer const &, LyXLex &);
56 /// The name of the tempfile used for manipulations.
57 std::string const & tempname() const { return tempname_(); }
59 /// The template currently in use.
60 void settemplate(std::string const &);
61 std::string const & templatename() const { return templatename_; }
63 /// The external file.
64 lyx::support::FileName filename;
65 /// How the inset is to be displayed by LyX.
66 lyx::graphics::DisplayType display;
67 /// The scale of the displayed graphic (if shown).
68 unsigned int lyxscale;
71 lyx::external::TempName tempname_;
72 std::string templatename_;
79 class InsetExternal : public InsetOld, public boost::signals::trackable
84 InsetExternal(InsetExternal const &);
86 virtual ~InsetExternal();
88 virtual std::auto_ptr<InsetBase> clone() const;
90 virtual dispatch_result localDispatch(FuncRequest const & cmd);
93 virtual InsetOld::Code lyxCode() const { return EXTERNAL_CODE; }
95 virtual EDITABLE editable() const { return IS_EDITABLE; }
98 void metrics(MetricsInfo &, Dimension &) const;
100 void draw(PainterInfo & pi, int x, int y) const;
102 virtual void write(Buffer const &, std::ostream &) const;
104 virtual void read(Buffer const &, LyXLex & lex);
106 /// \returns the number of rows (\n's) of generated code.
107 virtual int latex(Buffer const &, std::ostream &,
108 LatexRunParams const &) const;
110 virtual int ascii(Buffer const &, std::ostream &, int linelen) const;
112 virtual int linuxdoc(Buffer const &, std::ostream &) const;
114 virtual int docbook(Buffer const &, std::ostream &,
117 /// Update needed features for this inset.
118 virtual void validate(LaTeXFeatures & features) const;
121 InsetExternalParams const & params() const;
122 void setParams(InsetExternalParams const &, Buffer const &);
125 /** This method is connected to the graphics loader, so we are
126 * informed when the image has been loaded.
128 void statusChanged();
130 /// The current params
131 InsetExternalParams params_;
132 /// The thing that actually draws the image on LyX's screen.
133 boost::scoped_ptr<RenderInset> renderer_;
137 #include "mailinset.h"
139 class InsetExternalMailer : public MailInset {
142 InsetExternalMailer(InsetExternal & inset);
144 virtual InsetBase & inset() const { return inset_; }
146 virtual std::string const & name() const { return name_; }
148 virtual std::string const inset2string(Buffer const &) const;
150 static void string2params(std::string const &, Buffer const &,
151 InsetExternalParams &);
153 static std::string const params2string(InsetExternalParams const &,
157 static std::string const name_;
159 InsetExternal & inset_;