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"
25 /////////////////////////////////////////////////////////////////////////
29 /////////////////////////////////////////////////////////////////////////
31 /// Used for images etc.
32 class InsetGraphics : public Inset
36 InsetGraphics(Buffer * buf);
41 static void string2params(std::string const & data,
42 Buffer const & buffer,
43 InsetGraphicsParams &);
45 static std::string params2string(InsetGraphicsParams const &,
48 /** Set the inset parameters, used by the GUIndependent dialog.
49 Return true of new params are different from what was so far.
51 bool setParams(InsetGraphicsParams const & params);
53 InsetGraphicsParams getParams() const { return params_;}
55 bool clickable(int, int) const { return true; }
59 InsetGraphics(InsetGraphics const &);
62 bool isLabeled() const { return true; }
63 void metrics(MetricsInfo &, Dimension &) const;
65 bool hasSettings() const { return true; }
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;
80 docstring xhtml(XHTMLStream & os, 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 bool showInsetDialog(BufferView * bv) const;
94 void editGraphics(InsetGraphicsParams 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 /// This version is for use with LaTeX-style output.
117 std::string prepareFile(OutputParams const &) const;
118 /// Convert the file if needed, and return the location of the file.
119 /// This version is for use with HTML-style output.
120 /// \return the new filename, relative to the location of the HTML file,
121 /// or an empty string on error.
122 std::string prepareHTMLFile(OutputParams const & runparams) const;
125 InsetGraphicsParams params_;
126 /// holds the entity name that defines the graphics location (SGML).
127 docstring const graphic_label;
128 /// The thing that actually draws the image on LyX's screen.
129 RenderGraphic * graphic_;
134 /// Saves the list of currently used groups in the document.
135 void getGraphicsGroups(Buffer const &, std::set<std::string> &);
137 /// how many members has the current group?
138 int countGroupMembers(Buffer const &, std::string const &);
140 /// Returns parameters of a given graphics group (except filename).
141 std::string getGroupParams(Buffer const &, std::string const &);
143 /** Synchronize all Graphics insets of the group.
144 Both groupId and params are taken from argument.
146 void unifyGraphicsGroups(Buffer &, std::string const &);
147 InsetGraphics * getCurrentGraphicsInset(Cursor const &);
153 #endif // INSET_GRAPHICS_H