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>
27 class InsetGraphics : public InsetOld, public boost::signals::trackable {
34 void metrics(MetricsInfo &, Dimension &) const;
36 EDITABLE editable() const;
38 void write(Buffer const &, std::ostream &) const;
40 void read(Buffer const &, LyXLex & lex);
42 /** returns the number of rows (\n's) of generated tex code.
43 #fragile == true# means, that the inset should take care about
44 fragile commands by adding a #\protect# before.
46 int latex(Buffer const &, std::ostream &,
47 OutputParams const &) const;
49 int plaintext(Buffer const &, std::ostream &,
50 OutputParams const &) const;
52 int linuxdoc(Buffer const &, std::ostream &,
53 OutputParams const &) const;
55 int docbook(Buffer const &, std::ostream &,
56 OutputParams const &) const;
58 /** Tell LyX what the latex features you need i.e. what latex packages
59 you need to be included.
61 void validate(LaTeXFeatures & features) const;
63 /// returns LyX code associated with the inset. Used for TOC, ...)
64 InsetOld::Code lyxCode() const { return InsetOld::GRAPHICS_CODE; }
66 /** Set the inset parameters, used by the GUIndependent dialog.
67 Return true of new params are different from what was so far.
69 bool setParams(InsetGraphicsParams const & params);
71 /// Get the inset parameters, used by the GUIndependent dialog.
72 InsetGraphicsParams const & params() const;
74 void draw(PainterInfo & pi, int x, int y) const;
76 void edit(LCursor & cur, bool left);
78 void editGraphics(InsetGraphicsParams const &, Buffer const &) const;
80 InsetGraphics(InsetGraphics const &);
82 virtual void doDispatch(LCursor & cur, FuncRequest & cmd);
84 friend class InsetGraphicsMailer;
86 virtual std::auto_ptr<InsetBase> doClone() const;
88 /// Read the inset native format
89 void readInsetGraphics(LyXLex & lex, std::string const & bufpath);
91 /// Get the status message, depends on the image loading status.
92 std::string const statusMessage() const;
93 /// Create the options for the latex command.
94 std::string const createLatexOptions() const;
95 /// Create length values for docbook export.
96 std::string const toDocbookLength(LyXLength const & len) const;
97 /// Create the atributes for docbook export.
98 std::string const createDocBookAttributes() const;
99 /// Convert the file if needed, and return the location of the file.
100 std::string const prepareFile(Buffer const & buf, OutputParams const &) const;
103 InsetGraphicsParams params_;
105 /// holds the entity name that defines the graphics location (SGML).
106 std::string const graphic_label;
108 /// The thing that actually draws the image on LyX's screen.
109 boost::scoped_ptr<RenderGraphic> const graphic_;
113 #include "mailinset.h"
115 class InsetGraphicsMailer : public MailInset {
118 InsetGraphicsMailer(InsetGraphics & inset);
120 virtual InsetBase & inset() const { return inset_; }
122 virtual std::string const & name() const { return name_; }
124 virtual std::string const inset2string(Buffer const &) const;
126 static void string2params(std::string const & data,
127 Buffer const & buffer,
128 InsetGraphicsParams &);
130 static std::string const params2string(InsetGraphicsParams const &,
134 static std::string const name_;
136 InsetGraphics & inset_;