]> git.lyx.org Git - lyx.git/blob - src/insets/insetgraphics.h
Don't remove cell selections after fontchange.
[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 class LyXImage;
34
35 ///
36 class InsetGraphics : public Inset, public SigC::Object {
37 public:
38         ///
39         InsetGraphics();
40         ///
41         InsetGraphics(InsetGraphics const &, bool same_id = false);
42         ///
43         ~InsetGraphics();
44         ///
45         int ascent(BufferView *, LyXFont const &) const;
46         ///
47         int descent(BufferView *, LyXFont const &) const;
48         ///
49         int width(BufferView *, LyXFont const &) const;
50         ///
51         bool display() const { return true; }
52         ///
53         void draw(BufferView *, LyXFont const &, int, float &, bool) const;
54         ///
55         void edit(BufferView *, int, int, unsigned int);
56         ///
57         void edit(BufferView * bv, bool front = true);
58         ///
59         EDITABLE editable() const;
60         ///
61         void write(Buffer const *, std::ostream &) const;
62         ///
63         void read(Buffer const *, LyXLex & lex);
64
65         /** returns the number of rows (\n's) of generated tex code.
66          #fragile == true# means, that the inset should take care about
67          fragile commands by adding a #\protect# before.
68          */
69         int latex(Buffer const *, std::ostream &,
70                   bool fragile, bool free_spc) const;
71         ///
72         int ascii(Buffer const *, std::ostream &, int linelen) const;
73         ///
74         int linuxdoc(Buffer const *, std::ostream &) const;
75         ///
76         int docbook(Buffer const *, std::ostream &) const;
77
78         /** Tell LyX what the latex features you need i.e. what latex packages
79             you need to be included.
80          */
81         void validate(LaTeXFeatures & features) const;
82
83         /// returns LyX code associated with the inset. Used for TOC, ...)
84         Inset::Code lyxCode() const { return Inset::GRAPHICS_CODE; }
85
86         ///
87         virtual Inset * clone(Buffer const &, bool same_id = false) const;
88
89         /** Set the inset parameters, used by the GUIndependent dialog.
90             Return true of new params are different from what was so far.
91         */
92         bool setParams(InsetGraphicsParams const & params);
93
94         /// Get the inset parameters, used by the GUIndependent dialog.
95         InsetGraphicsParams getParams() const;
96
97         /** This signal is connected by our dialog and called when the inset
98             is deleted.
99         */
100         SigC::Signal0<void> hideDialog;
101
102 private:
103         /// Read the inset native format
104         void readInsetGraphics(Buffer const * buf, LyXLex & lex);
105         /// Read the FigInset file format
106         void readFigInset(Buffer const * buf, LyXLex & lex);
107         
108         /// Update the inset after parameter change.
109         void updateInset() const;
110         /// Get the status message, depends on the image loading status.
111         string const statusMessage() const;
112         /// Create the options for the latex command.
113         string const createLatexOptions() const;
114         /// Convert the file if needed, and return the location of the file.
115         string const prepareFile(Buffer const * buf) const;
116         /// The graphics cache handle.
117         mutable boost::shared_ptr<GraphicsCacheItem> cacheHandle;
118         /// is the pixmap initialized?
119         mutable bool imageLoaded;
120         /// the parameters
121         InsetGraphicsParams params;
122         /// holds the entity name that defines the graphics location (SGML).
123         string const graphic_label;
124 };
125
126 #endif