]> git.lyx.org Git - lyx.git/blob - src/insets/insetgraphics.h
Backout my fuck up.
[lyx.git] / src / insets / insetgraphics.h
1 // -*- C++ -*-
2 /* This file is part of
3  * ====================================================== 
4  * 
5  *           LyX, The Document Processor
6  *       
7  *           Copyright 1995 Matthias Ettrich
8  *           Copyright 1995-2001 the LyX Team.
9  *
10  * \author Baruch Even
11  * \author Herbert Voss <voss@lyx.org>
12  * ====================================================== */
13
14 #ifndef INSET_GRAPHICS_H
15 #define INSET_GRAPHICS_H
16
17
18 #ifdef __GNUG__
19 #pragma interface
20 #endif 
21
22 #include "insets/inset.h"
23 #include "insets/insetgraphicsParams.h"
24 #include "graphics/GraphicsCacheItem.h"
25 #include <boost/smart_ptr.hpp>
26
27 #include "LaTeXFeatures.h"
28
29 // We need a signal here to hide an active dialog when we are deleted.
30 #include "sigc++/signal_system.h"
31
32 class Dialogs;
33
34 ///
35 class InsetGraphics : public Inset, public SigC::Object {
36 public:
37         ///
38         InsetGraphics();
39         ///
40         InsetGraphics(InsetGraphics const &, bool same_id = false);
41         ///
42         ~InsetGraphics();
43         ///
44         int ascent(BufferView *, LyXFont const &) const;
45         ///
46         int descent(BufferView *, LyXFont const &) const;
47         ///
48         int width(BufferView *, LyXFont const &) const;
49         ///
50         bool display() const { return true; }
51         ///
52         void draw(BufferView *, LyXFont const &, int, float &, bool) const;
53         ///
54         void edit(BufferView *, int, int, unsigned int);
55         ///
56         void edit(BufferView * bv, bool front = true);
57         ///
58         EDITABLE editable() const;
59         ///
60         void write(Buffer const *, std::ostream &) const;
61         ///
62         void read(Buffer const *, LyXLex & lex);
63
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.
67          */
68         int latex(Buffer const *, std::ostream &,
69                   bool fragile, bool free_spc) const;
70         ///
71         int ascii(Buffer const *, std::ostream &, int linelen) const;
72         ///
73         int linuxdoc(Buffer const *, std::ostream &) const;
74         ///
75         int docbook(Buffer const *, std::ostream &) const;
76
77         /** Tell LyX what the latex features you need i.e. what latex packages
78             you need to be included.
79          */
80         void validate(LaTeXFeatures & features) const;
81
82         /// returns LyX code associated with the inset. Used for TOC, ...)
83         Inset::Code lyxCode() const { return Inset::GRAPHICS_CODE; }
84
85         ///
86         virtual Inset * clone(Buffer const &, bool same_id = false) const;
87
88         /** Set the inset parameters, used by the GUIndependent dialog.
89             Return true of new params are different from what was so far.
90         */
91         bool setParams(InsetGraphicsParams const & params);
92
93         /// Get the inset parameters, used by the GUIndependent dialog.
94         InsetGraphicsParams getParams() const;
95
96         /** This signal is connected by our dialog and called when the inset
97             is deleted.
98         */
99         SigC::Signal0<void> hideDialog;
100
101 private:
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);
106         
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;
115         ///
116         InsetGraphicsParams params;
117 };
118
119 #endif