]> git.lyx.org Git - lyx.git/blob - src/insets/insetgraphicsParams.h
Angus insetindex patch + protect patch from Dekel
[lyx.git] / src / insets / insetgraphicsParams.h
1 // -*- C++ -*-
2 /* This file is part of
3  * =================================================
4  * 
5  *          LyX, The Document Processor
6  *          Copyright 1995 Matthias Ettrich.
7  *          Copyright 1995-2000 The LyX Team.
8  *
9  *          This file Copyright 2000 Baruch Even
10  * ================================================= */
11
12 #ifndef INSETGRAPHICSPARAMS_H
13 #define INSETGRAPHICSPARAMS_H
14
15 #ifdef __GNUG__
16 #pragma interface
17 #endif
18
19 #include <config.h>
20 #include "LString.h"
21
22 #include "buffer.h"
23 #include "lyxlex.h"
24
25 using std::ostream;
26
27 /// This struct holds all the parameters needed by insetGraphics.
28 struct InsetGraphicsParams {
29     /// Image filename.
30     string filename;
31     
32     /// How do we display the image?
33     enum DisplayType {
34         /// In full color range (if it's not in color we show it as it is)
35         COLOR,
36         /// In Grayscale (256 shades of gray).
37         GRAYSCALE,
38         /// In black and white.
39         MONOCHROME,
40         /// Don't display it on screen, only keep a frame in place.
41         NONE
42     };
43
44     /// How to display the image
45     DisplayType display;
46
47     /// Is the figure inlined? (not in a paragraph of its own).
48     bool inlineFigure;
49
50     /// Do we have a subcaption?
51     bool subcaption;
52
53     /// The text of the subcaption.
54     string subcaptionText;
55     
56         /// This is the different origins that the graphicx package support.
57         enum Origin {
58                 DEFAULT,
59                 LEFTTOP,
60                 LEFTCENTER,
61                 LEFTBASELINE,
62                 LEFTBOTTOM,
63                 CENTERTOP,
64                 CENTER,
65                 CENTERBASELINE,
66                 CENTERBOTTOM,
67                 RIGHTTOP,
68                 RIGHTCENTER,
69                 RIGHTBASELINE,
70                 RIGHTBOTTOM,
71                 REFERENCE_POINT = LEFTBASELINE
72         };
73
74     /// The resize of the image, is it the default size, in cm, inch or
75     /// percentage of the page/column width/height
76     enum Resize {
77         DEFAULT_SIZE,
78         CM,
79         INCH,
80         PERCENT_PAGE,
81         PERCENT_COLUMN
82     };
83
84     
85     /// Keep the ratio between height and width when resizing.
86     bool keepAspectRatio;
87
88     // What width resize to do?
89     Resize widthResize;
90     // Value of width resize
91     float widthSize;
92     // What height resize to do?
93     Resize heightResize;
94     // Value of height resize
95     float heightSize;
96
97     // Origin point of rotation
98     Origin rotateOrigin;
99     // Rotation angle.
100     int rotateAngle;
101
102     InsetGraphicsParams();
103
104     InsetGraphicsParams(InsetGraphicsParams const &);
105     InsetGraphicsParams const & operator=(InsetGraphicsParams const &);
106
107     /// Save the parameters in the LyX format stream.
108     void Write(Buffer const * buf, ostream & os) const;
109     
110     /// If the token belongs to our parameters, read it.
111     bool Read(Buffer const * buf, LyXLex & lex, string const & token);
112     
113     /// Test the struct to make sure that all the options have legal values.
114     void testInvariant() const;
115
116 private:
117     /// Initialize the object to a default status.
118     void init();
119
120     /// Copy the other objects content to us, used in copy c-tor and assignment
121     void copy(InsetGraphicsParams const & params);
122 };
123
124 bool operator==(InsetGraphicsParams const&, InsetGraphicsParams const &);
125
126 #endif