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