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 "ExternalTransforms.h"
18 #include "graphics/GraphicsTypes.h"
20 #include "support/filename.h"
22 #include <boost/scoped_ptr.hpp>
23 #include <boost/signals/trackable.hpp>
26 /** No two InsetExternalParams variables can have the same temporary file.
27 * This struct has copy-semantics but the copy constructor
28 * and assignment operator simply call the default constructor.
29 * Use of this struct enables us to use the compiler-generated
30 * copy constructor and assignment operator for the
31 * InsetExternalParams struct.
38 TempName(TempName const &);
40 TempName & operator=(TempName const &);
41 std::string const & operator()() const { return tempname_; }
43 std::string tempname_;
46 } // namespace external
50 /// hold parameters settable from the GUI
51 struct InsetExternalParams {
52 InsetExternalParams();
54 void write(Buffer const &, std::ostream &) const;
55 bool read(Buffer const &, LyXLex &);
57 /// The name of the tempfile used for manipulations.
58 std::string const & tempname() const { return tempname_(); }
60 /// The template currently in use.
61 void settemplate(std::string const &);
62 std::string const & templatename() const { return templatename_; }
64 /// The external file.
65 lyx::support::FileName filename;
66 /// How the inset is to be displayed by LyX.
67 lyx::graphics::DisplayType display;
68 /// The scale of the displayed graphic (if shown).
69 unsigned int lyxscale;
71 lyx::external::ClipData clipdata;
72 lyx::external::ExtraData extradata;
73 lyx::external::ResizeData resizedata;
74 lyx::external::RotationData rotationdata;
77 lyx::external::TempName tempname_;
78 std::string templatename_;
85 class InsetExternal : public InsetOld, public boost::signals::trackable
90 InsetExternal(InsetExternal const &);
92 virtual ~InsetExternal();
94 virtual std::auto_ptr<InsetBase> clone() const;
96 virtual InsetOld::Code lyxCode() const { return EXTERNAL_CODE; }
98 virtual EDITABLE editable() const { return IS_EDITABLE; }
101 void metrics(MetricsInfo &, Dimension &) const;
103 void draw(PainterInfo & pi, int x, int y) const;
105 virtual void write(Buffer const &, std::ostream &) const;
107 virtual void read(Buffer const &, LyXLex & lex);
109 /// \returns the number of rows (\n's) of generated code.
110 virtual int latex(Buffer const &, std::ostream &,
111 LatexRunParams const &) const;
113 virtual int ascii(Buffer const &, std::ostream &, int linelen) const;
115 virtual int linuxdoc(Buffer const &, std::ostream &) const;
117 virtual int docbook(Buffer const &, std::ostream &,
120 /// Update needed features for this inset.
121 virtual void validate(LaTeXFeatures & features) const;
124 InsetExternalParams const & params() const;
125 void setParams(InsetExternalParams const &, Buffer const &);
130 priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &);
132 /** This method is connected to the graphics loader, so we are
133 * informed when the image has been loaded.
135 void statusChanged() const;
137 /// The current params
138 InsetExternalParams params_;
139 /// The thing that actually draws the image on LyX's screen.
140 boost::scoped_ptr<RenderBase> renderer_;
144 #include "mailinset.h"
146 class InsetExternalMailer : public MailInset {
149 InsetExternalMailer(InsetExternal & inset);
151 virtual InsetBase & inset() const { return inset_; }
153 virtual std::string const & name() const { return name_; }
155 virtual std::string const inset2string(Buffer const &) const;
157 static void string2params(std::string const &, Buffer const &,
158 InsetExternalParams &);
160 static std::string const params2string(InsetExternalParams const &,
164 static std::string const name_;
166 InsetExternal & inset_;