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
22 #include "insets/lyxinset.h"
23 #include "insets/insetgraphicsParams.h"
24 #include "graphics/GraphicsCacheItem.h"
26 #include "LaTeXFeatures.h"
28 // We need a signal here to hide an active dialog when we are deleted.
29 #include "sigc++/signal_system.h"
30 #ifdef SIGC_CXX_NAMESPACES
39 #ifdef SIGC_CXX_NAMESPACES
40 class InsetGraphics : public Inset, public SigC::Object {
42 class InsetGraphics : public Inset, public Object {
50 int ascent(BufferView *, LyXFont const &) const;
52 int descent(BufferView *, LyXFont const &) const;
54 int width(BufferView *, LyXFont const &) const;
56 bool display() const { return true; }
58 void draw(BufferView *, LyXFont const &, int, float &, bool) const;
60 void Edit(BufferView *, int, int, unsigned int);
62 EDITABLE Editable() const;
64 void Write(Buffer const *, std::ostream &) const;
66 void Read(Buffer const *, LyXLex & 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.
72 int Latex(Buffer const *, std::ostream &,
73 bool fragile, bool free_spc) const;
75 int Ascii(Buffer const *, std::ostream &) const;
77 int Linuxdoc(Buffer const *, std::ostream &) const;
79 int DocBook(Buffer const *, std::ostream &) 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;
86 /// returns LyX code associated with the inset. Used for TOC, ...)
87 Inset::Code LyxCode() const { return Inset::GRAPHICS_CODE; }
90 Inset * Clone() const;
92 /// Set the inset parameters, used by the GUIndependent dialog.
93 /// Return true of new params are different from what was so far.
94 bool setParams(InsetGraphicsParams const & params);
96 /// Get the inset parameters, used by the GUIndependent dialog.
97 InsetGraphicsParams getParams() const;
99 /// This signal is connected by our dialog and called when the inset
103 /// Update the inset after parameter change.
106 /// The graphics cache handle.
107 GraphicsCacheItem * cacheHandle;
110 mutable Pixmap pixmap;
111 /// is the pixmap initialized?
112 mutable bool pixmapInitialized;
114 InsetGraphicsParams params;
116 // Baruch Even (baruch.even@writeme.com) 2000-07-17
117 // This was the intended way however it is not flexible enough and
118 // only provides for LaTeX output.
120 // We need variables to store the size of the boundingbox and
121 // to store a pointer to the pixmap in.. The question is if
122 // these should be in a "pixmap" class.
123 // We also need to have variables about rotation and scaling,
124 // width and height. in effect all the paramters that
125 // \includegraphics can handle. (the graphix.sty package)
127 /** The "bounding box" of the graphics image. Its value field
128 must contain four dimensions, separated by spaces. */
130 /** The bounding box above is used for display and file both.
131 But we need this variable below to know if we shall use the
132 bounding box in the LaTex command or not. (i.e. if the user
133 has manually set the bb.) */
136 /** When a graphics file is parsed we first check for BoundingBox
137 and then for HiResBoundingBox, and set hiresbb depending on this.
138 This key makes LaTeX search for %%HiResBoundingBox comments
139 instead of the normal %%BoundingBox. Some applications use
140 this to specify more precise bounding boxes, becase the numbers
141 can normally only have integer values. It is a Boolean, either
142 "true" or "false". */
145 /** This key takes four arguments (like bb), but in this case the
146 origin is taken with respect to the bounding box specified in
147 the file. So to view a 20 bp square at the lower left-hand corner
148 of the picture, specify viewport=0 0 20 20. */
149 BoundingBox viewport;
151 /** Similar to the viewport key, but the four dimensions correspond
152 to the amount of space to be trimmed (cut off) at the left-hand
153 side, bottom, right-hand side and top of the included graphics. */
156 /// Natural height of figure
159 /// Natural width of figure.
162 /// Rotation angle (in degrees, counterclockwise).
165 /** Origin for rotation, similar to the origin parameter of
166 the \rotatebox command described on p.46 and Fig. 2.2 on p.46. */
169 /// Required width (the width of the image is scaled to that value).
172 /// Required height (the height of the image is scaled to that value).
175 /** Required total height (the total height of the image is scaled
176 to that value). This key should be used instead of height if
177 images are rotated over 90 degrees, since the height can
178 disappear (and become the depth) and LaTeX will have difficulties
179 satisfying the user's request. */
180 LyXLength totalheight;
182 /** Boolean variable that can have the values "true" and "false"
183 (se above for defaults). When true, specifying both width and
184 height parameters does not distort the picture, but the image
185 is scaled so that neither of the width of height exceeds the
187 bool keepaspectratio;
192 /** Clip the graphic to the bounding box. It is a Boolean, either
193 "true" or "false". */
196 /// Locally switch to draft mode. A Boolean valued key, like clip.
199 /// The graphics type.
202 /// The file extension of the file containing the image data.
205 /// The file extension of the file "read" by LaTeX.
208 /// Any command to be applied to the file.