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