3 * \file InsetGraphics.h
4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
10 * Full author contact details are available in file CREDITS.
13 #ifndef INSET_GRAPHICS_H
14 #define INSET_GRAPHICS_H
17 #include "InsetGraphicsParams.h"
19 #include <boost/scoped_ptr.hpp>
20 #include <boost/signals/trackable.hpp>
28 /////////////////////////////////////////////////////////////////////////
32 /////////////////////////////////////////////////////////////////////////
34 /// Used for images etc.
35 class InsetGraphics : public Inset, public boost::signals::trackable
39 InsetGraphics(Buffer & buf);
44 static void string2params(std::string const & data,
45 Buffer const & buffer,
46 InsetGraphicsParams &);
48 static std::string params2string(InsetGraphicsParams const &,
50 /** Set the inset parameters, used by the GUIndependent dialog.
51 Return true of new params are different from what was so far.
53 bool setParams(InsetGraphicsParams const & params);
57 InsetGraphics(InsetGraphics const &);
60 void setBuffer(Buffer & buffer);
62 bool isLabeled() const { return true; }
63 void metrics(MetricsInfo &, Dimension &) const;
65 EDITABLE editable() const;
67 void write(std::ostream &) const;
69 void read(Lexer & lex);
70 /** returns the number of rows (\n's) of generated tex code.
71 #fragile == true# means, that the inset should take care about
72 fragile commands by adding a #\protect# before.
74 int latex(odocstream &, OutputParams const &) const;
76 int plaintext(odocstream &, OutputParams const &) const;
78 int docbook(odocstream &, OutputParams const &) const;
79 /** Tell LyX what the latex features you need i.e. what latex packages
80 you need to be included.
82 void validate(LaTeXFeatures & features) const;
83 /// returns LyX code associated with the inset. Used for TOC, ...)
84 InsetCode lyxCode() const { return GRAPHICS_CODE; }
85 /// Get the inset parameters, used by the GUIndependent dialog.
86 InsetGraphicsParams const & params() const;
88 void draw(PainterInfo & pi, int x, int y) const;
90 void edit(Cursor & cur, bool front, EntryDirection entry_from);
92 void editGraphics(InsetGraphicsParams const &, Buffer const &) const;
94 bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;
95 /// all graphics can be embedded
96 void registerEmbeddedFiles(EmbeddedFileList &) const;
98 void updateEmbeddedFile(EmbeddedFile const &);
100 void addToToc(ParConstIterator const &) const;
102 docstring contextMenu(BufferView const & bv, int x, int y) const;
103 /// Force inset into LTR environment if surroundings are RTL?
104 bool forceLTR() const { return true; }
106 void doDispatch(Cursor & cur, FuncRequest & cmd);
108 Inset * clone() const;
109 /// Get the status message, depends on the image loading status.
110 std::string statusMessage() const;
111 /// Create the options for the latex command.
112 std::string createLatexOptions() const;
113 /// Create length values for docbook export.
114 docstring toDocbookLength(Length const & len) const;
115 /// Create the atributes for docbook export.
116 docstring createDocBookAttributes() const;
117 /// Convert the file if needed, and return the location of the file.
118 std::string prepareFile(OutputParams const &) const;
121 InsetGraphicsParams params_;
122 /// holds the entity name that defines the graphics location (SGML).
123 docstring const graphic_label;
124 /// The thing that actually draws the image on LyX's screen.
125 boost::scoped_ptr<RenderGraphic> const graphic_;
130 #endif // INSET_GRAPHICS_H