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 {
32 InsetGraphics(InsetGraphics const &);
36 void metrics(MetricsInfo &, Dimension &) const;
38 EDITABLE editable() const;
40 void write(Buffer const &, std::ostream &) const;
42 void read(Buffer const &, LyXLex & lex);
44 /** returns the number of rows (\n's) of generated tex code.
45 #fragile == true# means, that the inset should take care about
46 fragile commands by adding a #\protect# before.
48 int latex(Buffer const &, std::ostream &,
49 OutputParams const &) const;
51 int plaintext(Buffer const &, std::ostream &,
52 OutputParams const &) const;
54 int linuxdoc(Buffer const &, std::ostream &,
55 OutputParams const &) const;
57 int docbook(Buffer const &, std::ostream &,
58 OutputParams const &) const;
60 /** Tell LyX what the latex features you need i.e. what latex packages
61 you need to be included.
63 void validate(LaTeXFeatures & features) const;
65 /// returns LyX code associated with the inset. Used for TOC, ...)
66 InsetOld::Code lyxCode() const { return InsetOld::GRAPHICS_CODE; }
69 virtual std::auto_ptr<InsetBase> clone() const;
71 /** Set the inset parameters, used by the GUIndependent dialog.
72 Return true of new params are different from what was so far.
74 bool setParams(InsetGraphicsParams const & params);
76 /// Get the inset parameters, used by the GUIndependent dialog.
77 InsetGraphicsParams const & params() const;
79 void draw(PainterInfo & pi, int x, int y) const;
81 void edit(LCursor & cur, bool left);
83 void editGraphics(InsetGraphicsParams const &, Buffer const &) const;
86 void priv_dispatch(LCursor & cur, FuncRequest & cmd);
89 friend class InsetGraphicsMailer;
91 /// Read the inset native format
92 void readInsetGraphics(LyXLex & lex, std::string const & bufpath);
94 /// Get the status message, depends on the image loading status.
95 std::string const statusMessage() const;
96 /// Create the options for the latex command.
97 std::string const createLatexOptions() const;
98 /// Create the atributes for docbook export.
99 std::string const createDocBookAttributes() const;
100 /// Convert the file if needed, and return the location of the file.
101 std::string const prepareFile(Buffer const & buf, OutputParams const &) const;
104 InsetGraphicsParams params_;
106 /// holds the entity name that defines the graphics location (SGML).
107 std::string const graphic_label;
109 /// The thing that actually draws the image on LyX's screen.
110 boost::scoped_ptr<RenderGraphic> const graphic_;
114 #include "mailinset.h"
116 class InsetGraphicsMailer : public MailInset {
119 InsetGraphicsMailer(InsetGraphics & inset);
121 virtual InsetBase & inset() const { return inset_; }
123 virtual std::string const & name() const { return name_; }
125 virtual std::string const inset2string(Buffer const &) const;
127 static void string2params(std::string const & data,
128 Buffer const & buffer,
129 InsetGraphicsParams &);
131 static std::string const params2string(InsetGraphicsParams const &,
135 static std::string const name_;
137 InsetGraphics & inset_;