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"
29 #ifdef SIGC_CXX_NAMESPACES
39 #ifdef SIGC_CXX_NAMESPACES
40 class InsetGraphics : public Inset, public SigC::Object
42 class InsetGraphics : public Inset, public Object
51 int ascent(BufferView *, LyXFont const &) const;
53 int descent(BufferView *, LyXFont const &) const;
55 int width(BufferView *, LyXFont const &) const;
57 bool display() const { return true; }
59 void draw(BufferView *, LyXFont const &, int, float &, bool) const;
61 void Edit(BufferView *, int, int, unsigned int);
63 EDITABLE Editable() const;
65 void Write(Buffer const *, std::ostream &) const;
67 void Read(Buffer const *, LyXLex & lex);
69 /** returns the number of rows (\n's) of generated tex code.
70 #fragile == true# means, that the inset should take care about
71 fragile commands by adding a #\protect# before.
73 int Latex(Buffer const *, std::ostream &,
74 bool fragile, bool free_spc) const;
76 int Ascii(Buffer const *, std::ostream &, int linelen) const;
78 int Linuxdoc(Buffer const *, std::ostream &) const;
80 int DocBook(Buffer const *, std::ostream &) const;
82 /** Tell LyX what the latex features you need i.e. what latex packages
83 you need to be included.
85 void Validate(LaTeXFeatures & features) const;
87 /// returns LyX code associated with the inset. Used for TOC, ...)
88 Inset::Code LyxCode() const { return Inset::GRAPHICS_CODE; }
91 Inset * Clone(Buffer const &) const;
93 /** Set the inset parameters, used by the GUIndependent dialog.
94 Return true of new params are different from what was so far.
96 bool setParams(InsetGraphicsParams const & params);
98 /// Get the inset parameters, used by the GUIndependent dialog.
99 InsetGraphicsParams getParams() const;
101 /** This signal is connected by our dialog and called when the inset
104 Signal0 <void> hideDialog;
107 /// Update the inset after parameter change.
108 void updateInset() const;
109 /// Get the status message, depends on the image loading status.
110 char const * statusMessage() const;
111 /// Create the options for the latex command.
112 string const createLatexOptions() const;
113 /// Convert the file if needed, and return the location of the file.
114 string const prepareFile(Buffer const * buf) const;
116 /// The graphics cache handle.
117 mutable boost::shared_ptr<GraphicsCacheItem> cacheHandle;
119 /// is the pixmap initialized?
120 mutable bool imageLoaded;
122 InsetGraphicsParams params;