]> git.lyx.org Git - lyx.git/blob - src/insets/insetgraphics.h
Make it compile when USE_BOOST_FORMAT is unset
[lyx.git] / src / insets / insetgraphics.h
1 // -*- C++ -*-
2 /**
3  * \file insetgraphics.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Baruch Even
8  * \author Herbert Voss
9  *
10  * Full author contact details are available in file CREDITS
11  */
12
13 #ifndef INSET_GRAPHICS_H
14 #define INSET_GRAPHICS_H
15
16
17 #ifdef __GNUG__
18 #pragma interface
19 #endif
20
21 #include "insets/inset.h"
22 #include "insets/insetgraphicsParams.h"
23
24 // We need a signal here to hide an active dialog when we are deleted.
25 #include <boost/signals/signal0.hpp>
26 #include <boost/signals/trackable.hpp>
27 #include <boost/scoped_ptr.hpp>
28
29 class Dialogs;
30 class LaTeXFeatures;
31
32 ///
33 class InsetGraphics : public Inset, public boost::signals::trackable {
34 public:
35         ///
36         InsetGraphics();
37         ///
38         InsetGraphics(InsetGraphics const &, string const & filepath,
39                       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         void draw(BufferView *, LyXFont const &, int, float &, bool) const;
50         ///
51         void edit(BufferView *, int, int, mouse_button::state);
52         ///
53         void edit(BufferView * bv, bool front = true);
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 &, bool mixcont) 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                        string const & filepath);
90
91         /// Get the inset parameters, used by the GUIndependent dialog.
92         InsetGraphicsParams const & params() const;
93
94         /** This signal is connected by our dialog and called when the inset
95             is deleted.
96         */
97         boost::signal0<void> hideDialog;
98
99 private:
100         /// Is the image ready to draw, or should we display a message instead?
101         bool imageIsDrawable() const;
102
103         /** This method is connected to cache_->statusChanged, so we are
104             informed when the image has been loaded.
105          */
106         void statusChanged();
107
108         /// Read the inset native format
109         void readInsetGraphics(LyXLex & lex);
110
111         /// Get the status message, depends on the image loading status.
112         string const statusMessage() const;
113         /// Create the options for the latex command.
114         string const createLatexOptions() const;
115         /// Convert the file if needed, and return the location of the file.
116         string const prepareFile(Buffer const * buf) const;
117
118         ///
119         InsetGraphicsParams params_;
120
121         /// holds the entity name that defines the graphics location (SGML).
122         string const graphic_label;
123
124         /// The cached variables
125         class Cache;
126         friend class Cache;
127         /// The pointer never changes although *cache_'s contents may.
128         boost::scoped_ptr<Cache> const cache_;
129 };
130
131 #endif