]> git.lyx.org Git - lyx.git/blob - src/insets/insetgraphics.h
read the Changelog, preparing for prerelease
[lyx.git] / src / insets / insetgraphics.h
1 // -*- C++ -*-
2 /* This file is part of
3  * ====================================================== 
4  * 
5  *           LyX, The Document Processor
6  *       
7  *           Copyright 1995 Matthias Ettrich
8  *           Copyright 1995-2000 the LyX Team.
9  *
10  * ====================================================== */
11
12 #ifndef INSET_GRAPHICS_H
13 #define INSET_GRAPHICS_H
14
15 #ifdef __GNUG__
16 #pragma interface
17 #endif
18
19 #include "insets/lyxinset.h"
20 #include "LaTeXFeatures.h"
21 #include "vspace.h"
22 #include "insets/BoundingBox.h"
23
24 struct FD_Graphics;
25
26 ///
27 class InsetGraphics : public Inset {
28 public:
29         ///
30         InsetGraphics();
31         ///
32         int ascent(Painter &, LyXFont const &) const;
33         ///
34         int descent(Painter &, LyXFont const &) const;
35         ///
36         int width(Painter &, LyXFont const &) const;
37         ///
38         void draw(Painter &, LyXFont const &,
39                           int baseline, float & x) const;
40         ///
41         void Edit(BufferView *, int, int, unsigned int);
42         ///
43         EDITABLE Editable() const;
44         ///
45         void Write(std::ostream &) const;
46         ///
47         void Read(LyXLex & lex);
48         /** returns the number of rows (\n's) of generated tex code.
49          fragile == true means, that the inset should take care about
50          fragile commands by adding a \protect before.
51          */
52         int Latex(std::ostream &, bool fragile, bool free_spc) const;
53         ///
54         int Linuxdoc(std::ostream &) const;
55         ///
56         int DocBook(std::ostream &) const;
57
58         /// Updates needed features for this inset.
59         void Validate(LaTeXFeatures & features) const;
60
61         /// returns LyX code associated with the inset. Used for TOC, ...)
62         Inset::Code LyxCode() const { return Inset::GRAPHICS_CODE; }
63   
64         ///
65         Inset * Clone() const;
66         /// Set the graphics file
67         void graphicsFile(string const & f) {
68                 graphicsfile = f;
69         }
70         /// Get the graphics file
71         string const & graphicsFile() const {
72                 return graphicsfile;
73         }
74 private:
75         ///
76         FD_Graphics * form;
77         ///
78         string graphicsfile;
79         ///
80         Pixmap pixmap;
81         
82         // We need variables to store the size of the boundingbox and
83         // to store a pointer to the pixmap in.. The question is if
84         // these should be in a "pixmap" class.
85         // We also need to have variables about rotation and scaling,
86         // width and height. in effect all the paramters that
87         // \includegrapichs can handle. (the graphix.sty package)
88
89         /** The "bounding box" of the graphics image. Its value field
90             must contain four dimensions, separated by spaces.  */
91         BoundingBox bb;
92         /** The bounding box above is used for display and file both.
93             But we need this variable below to know if we shall use the
94             bounding box in the LaTex command or not. (i.e. if the user
95             has manually set the bb.) */
96         bool use_bb;
97         
98         /** When a graphics file is parsed we first check for BoundingBox
99             and then for HiResBoundingBox, and set hiresbb depending on this.
100             This key makes LaTeX search for %%HiResBoundingBox comments
101             instead of the normal %%BoundingBox. Some applications use
102             this to specify more precise bounding boxes, becase the cumbers
103             can normally only have integer values. It is a Boolean, either
104             "true" or "false". */
105         bool hiresbb;
106         /** This key takes four arguments (like bb), but in this case the
107             origin is taken with respect to the bounding box specified in
108             the file. So to view a 20 bp square at the lower left-hand corner
109             of the picture, specify viewport=0 0 20 20. */
110         BoundingBox viewport;
111         /** Similar to the viewport key, but the four dimensions correspond
112             to the amount of space to be trimmed (cut off) at the left-hand
113             side, bottom, right-hand side and top of the included graphics. */
114         BoundingBox trim;
115         /// Natural height of figure
116         LyXLength natheight;
117         /// Natural width of figure.
118         LyXLength natwidth;
119         /// Rotation angle (in degrees, counterclockwise).
120         float angle;
121         /// This is the different origins that the graphicx package support.
122         enum Origin {
123                 DEFAULT,
124                 LEFTTOP,
125                 LEFTCENTER,
126                 LEFTBASELINE,
127                 LEFTBOTTOM,
128                 CENTERTOP,
129                 CENTER,
130                 CENTERBASELINE,
131                 CENTERBOTTOM,
132                 RIGHTTOP,
133                 RIGHTCENTER,
134                 RIGHTBASELINE,
135                 RIGHTBOTTOM,
136                 REFERENCE_POINT = LEFTBASELINE
137         };
138         /** Origin for rotation, similar to the origin parameter of
139             the \rotatebox command described on p.46 and Fig. 2.2 on p.46. */
140         Origin origin;
141         /// Required width (the width of the image is scaled to that value).
142         LyXLength g_width;
143         /// Required height (the height of the image is scaled to that value).
144         LyXLength g_height;
145         /** Required total height (the total height of the image is scaled
146             to that value). This key should be used instead of height if
147             images are rotated over 90 degrees, since the height can
148             disappear (and become the depth) and LaTeX will have difficulties
149             satisfying the user's request. */
150         LyXLength totalheight;
151         /** Boolean variable that can have the values "true" and "false"
152             (se above for defaults). When true, specifying both width and
153             height parameters does not distort the picture, but the image
154             is scaled so that neither of the width of height exceeds the
155             given dimensions. */
156         bool keepaspectratio;
157         /// Scale factor
158         float scale;
159         /** Clip the graphic to the bounding box. It is a Boolean, either
160             "true" or "false". */
161         bool clip;
162         /// Locally switch to draft mode. A Boolean valued key, like clip.
163         bool draft;
164         /// The graphics type.
165         string type;
166         ///x The file extension of the file containing the image data.
167         string ext;
168         /// The file extension of the file "read" by LaTeX.
169         string read;
170         /// Any command to be applied to the file.
171         string command;
172 };
173
174 #endif