]> git.lyx.org Git - lyx.git/blob - src/insets/insetgraphics.h
updates to minipage inset
[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 #include <boost/smart_ptr.hpp>
24
25 #include "LaTeXFeatures.h"
26
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
30 using SigC::Signal0;
31 using SigC::slot;
32 using SigC::Object;
33 #endif 
34
35 class Dialogs;
36 class LyXImage;
37
38 ///
39 #ifdef SIGC_CXX_NAMESPACES
40 class InsetGraphics : public Inset, public SigC::Object
41 #else
42 class InsetGraphics : public Inset, public Object
43 #endif
44 {
45 public:
46         ///
47         InsetGraphics();
48         ///
49         ~InsetGraphics();
50         ///
51         int ascent(BufferView *, LyXFont const &) const;
52         ///
53         int descent(BufferView *, LyXFont const &) const;
54         ///
55         int width(BufferView *, LyXFont const &) const;
56         ///
57         bool display() const { return true; }
58         ///
59         void draw(BufferView *, LyXFont const &, int, float &, bool) const;
60         ///
61         void Edit(BufferView *, int, int, unsigned int);
62         ///
63         EDITABLE Editable() const;
64         ///
65         void Write(Buffer const *, std::ostream &) const;
66         ///
67         void Read(Buffer const *, LyXLex & lex);
68
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.
72          */
73         int Latex(Buffer const *, std::ostream &,
74                   bool fragile, bool free_spc) const;
75         ///
76         int Ascii(Buffer const *, std::ostream &, int linelen) const;
77         ///
78         int Linuxdoc(Buffer const *, std::ostream &) const;
79         ///
80         int DocBook(Buffer const *, std::ostream &) const;
81
82         /** Tell LyX what the latex features you need i.e. what latex packages
83             you need to be included.
84          */
85         void Validate(LaTeXFeatures & features) const;
86
87         /// returns LyX code associated with the inset. Used for TOC, ...)
88         Inset::Code LyxCode() const { return Inset::GRAPHICS_CODE; }
89
90         ///
91         Inset * Clone(Buffer const &) const;
92
93         /** Set the inset parameters, used by the GUIndependent dialog.
94             Return true of new params are different from what was so far.
95         */
96         bool setParams(InsetGraphicsParams const & params);
97
98         /// Get the inset parameters, used by the GUIndependent dialog.
99         InsetGraphicsParams getParams() const;
100
101         /** This signal is connected by our dialog and called when the inset
102             is deleted.
103         */
104         Signal0 <void> hideDialog;
105
106 private:
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;
115
116         /// The graphics cache handle.
117         mutable boost::shared_ptr<GraphicsCacheItem> cacheHandle;
118
119         /// is the pixmap initialized?
120         mutable bool imageLoaded;
121
122         InsetGraphicsParams params;
123 };
124
125 #endif