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