2 /* This file is part of
3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright 1995 Matthias Ettrich
8 * Copyright 1995-2001 the LyX Team.
11 * \author Herbert Voss <voss@lyx.org>
12 * ====================================================== */
14 #ifndef INSET_GRAPHICS_H
15 #define INSET_GRAPHICS_H
22 #include "insets/inset.h"
23 #include "insets/insetgraphicsParams.h"
24 #include "graphics/GraphicsCacheItem.h"
25 #include <boost/smart_ptr.hpp>
27 #include "LaTeXFeatures.h"
29 // We need a signal here to hide an active dialog when we are deleted.
30 #include "sigc++/signal_system.h"
35 class InsetGraphics : public Inset, public SigC::Object {
40 InsetGraphics(InsetGraphics const &, bool same_id = false);
44 int ascent(BufferView *, LyXFont const &) const;
46 int descent(BufferView *, LyXFont const &) const;
48 int width(BufferView *, LyXFont const &) const;
50 bool display() const { return true; }
52 void draw(BufferView *, LyXFont const &, int, float &, bool) const;
54 void edit(BufferView *, int, int, unsigned int);
56 void edit(BufferView * bv, bool front = true);
58 EDITABLE editable() const;
60 void write(Buffer const *, std::ostream &) const;
62 void read(Buffer const *, LyXLex & lex);
64 /** returns the number of rows (\n's) of generated tex code.
65 #fragile == true# means, that the inset should take care about
66 fragile commands by adding a #\protect# before.
68 int latex(Buffer const *, std::ostream &,
69 bool fragile, bool free_spc) const;
71 int ascii(Buffer const *, std::ostream &, int linelen) const;
73 int linuxdoc(Buffer const *, std::ostream &) const;
75 int docbook(Buffer const *, std::ostream &) const;
77 /** Tell LyX what the latex features you need i.e. what latex packages
78 you need to be included.
80 void validate(LaTeXFeatures & features) const;
82 /// returns LyX code associated with the inset. Used for TOC, ...)
83 Inset::Code lyxCode() const { return Inset::GRAPHICS_CODE; }
86 virtual Inset * clone(Buffer const &, bool same_id = false) const;
88 /** Set the inset parameters, used by the GUIndependent dialog.
89 Return true of new params are different from what was so far.
91 bool setParams(InsetGraphicsParams const & params);
93 /// Get the inset parameters, used by the GUIndependent dialog.
94 InsetGraphicsParams getParams() const;
96 /** This signal is connected by our dialog and called when the inset
99 SigC::Signal0<void> hideDialog;
102 /// Read the inset native format
103 void readInsetGraphics(Buffer const * buf, LyXLex & lex);
104 /// Read the FigInset file format
105 void readFigInset(Buffer const * buf, LyXLex & lex);
107 /// Update the inset after parameter change.
108 void updateInset() const;
109 /// Get the status message, depends on the image loading status.
110 string 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 InsetGraphicsParams params;