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>
21 #include <boost/weak_ptr.hpp>
29 class InsetGraphics : public InsetOld, public boost::signals::trackable {
34 InsetGraphics(InsetGraphics const &);
38 virtual dispatch_result localDispatch(FuncRequest const & cmd);
40 void metrics(MetricsInfo &, Dimension &) const;
42 EDITABLE editable() const;
44 void write(Buffer const &, std::ostream &) const;
46 void read(Buffer const &, LyXLex & lex);
48 /** returns the number of rows (\n's) of generated tex code.
49 #fragile == true# means, that the inset should take care about
50 fragile commands by adding a #\protect# before.
52 int latex(Buffer const &, std::ostream &,
53 LatexRunParams const &) const;
55 int ascii(Buffer const &, std::ostream &, int linelen) const;
57 int linuxdoc(Buffer const &, std::ostream &) const;
59 int docbook(Buffer const &, std::ostream &, bool mixcont) const;
61 /** Tell LyX what the latex features you need i.e. what latex packages
62 you need to be included.
64 void validate(LaTeXFeatures & features) const;
66 /// returns LyX code associated with the inset. Used for TOC, ...)
67 InsetOld::Code lyxCode() const { return InsetOld::GRAPHICS_CODE; }
70 virtual std::auto_ptr<InsetBase> clone() const;
72 /** Set the inset parameters, used by the GUIndependent dialog.
73 Return true of new params are different from what was so far.
75 bool setParams(InsetGraphicsParams const & params);
77 /// Get the inset parameters, used by the GUIndependent dialog.
78 InsetGraphicsParams const & params() const;
80 void draw(PainterInfo & pi, int x, int y) const;
84 friend class InsetGraphicsMailer;
86 void cache(BufferView *) const;
87 BufferView * view() const;
89 /** This method is connected to the graphics loader, so we are
90 * informed when the image has been loaded.
92 void statusChanged() const;
94 /// Read the inset native format
95 void readInsetGraphics(LyXLex & lex, std::string const & bufpath);
97 /// Get the status message, depends on the image loading status.
98 std::string const statusMessage() const;
99 /// Create the options for the latex command.
100 std::string const createLatexOptions() const;
101 /// Convert the file if needed, and return the location of the file.
102 std::string const prepareFile(Buffer const & buf, LatexRunParams const &) const;
105 InsetGraphicsParams params_;
107 /// holds the entity name that defines the graphics location (SGML).
108 std::string const graphic_label;
110 /// The thing that actually draws the image on LyX's screen.
111 boost::scoped_ptr<RenderGraphic> const graphic_;
114 mutable boost::weak_ptr<BufferView> view_;
118 #include "mailinset.h"
120 class InsetGraphicsMailer : public MailInset {
123 InsetGraphicsMailer(InsetGraphics & inset);
125 virtual InsetBase & inset() const { return inset_; }
127 virtual std::string const & name() const { return name_; }
129 virtual std::string const inset2string(Buffer const &) const;
131 static void string2params(std::string const & data,
132 Buffer const & buffer,
133 InsetGraphicsParams &);
135 static std::string const params2string(InsetGraphicsParams const &,
139 static std::string const name_;
141 InsetGraphics & inset_;