]> git.lyx.org Git - lyx.git/blob - src/insets/insetgraphics.h
remove commented same_id functions, and also remove some const_casts
[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 #include "insets/inset.h"
17 #include "insets/insetgraphicsParams.h"
18
19 #include <boost/signals/trackable.hpp>
20 #include <boost/scoped_ptr.hpp>
21
22 class Dialogs;
23 class LaTeXFeatures;
24
25 ///
26 class InsetGraphics : public Inset, public boost::signals::trackable {
27 public:
28         ///
29         InsetGraphics();
30         ///
31         InsetGraphics(InsetGraphics const &, string const & filepath);
32         ///
33         ~InsetGraphics();
34         ///
35         virtual dispatch_result localDispatch(FuncRequest const & cmd);
36         ///
37         void dimension(BufferView *, LyXFont const &, Dimension &) const;
38         ///
39         void draw(BufferView *, LyXFont const &, int, float &) const;
40         ///
41         EDITABLE editable() const;
42         ///
43         void write(Buffer const *, std::ostream &) const;
44         ///
45         void read(Buffer const *, LyXLex & lex);
46
47         /** returns the number of rows (\n's) of generated tex code.
48          #fragile == true# means, that the inset should take care about
49          fragile commands by adding a #\protect# before.
50          */
51         int latex(Buffer const *, std::ostream &,
52                   LatexRunParams const &) const;
53         ///
54         int ascii(Buffer const *, std::ostream &, int linelen) const;
55         ///
56         int linuxdoc(Buffer const *, std::ostream &) const;
57         ///
58         int docbook(Buffer const *, std::ostream &, bool mixcont) const;
59
60         /** Tell LyX what the latex features you need i.e. what latex packages
61             you need to be included.
62          */
63         void validate(LaTeXFeatures & features) const;
64
65         /// returns LyX code associated with the inset. Used for TOC, ...)
66         Inset::Code lyxCode() const { return Inset::GRAPHICS_CODE; }
67
68         ///
69         virtual Inset * clone(Buffer const &) const;
70
71         /** Set the inset parameters, used by the GUIndependent dialog.
72             Return true of new params are different from what was so far.
73         */
74         bool setParams(InsetGraphicsParams const & params,
75                        string const & filepath);
76
77         /// Get the inset parameters, used by the GUIndependent dialog.
78         InsetGraphicsParams const & params() const;
79
80 private:
81         /// Returns the cached BufferView.
82         BufferView * view() const;
83
84         ///
85         friend class InsetGraphicsMailer;
86
87         /// Is the image ready to draw, or should we display a message instead?
88         bool imageIsDrawable() const;
89
90         /** This method is connected to cache_->statusChanged, so we are
91             informed when the image has been loaded.
92          */
93         void statusChanged();
94
95         /// Read the inset native format
96         void readInsetGraphics(LyXLex & lex);
97
98         /// Get the status message, depends on the image loading status.
99         string const statusMessage() const;
100         /// Create the options for the latex command.
101         string const createLatexOptions() const;
102         /// Convert the file if needed, and return the location of the file.
103         string const prepareFile(Buffer const * buf, LatexRunParams const &) const;
104
105         ///
106         InsetGraphicsParams params_;
107
108         /// holds the entity name that defines the graphics location (SGML).
109         string const graphic_label;
110
111         /// The cached variables
112         class Cache;
113         friend class Cache;
114         /// The pointer never changes although *cache_'s contents may.
115         boost::scoped_ptr<Cache> const cache_;
116 };
117
118
119 #include "mailinset.h"
120
121 class InsetGraphicsMailer : public MailInset {
122 public:
123         ///
124         InsetGraphicsMailer(InsetGraphics & inset);
125         ///
126         virtual InsetBase & inset() const { return inset_; }
127         ///
128         virtual string const & name() const { return name_; }
129         ///
130         virtual string const inset2string() const;
131         ///
132         static void string2params(string const &, InsetGraphicsParams &);
133         ///
134         static string const params2string(InsetGraphicsParams const &);
135 private:
136         ///
137         static string const name_;
138         ///
139         InsetGraphics & inset_;
140 };
141
142 #endif