]> git.lyx.org Git - lyx.git/blob - src/insets/InsetGraphics.h
dae9a701d2a42711b8b01bae621058c9381c09de
[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
23 namespace lyx {
24
25 class RenderGraphic;
26 class LaTeXFeatures;
27
28 /////////////////////////////////////////////////////////////////////////
29 //
30 // InsetGraphics
31 //
32 /////////////////////////////////////////////////////////////////////////
33
34 /// Used for images etc.
35 class InsetGraphics : public Inset, public boost::signals::trackable
36 {
37 public:
38         ///
39         InsetGraphics(Buffer & buf);
40         ///
41         ~InsetGraphics();
42
43         ///
44         static void string2params(std::string const & data,
45                                   Buffer const & buffer,
46                                   InsetGraphicsParams &);
47         ///
48         static std::string params2string(InsetGraphicsParams const &,
49                                           Buffer const &);
50         /** Set the inset parameters, used by the GUIndependent dialog.
51             Return true of new params are different from what was so far.
52         */
53         bool setParams(InsetGraphicsParams const & params);
54
55 private:
56         ///
57         InsetGraphics(InsetGraphics const &);
58
59         ///
60         bool isLabeled() const { return true; }
61         void metrics(MetricsInfo &, Dimension &) const;
62         ///
63         EDITABLE editable() const;
64         ///
65         void write(std::ostream &) const;
66         ///
67         void read(Lexer & lex);
68         /** returns the number of rows (\n's) of generated tex code.
69          #fragile == true# means, that the inset should take care about
70          fragile commands by adding a #\protect# before.
71          */
72         int latex(odocstream &, OutputParams const &) const;
73         ///
74         int plaintext(odocstream &, OutputParams const &) const;
75         ///
76         int docbook(odocstream &, OutputParams const &) const;
77         /** Tell LyX what the latex features you need i.e. what latex packages
78             you need to be included.
79          */
80         void validate(LaTeXFeatures & features) const;
81         /// returns LyX code associated with the inset. Used for TOC, ...)
82         InsetCode lyxCode() const { return GRAPHICS_CODE; }
83         /// Get the inset parameters, used by the GUIndependent dialog.
84         InsetGraphicsParams const & params() const;
85         ///
86         void draw(PainterInfo & pi, int x, int y) const;
87         ///
88         void edit(Cursor & cur, bool front, EntryDirection entry_from);
89         ///
90         void editGraphics(InsetGraphicsParams const &, Buffer const &) const;
91         ///
92         bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;
93         ///
94         void addToToc(ParConstIterator const &) const;
95         ///
96         docstring contextMenu(BufferView const & bv, int x, int y) const;
97         /// Force inset into LTR environment if surroundings are RTL?
98         bool forceLTR() const { return true; }
99         ///
100         void doDispatch(Cursor & cur, FuncRequest & cmd);
101         ///
102         Inset * clone() const;
103         /// Get the status message, depends on the image loading status.
104         std::string statusMessage() const;
105         /// Create the options for the latex command.
106         std::string createLatexOptions() const;
107         /// Create length values for docbook export.
108         docstring toDocbookLength(Length const & len) const;
109         /// Create the atributes for docbook export.
110         docstring createDocBookAttributes() const;
111         /// Convert the file if needed, and return the location of the file.
112         std::string prepareFile(OutputParams const &) const;
113
114         ///
115         InsetGraphicsParams params_;
116         /// holds the entity name that defines the graphics location (SGML).
117         docstring const graphic_label;
118         /// The thing that actually draws the image on LyX's screen.
119         boost::scoped_ptr<RenderGraphic> const graphic_;
120 };
121
122 } // namespace lyx
123
124 #endif // INSET_GRAPHICS_H