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 "LaTeXFeatures.h"
22 #include "insets/BoundingBox.h"
25 class InsetGraphics : public Inset {
28 int ascent(Painter &, LyXFont const &) const;
30 int descent(Painter &, LyXFont const &) const;
32 int width(Painter &, LyXFont const &) const;
34 void draw(Painter &, LyXFont const &,
35 int baseline, float & x) const;
37 void Edit(BufferView *, int, int, unsigned int);
39 unsigned char Editable() const;
41 void Write(ostream &) const;
43 void Read(LyXLex & lex);
44 /** returns the number of rows (\n's) of generated tex code.
45 fragile != 0 means, that the inset should take care about
46 fragile commands by adding a \protect before.
48 int Latex(ostream &, signed char fragile) const;
50 int Latex(string & file, signed char fragile) const;
52 int Linuxdoc(string & /*file*/) const;
54 int DocBook(string & /*file*/) const;
55 /// Updates needed features for this inset.
56 void Validate(LaTeXFeatures & features) const;
58 /// returns LyX code associated with the inset. Used for TOC, ...)
59 Inset::Code LyxCode() const { return Inset::GRAPHICS_CODE; }
62 Inset * Clone() const;
69 // We need variables to store the size of the boundingbox and
70 // to store a pointer to the pixmap in.. The question is if
71 // these should be in a "pixmap" class.
72 // We also need to have variables about rotation and scaling,
73 // width and height. in effect all the paramters that
74 // \includegrapichs can handle. (the graphix.sty package)
76 /** The "bounding box" of the graphics image. Its value field
77 must contain four dimensions, separated by spaces. */
79 /** The bounding box above is used for display and file both.
80 But we need this variable below to know if we shall use the
81 bounding box in the LaTex command or not. (i.e. if the user
82 has manually set the bb.) */
85 /** When a graphics file is parsed we first check for BoundingBox
86 and then for HiResBoundingBox, and set hiresbb depending on this.
87 This key makes LaTeX search for %%HiResBoundingBox comments
88 instead of the normal %%BoundingBox. Some applications use
89 this to specify more precise bounding boxes, becase the cumbers
90 can normally only have integer values. It is a Boolean, either
93 /** This key takes four arguments (like bb), but in this case the
94 origin is taken with respect to the bounding box specified in
95 the file. So to view a 20 bp square at the lower left-hand corner
96 of the picture, specify viewport=0 0 20 20. */
98 /** Similar to the viewport key, but the four dimensions correspond
99 to the amount of space to be trimmed (cut off) at the left-hand
100 side, bottom, right-hand side and top of the included graphics. */
102 /// Natural height of figure
104 /// Natural width of figure.
106 /// Rotation angle (in degrees, counterclockwise).
108 /// This is the different origins that the graphicx package support.
123 REFERENCE_POINT = LEFTBASELINE
125 /** Origin for rotation, similar to the origin parameter of
126 the \rotatebox command described on p.46 and Fig. 2.2 on p.46. */
128 /// Required width (the width of the image is scaled to that value).
130 /// Required height (the height of the image is scaled to that value).
132 /** Required total height (the total height of the image is scaled
133 to that value). This key should be used instead of height if
134 images are rotated over 90 degrees, since the height can
135 disappear (and become the depth) and LaTeX will have difficulties
136 satisfying the user's request. */
137 LyXLength totalheight;
138 /** Boolean variable that can have the values "true" and "false"
139 (se above for defaults). When true, specifying both width and
140 height parameters does not distort the picture, but the image
141 is scaled so that neither of the width of height exceeds the
143 bool keepaspectratio;
146 /** Clip the graphic to the bounding box. It is a Boolean, either
147 "true" or "false". */
149 /// Locally switch to draft mode. A Boolean valued key, like clip.
151 /// The graphics type.
153 ///x The file extension of the file containing the image data.
155 /// The file extension of the file "read" by LaTeX.
157 /// Any command to be applied to the file.