]> git.lyx.org Git - lyx.git/blob - src/insets/insetgraphics.h
drop linuxdoc support (part 1)
[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 Voß
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 "inset.h"
17 #include "insetgraphicsParams.h"
18
19 #include <boost/scoped_ptr.hpp>
20 #include <boost/signals/trackable.hpp>
21
22 class Dialogs;
23 class RenderGraphic;
24 class LaTeXFeatures;
25
26 ///
27 class InsetGraphics : public InsetOld, public boost::signals::trackable {
28 public:
29         ///
30         InsetGraphics();
31         ///
32         ~InsetGraphics();
33         ///
34         void metrics(MetricsInfo &, Dimension &) const;
35         ///
36         EDITABLE editable() const;
37         ///
38         void write(Buffer const &, std::ostream &) const;
39         ///
40         void read(Buffer const &, LyXLex & lex);
41
42         /** returns the number of rows (\n's) of generated tex code.
43          #fragile == true# means, that the inset should take care about
44          fragile commands by adding a #\protect# before.
45          */
46         int latex(Buffer const &, std::ostream &,
47                   OutputParams const &) const;
48         ///
49         int plaintext(Buffer const &, std::ostream &,
50                   OutputParams const &) const;
51         ///
52         int docbook(Buffer const &, std::ostream &,
53                     OutputParams const &) const;
54
55         /** Tell LyX what the latex features you need i.e. what latex packages
56             you need to be included.
57          */
58         void validate(LaTeXFeatures & features) const;
59
60         /// returns LyX code associated with the inset. Used for TOC, ...)
61         InsetBase::Code lyxCode() const { return InsetBase::GRAPHICS_CODE; }
62
63         /** Set the inset parameters, used by the GUIndependent dialog.
64             Return true of new params are different from what was so far.
65         */
66         bool setParams(InsetGraphicsParams const & params);
67
68         /// Get the inset parameters, used by the GUIndependent dialog.
69         InsetGraphicsParams const & params() const;
70         ///
71         void draw(PainterInfo & pi, int x, int y) const;
72         ///
73         void edit(LCursor & cur, bool left);
74         ///
75         void editGraphics(InsetGraphicsParams const &, Buffer const &) const;
76         ///
77         bool getStatus(LCursor &, FuncRequest const &, FuncStatus &) const;
78 protected:
79         InsetGraphics(InsetGraphics const &);
80         ///
81         virtual void doDispatch(LCursor & cur, FuncRequest & cmd);
82 private:
83         friend class InsetGraphicsMailer;
84
85         virtual std::auto_ptr<InsetBase> doClone() const;
86
87         /// Read the inset native format
88         void readInsetGraphics(LyXLex & lex, std::string const & bufpath);
89
90         /// Get the status message, depends on the image loading status.
91         std::string const statusMessage() const;
92         /// Create the options for the latex command.
93         std::string const createLatexOptions() const;
94         /// Create length values for docbook export.
95         std::string const toDocbookLength(LyXLength const & len) const;
96         /// Create the atributes for docbook export.
97         std::string const createDocBookAttributes() const;
98         /// Convert the file if needed, and return the location of the file.
99         std::string const prepareFile(Buffer const & buf, OutputParams const &) const;
100
101         ///
102         InsetGraphicsParams params_;
103
104         /// holds the entity name that defines the graphics location (SGML).
105         std::string const graphic_label;
106
107         /// The thing that actually draws the image on LyX's screen.
108         boost::scoped_ptr<RenderGraphic> const graphic_;
109 };
110
111
112 #include "mailinset.h"
113
114 class InsetGraphicsMailer : public MailInset {
115 public:
116         ///
117         InsetGraphicsMailer(InsetGraphics & inset);
118         ///
119         virtual InsetBase & inset() const { return inset_; }
120         ///
121         virtual std::string const & name() const { return name_; }
122         ///
123         virtual std::string const inset2string(Buffer const &) const;
124         ///
125         static void string2params(std::string const & data,
126                                   Buffer const & buffer,
127                                   InsetGraphicsParams &);
128         ///
129         static std::string const params2string(InsetGraphicsParams const &,
130                                           Buffer const &);
131 private:
132         ///
133         static std::string const name_;
134         ///
135         InsetGraphics & inset_;
136 };
137
138 #endif