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