2 /* This file is part of
3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright 1995 Matthias Ettrich
8 * Copyright 1995-2000 the LyX Team.
10 * ====================================================== */
12 #ifndef INSET_GRAPHICS_H
13 #define INSET_GRAPHICS_H
19 #include "insets/lyxinset.h"
20 #include "insets/insetgraphicsParams.h"
22 #include "LaTeXFeatures.h"
24 // We need a signal here to hide an active dialog when we are deleted.
25 #include "sigc++/signal_system.h"
26 #ifdef SIGC_CXX_NAMESPACES
31 class GraphicsCacheItem;
34 class InsetGraphics : public Inset {
41 int ascent(BufferView *, LyXFont const &) const;
43 int descent(BufferView *, LyXFont const &) const;
45 int width(BufferView *, LyXFont const &) const;
47 bool display() const { return true; }
49 void draw(BufferView *, LyXFont const &, int, float &, bool) const;
51 void Edit(BufferView *, int, int, unsigned int);
53 EDITABLE Editable() const;
55 void Write(Buffer const *, std::ostream &) const;
57 void Read(Buffer const *, LyXLex & lex);
59 /** returns the number of rows (\n's) of generated tex code.
60 fragile == true means, that the inset should take care about
61 fragile commands by adding a \protect before.
63 int Latex(Buffer const *, std::ostream &,
64 bool fragile, bool free_spc) const;
66 int Ascii(Buffer const *, std::ostream &) const;
68 int Linuxdoc(Buffer const *, std::ostream &) const;
70 int DocBook(Buffer const *, std::ostream &) const;
72 /** Tell LyX what the latex features you need i.e. what latex packages
73 * you need to be included.
75 void Validate(LaTeXFeatures & features) const;
77 /// returns LyX code associated with the inset. Used for TOC, ...)
78 Inset::Code LyxCode() const { return Inset::GRAPHICS_CODE; }
81 Inset * Clone() const;
83 /// Set the inset parameters, used by the GUIndependent dialog.
84 /// Return true of new params are different from what was so far.
85 bool setParams(InsetGraphicsParams const & params);
87 /// Get the inset parameters, used by the GUIndependent dialog.
88 InsetGraphicsParams getParams() const;
90 /// This signal is connected by our dialog and called when the inset
94 /// Update the inset after parameter change.
97 /// The graphics cache handle.
98 GraphicsCacheItem * cachehandle;
101 InsetGraphicsParams params;
103 // Baruch Even (baruch.even@writeme.com) 2000-07-17
104 // This was the intended way however it is not flexible enough and
105 // only provides for LaTeX output.
107 // We need variables to store the size of the boundingbox and
108 // to store a pointer to the pixmap in.. The question is if
109 // these should be in a "pixmap" class.
110 // We also need to have variables about rotation and scaling,
111 // width and height. in effect all the paramters that
112 // \includegraphics can handle. (the graphix.sty package)
114 /** The "bounding box" of the graphics image. Its value field
115 must contain four dimensions, separated by spaces. */
117 /** The bounding box above is used for display and file both.
118 But we need this variable below to know if we shall use the
119 bounding box in the LaTex command or not. (i.e. if the user
120 has manually set the bb.) */
123 /** When a graphics file is parsed we first check for BoundingBox
124 and then for HiResBoundingBox, and set hiresbb depending on this.
125 This key makes LaTeX search for %%HiResBoundingBox comments
126 instead of the normal %%BoundingBox. Some applications use
127 this to specify more precise bounding boxes, becase the numbers
128 can normally only have integer values. It is a Boolean, either
129 "true" or "false". */
132 /** This key takes four arguments (like bb), but in this case the
133 origin is taken with respect to the bounding box specified in
134 the file. So to view a 20 bp square at the lower left-hand corner
135 of the picture, specify viewport=0 0 20 20. */
136 BoundingBox viewport;
138 /** Similar to the viewport key, but the four dimensions correspond
139 to the amount of space to be trimmed (cut off) at the left-hand
140 side, bottom, right-hand side and top of the included graphics. */
143 /// Natural height of figure
146 /// Natural width of figure.
149 /// Rotation angle (in degrees, counterclockwise).
152 /** Origin for rotation, similar to the origin parameter of
153 the \rotatebox command described on p.46 and Fig. 2.2 on p.46. */
156 /// Required width (the width of the image is scaled to that value).
159 /// Required height (the height of the image is scaled to that value).
162 /** Required total height (the total height of the image is scaled
163 to that value). This key should be used instead of height if
164 images are rotated over 90 degrees, since the height can
165 disappear (and become the depth) and LaTeX will have difficulties
166 satisfying the user's request. */
167 LyXLength totalheight;
169 /** Boolean variable that can have the values "true" and "false"
170 (se above for defaults). When true, specifying both width and
171 height parameters does not distort the picture, but the image
172 is scaled so that neither of the width of height exceeds the
174 bool keepaspectratio;
179 /** Clip the graphic to the bounding box. It is a Boolean, either
180 "true" or "false". */
183 /// Locally switch to draft mode. A Boolean valued key, like clip.
186 /// The graphics type.
189 /// The file extension of the file containing the image data.
192 /// The file extension of the file "read" by LaTeX.
195 /// Any command to be applied to the file.