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 dispatch_result localDispatch(FuncRequest const & cmd);
99 virtual InsetOld::Code lyxCode() const { return EXTERNAL_CODE; }
101 virtual EDITABLE editable() const { return IS_EDITABLE; }
104 void metrics(MetricsInfo &, Dimension &) const;
106 void draw(PainterInfo & pi, int x, int y) const;
108 virtual void write(Buffer const &, std::ostream &) const;
110 virtual void read(Buffer const &, LyXLex & lex);
112 /// \returns the number of rows (\n's) of generated code.
113 virtual int latex(Buffer const &, std::ostream &,
114 LatexRunParams const &) const;
116 virtual int ascii(Buffer const &, std::ostream &, int linelen) const;
118 virtual int linuxdoc(Buffer const &, std::ostream &) const;
120 virtual int docbook(Buffer const &, std::ostream &,
123 /// Update needed features for this inset.
124 virtual void validate(LaTeXFeatures & features) const;
127 InsetExternalParams const & params() const;
128 void setParams(InsetExternalParams const &, Buffer const &);
131 /** This method is connected to the graphics loader, so we are
132 * informed when the image has been loaded.
134 void statusChanged() const;
136 /// The current params
137 InsetExternalParams params_;
138 /// The thing that actually draws the image on LyX's screen.
139 boost::scoped_ptr<RenderBase> renderer_;
143 #include "mailinset.h"
145 class InsetExternalMailer : public MailInset {
148 InsetExternalMailer(InsetExternal & inset);
150 virtual InsetBase & inset() const { return inset_; }
152 virtual std::string const & name() const { return name_; }
154 virtual std::string const inset2string(Buffer const &) const;
156 static void string2params(std::string const &, Buffer const &,
157 InsetExternalParams &);
159 static std::string const params2string(InsetExternalParams const &,
163 static std::string const name_;
165 InsetExternal & inset_;