]> git.lyx.org Git - lyx.git/blob - src/insets/insetgraphics.h
More InsetText/InsetTabular fixes!
[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-2000 the LyX Team.
9  *
10  * ====================================================== */
11
12 #ifndef INSET_GRAPHICS_H
13 #define INSET_GRAPHICS_H
14
15
16 #ifdef __GNUG__
17 #pragma interface
18 #endif 
19
20 #include "insets/lyxinset.h"
21 #include "insets/insetgraphicsParams.h"
22 #include "graphics/GraphicsCacheItem.h"
23
24 #include "LaTeXFeatures.h"
25
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
29 using SigC::Signal0;
30 using SigC::slot;
31 using SigC::Object;
32 #endif 
33
34 class Dialogs;
35 class LyXImage;
36
37 ///
38 #ifdef SIGC_CXX_NAMESPACES
39 class InsetGraphics : public Inset, public SigC::Object
40 #else
41 class InsetGraphics : public Inset, public Object
42 #endif
43 {
44 public:
45         ///
46         InsetGraphics();
47         ///
48         ~InsetGraphics();
49         ///
50         int ascent(BufferView *, LyXFont const &) const;
51         ///
52         int descent(BufferView *, LyXFont const &) const;
53         ///
54         int width(BufferView *, LyXFont const &) const;
55         ///
56         bool display() const { return true; }
57         ///
58         void draw(BufferView *, LyXFont const &, int, float &, bool) const;
59         ///
60         void Edit(BufferView *, int, int, unsigned int);
61         ///
62         EDITABLE Editable() const;
63         ///
64         void Write(Buffer const *, std::ostream &) const;
65         ///
66         void Read(Buffer const *, LyXLex & lex);
67
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.
71          */
72         int Latex(Buffer const *, std::ostream &,
73                   bool fragile, bool free_spc) const;
74         ///
75         int Ascii(Buffer const *, std::ostream &, int linelen) const;
76         ///
77         int Linuxdoc(Buffer const *, std::ostream &) const;
78         ///
79         int DocBook(Buffer const *, std::ostream &) const;
80
81         /** Tell LyX what the latex features you need i.e. what latex packages
82             you need to be included.
83          */
84         void Validate(LaTeXFeatures & features) const;
85
86         /// returns LyX code associated with the inset. Used for TOC, ...)
87         Inset::Code LyxCode() const { return Inset::GRAPHICS_CODE; }
88
89         ///
90         Inset * Clone(Buffer const &) const;
91
92         /** Set the inset parameters, used by the GUIndependent dialog.
93             Return true of new params are different from what was so far.
94         */
95         bool setParams(InsetGraphicsParams const & params);
96
97         /// Get the inset parameters, used by the GUIndependent dialog.
98         InsetGraphicsParams getParams() const;
99
100         /** This signal is connected by our dialog and called when the inset
101             is deleted.
102         */
103         Signal0 <void> hideDialog;
104
105 private:
106         /// Update the inset after parameter change.
107         void updateInset() const;
108         /// Get the status message, depends on the image loading status.
109         char const * statusMessage() const;
110         /// Create the options for the latex command.
111         string const createLatexOptions() const;
112         /// Convert the file if needed, and return the location of the file.
113         string const prepareFile(Buffer const * buf) const;
114
115         /// The graphics cache handle.
116         mutable GraphicsCacheItem * cacheHandle;
117
118         /// is the pixmap initialized?
119         mutable bool imageLoaded;
120
121         InsetGraphicsParams params;
122 };
123
124 #endif