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"
24 #include "LaTeXFeatures.h"
26 // We need a signal here to hide an active dialog when we are deleted.
27 #include "sigc++/signal_system.h"
28 #ifdef SIGC_CXX_NAMESPACES
38 #ifdef SIGC_CXX_NAMESPACES
39 class InsetGraphics : public Inset, public SigC::Object
41 class InsetGraphics : public Inset, public Object
50 int ascent(BufferView *, LyXFont const &) const;
52 int descent(BufferView *, LyXFont const &) const;
54 int width(BufferView *, LyXFont const &) const;
56 bool display() const { return true; }
58 void draw(BufferView *, LyXFont const &, int, float &, bool) const;
60 void Edit(BufferView *, int, int, unsigned int);
62 EDITABLE Editable() const;
64 void Write(Buffer const *, std::ostream &) const;
66 void Read(Buffer const *, LyXLex & lex);
68 /** returns the number of rows (\n's) of generated tex code.
69 #fragile == true# means, that the inset should take care about
70 fragile commands by adding a #\protect# before.
72 int Latex(Buffer const *, std::ostream &,
73 bool fragile, bool free_spc) const;
75 int Ascii(Buffer const *, std::ostream &, int linelen) const;
77 int Linuxdoc(Buffer const *, std::ostream &) const;
79 int DocBook(Buffer const *, std::ostream &) const;
81 /** Tell LyX what the latex features you need i.e. what latex packages
82 you need to be included.
84 void Validate(LaTeXFeatures & features) const;
86 /// returns LyX code associated with the inset. Used for TOC, ...)
87 Inset::Code LyxCode() const { return Inset::GRAPHICS_CODE; }
90 Inset * Clone(Buffer const &) const;
92 /** Set the inset parameters, used by the GUIndependent dialog.
93 Return true of new params are different from what was so far.
95 bool setParams(InsetGraphicsParams const & params);
97 /// Get the inset parameters, used by the GUIndependent dialog.
98 InsetGraphicsParams getParams() const;
100 /** This signal is connected by our dialog and called when the inset
105 /// Update the inset after parameter change.
106 void updateInset() const;
107 /// Get the status message, depends on the image loading status.
108 char const * statusMessage() const;
109 /// Create the options for the latex command.
110 string const createLatexOptions() const;
111 /// Convert the file if needed, and return the location of the file.
112 string const prepareFile(Buffer const * buf) const;
114 /// The graphics cache handle.
115 mutable GraphicsCacheItem * cacheHandle;
118 mutable LyXImage * pixmap;
119 /// is the pixmap initialized?
120 mutable bool updateImage;
122 InsetGraphicsParams params;