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
21 #include "insets/inset.h"
22 #include "insets/insetgraphicsParams.h"
24 // We need a signal here to hide an active dialog when we are deleted.
25 #include <boost/signals/signal0.hpp>
26 #include <boost/signals/trackable.hpp>
27 #include <boost/scoped_ptr.hpp>
33 class InsetGraphics : public Inset, public boost::signals::trackable {
38 InsetGraphics(InsetGraphics const &, string const & filepath,
39 bool same_id = false);
43 int ascent(BufferView *, LyXFont const &) const;
45 int descent(BufferView *, LyXFont const &) const;
47 int width(BufferView *, LyXFont const &) const;
49 void draw(BufferView *, LyXFont const &, int, float &, bool) const;
51 void edit(BufferView *, int, int, mouse_button::state);
53 void edit(BufferView * bv, bool front = true);
55 EDITABLE editable() const;
57 void write(Buffer const *, std::ostream &) const;
59 void read(Buffer const *, LyXLex & lex);
61 /** returns the number of rows (\n's) of generated tex code.
62 #fragile == true# means, that the inset should take care about
63 fragile commands by adding a #\protect# before.
65 int latex(Buffer const *, std::ostream &,
66 bool fragile, bool free_spc) const;
68 int ascii(Buffer const *, std::ostream &, int linelen) const;
70 int linuxdoc(Buffer const *, std::ostream &) const;
72 int docbook(Buffer const *, std::ostream &, bool mixcont) const;
74 /** Tell LyX what the latex features you need i.e. what latex packages
75 you need to be included.
77 void validate(LaTeXFeatures & features) const;
79 /// returns LyX code associated with the inset. Used for TOC, ...)
80 Inset::Code lyxCode() const { return Inset::GRAPHICS_CODE; }
83 virtual Inset * clone(Buffer const &, bool same_id = false) const;
85 /** Set the inset parameters, used by the GUIndependent dialog.
86 Return true of new params are different from what was so far.
88 bool setParams(InsetGraphicsParams const & params,
89 string const & filepath);
91 /// Get the inset parameters, used by the GUIndependent dialog.
92 InsetGraphicsParams const & params() const;
94 /** This signal is connected by our dialog and called when the inset
97 boost::signal0<void> hideDialog;
100 /// Is the image ready to draw, or should we display a message instead?
101 bool imageIsDrawable() const;
103 /** This method is connected to cache_->statusChanged, so we are
104 informed when the image has been loaded.
106 void statusChanged();
108 /// Read the inset native format
109 void readInsetGraphics(LyXLex & lex);
111 /// Get the status message, depends on the image loading status.
112 string const statusMessage() const;
113 /// Create the options for the latex command.
114 string const createLatexOptions() const;
115 /// Convert the file if needed, and return the location of the file.
116 string const prepareFile(Buffer const * buf) const;
119 InsetGraphicsParams params_;
121 /// holds the entity name that defines the graphics location (SGML).
122 string const graphic_label;
124 /// The cached variables
127 /// The pointer never changes although *cache_'s contents may.
128 boost::scoped_ptr<Cache> const cache_;