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
18 #include "InsetGraphicsParams.h"
20 #include <boost/scoped_ptr.hpp>
21 #include <boost/signals/trackable.hpp>
29 /////////////////////////////////////////////////////////////////////////
33 /////////////////////////////////////////////////////////////////////////
35 /// Used for images etc.
36 class InsetGraphics : public Inset, public boost::signals::trackable
40 InsetGraphics(Buffer & buf);
45 static void string2params(std::string const & data,
46 Buffer const & buffer,
47 InsetGraphicsParams &);
49 static std::string params2string(InsetGraphicsParams const &,
52 /** Set the inset parameters, used by the GUIndependent dialog.
53 Return true of new params are different from what was so far.
55 bool setParams(InsetGraphicsParams const & params);
57 InsetGraphicsParams getParams() const { return params_;}
61 InsetGraphics(InsetGraphics const &);
64 bool isLabeled() const { return true; }
65 void metrics(MetricsInfo &, Dimension &) const;
67 EDITABLE editable() const;
69 void write(std::ostream &) const;
71 void read(Lexer & lex);
72 /** returns the number of rows (\n's) of generated tex code.
73 #fragile == true# means, that the inset should take care about
74 fragile commands by adding a #\protect# before.
76 int latex(odocstream &, OutputParams const &) const;
78 int plaintext(odocstream &, OutputParams const &) const;
80 int docbook(odocstream &, OutputParams const &) const;
81 /** Tell LyX what the latex features you need i.e. what latex packages
82 you need to be included.
84 void validate(LaTeXFeatures & features) const;
85 /// returns LyX code associated with the inset. Used for TOC, ...)
86 InsetCode lyxCode() const { return GRAPHICS_CODE; }
87 /// Get the inset parameters, used by the GUIndependent dialog.
88 InsetGraphicsParams const & params() const;
90 void draw(PainterInfo & pi, int x, int y) const;
92 void edit(Cursor & cur, bool front, EntryDirection entry_from);
94 void editGraphics(InsetGraphicsParams const &, Buffer const &) const;
96 bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;
98 void addToToc(DocIterator const &);
100 docstring contextMenu(BufferView const & bv, int x, int y) const;
101 /// Force inset into LTR environment if surroundings are RTL?
102 bool forceLTR() const { return true; }
104 void doDispatch(Cursor & cur, FuncRequest & cmd);
106 Inset * clone() const;
107 /// Get the status message, depends on the image loading status.
108 std::string statusMessage() const;
109 /// Create the options for the latex command.
110 std::string createLatexOptions() const;
111 /// Create length values for docbook export.
112 docstring toDocbookLength(Length const & len) const;
113 /// Create the atributes for docbook export.
114 docstring createDocBookAttributes() const;
115 /// Convert the file if needed, and return the location of the file.
116 std::string prepareFile(OutputParams const &) const;
119 InsetGraphicsParams params_;
120 /// holds the entity name that defines the graphics location (SGML).
121 docstring const graphic_label;
122 /// The thing that actually draws the image on LyX's screen.
123 boost::scoped_ptr<RenderGraphic> const graphic_;
128 /// Saves the list of currently used groups in the document.
129 void getGraphicsGroups(Buffer const &, std::set<std::string> &);
131 /// Returns parameters of a given graphics group (except filename).
132 std::string getGroupParams(Buffer const &, std::string const &);
134 /** Synchronize all Graphics insets of the group.
135 Both groupId and params are taken from argument.
137 void unifyGraphicsGroups(Buffer &, std::string const &);
138 InsetGraphics * getCurrentGraphicsInset(Cursor const &);
144 #endif // INSET_GRAPHICS_H