2 /* This file is part of
3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright 1995 Matthias Ettrich
8 * Copyright 1995-2000 the LyX Team.
10 * ====================================================== */
12 #ifndef INSET_GRAPHICS_H
13 #define INSET_GRAPHICS_H
20 #include "insets/lyxinset.h"
21 #include "insets/insetgraphicsParams.h"
22 #include "graphics/GraphicsCacheItem.h"
23 #include <boost/smart_ptr.hpp>
25 #include "LaTeXFeatures.h"
27 // We need a signal here to hide an active dialog when we are deleted.
28 #include "sigc++/signal_system.h"
34 class InsetGraphics : public Inset, public SigC::Object {
41 int ascent(BufferView *, LyXFont const &) const;
43 int descent(BufferView *, LyXFont const &) const;
45 int width(BufferView *, LyXFont const &) const;
47 bool display() const { return true; }
49 void draw(BufferView *, LyXFont const &, int, float &, bool) const;
51 void Edit(BufferView *, int, int, unsigned int);
53 EDITABLE Editable() const;
55 void Write(Buffer const *, std::ostream &) const;
57 void Read(Buffer const *, LyXLex & lex);
59 /** returns the number of rows (\n's) of generated tex code.
60 #fragile == true# means, that the inset should take care about
61 fragile commands by adding a #\protect# before.
63 int Latex(Buffer const *, std::ostream &,
64 bool fragile, bool free_spc) const;
66 int Ascii(Buffer const *, std::ostream &, int linelen) const;
68 int Linuxdoc(Buffer const *, std::ostream &) const;
70 int DocBook(Buffer const *, std::ostream &) const;
72 /** Tell LyX what the latex features you need i.e. what latex packages
73 you need to be included.
75 void Validate(LaTeXFeatures & features) const;
77 /// returns LyX code associated with the inset. Used for TOC, ...)
78 Inset::Code LyxCode() const { return Inset::GRAPHICS_CODE; }
81 Inset * Clone(Buffer const &) const;
83 /** Set the inset parameters, used by the GUIndependent dialog.
84 Return true of new params are different from what was so far.
86 bool setParams(InsetGraphicsParams const & params);
88 /// Get the inset parameters, used by the GUIndependent dialog.
89 InsetGraphicsParams getParams() const;
91 /** This signal is connected by our dialog and called when the inset
94 SigC::Signal0<void> hideDialog;
97 /// Update the inset after parameter change.
98 void updateInset() const;
99 /// Get the status message, depends on the image loading status.
100 char const * statusMessage() const;
101 /// Create the options for the latex command.
102 string const createLatexOptions() const;
103 /// Convert the file if needed, and return the location of the file.
104 string const prepareFile(Buffer const * buf) const;
106 /// The graphics cache handle.
107 mutable boost::shared_ptr<GraphicsCacheItem> cacheHandle;
109 /// is the pixmap initialized?
110 mutable bool imageLoaded;
112 InsetGraphicsParams params;