3 * \file insetgraphics.h
4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
10 * Full author contact details are available in file CREDITS.
13 #ifndef INSET_GRAPHICS_H
14 #define INSET_GRAPHICS_H
17 #include "insetgraphicsParams.h"
19 #include <boost/scoped_ptr.hpp>
20 #include <boost/signals/trackable.hpp>
24 class GraphicRenderer;
28 class InsetGraphics : public InsetOld, public boost::signals::trackable {
33 InsetGraphics(InsetGraphics const &);
37 virtual dispatch_result localDispatch(FuncRequest const & cmd);
39 void metrics(MetricsInfo &, Dimension &) const;
41 void draw(PainterInfo & pi, int x, int y) const;
43 EDITABLE editable() const;
45 void write(Buffer const *, std::ostream &) const;
47 void read(Buffer const *, LyXLex & lex);
49 /** returns the number of rows (\n's) of generated tex code.
50 #fragile == true# means, that the inset should take care about
51 fragile commands by adding a #\protect# before.
53 int latex(Buffer const *, std::ostream &,
54 LatexRunParams const &) const;
56 int ascii(Buffer const *, std::ostream &, int linelen) const;
58 int linuxdoc(Buffer const *, std::ostream &) const;
60 int docbook(Buffer const *, std::ostream &, bool mixcont) const;
62 /** Tell LyX what the latex features you need i.e. what latex packages
63 you need to be included.
65 void validate(LaTeXFeatures & features) const;
67 /// returns LyX code associated with the inset. Used for TOC, ...)
68 InsetOld::Code lyxCode() const { return InsetOld::GRAPHICS_CODE; }
71 virtual std::auto_ptr<InsetBase> clone() const;
73 /** Set the inset parameters, used by the GUIndependent dialog.
74 Return true of new params are different from what was so far.
76 bool setParams(InsetGraphicsParams const & params);
78 /// Get the inset parameters, used by the GUIndependent dialog.
79 InsetGraphicsParams const & params() const;
83 friend class InsetGraphicsMailer;
85 /** This method is connected to the graphics loader, so we are
86 * informed when the image has been loaded.
90 /// Read the inset native format
91 void readInsetGraphics(LyXLex & lex, string const & bufpath);
93 /// Get the status message, depends on the image loading status.
94 string const statusMessage() const;
95 /// Create the options for the latex command.
96 string const createLatexOptions() const;
97 /// Convert the file if needed, and return the location of the file.
98 string const prepareFile(Buffer const * buf, LatexRunParams const &) const;
101 InsetGraphicsParams params_;
103 /// holds the entity name that defines the graphics location (SGML).
104 string const graphic_label;
106 /// The thing that actually draws the image on LyX's screen.
107 boost::scoped_ptr<GraphicRenderer> const graphic_;
111 #include "mailinset.h"
113 class InsetGraphicsMailer : public MailInset {
116 InsetGraphicsMailer(InsetGraphics & inset);
118 virtual InsetBase & inset() const { return inset_; }
120 virtual string const & name() const { return name_; }
122 virtual string const inset2string(Buffer const &) const;
124 static void string2params(string const & data,
125 Buffer const & buffer,
126 InsetGraphicsParams &);
128 static string const params2string(InsetGraphicsParams const &,
132 static string const name_;
134 InsetGraphics & inset_;