]> git.lyx.org Git - lyx.git/blob - src/insets/figinset.h
the fstream/iostream changes and some small other things
[lyx.git] / src / insets / figinset.h
1 // -*- C++ -*-
2 /*
3   figinset.h - Figure inset header - part of LyX project
4   (C)1996 by Ivan Schreter
5   */
6
7 #ifndef FIGINSET_H
8 #define FIGINSET_H
9
10 #include "form1.h"
11 #include "buffer.h"
12 #include "LString.h"
13 #include "LaTeXFeatures.h"
14 #include "insets/lyxinset.h"
15 /* the rest is figure stuff */
16
17
18 struct Figref;
19
20 ///
21 class InsetFig: public Inset {
22 public:
23         ///
24         InsetFig(int tmpx, int tmpy, Buffer *);
25         ///
26         ~InsetFig();
27         ///
28         int Ascent(LyXFont const & font) const;
29         ///
30         int Descent(LyXFont const & font) const;
31         ///
32         int Width(LyXFont const & font) const;
33         ///
34         void Draw(LyXFont font, LyXScreen & scr, int baseline, float & x);
35         ///
36         void Write(ostream &);
37         ///
38         void Read(LyXLex & lex);
39         ///
40         int Latex(ostream &, signed char fragile);
41         ///
42         int Latex(string & file, signed char fragile);
43         ///
44         int Linuxdoc(string & file);
45         ///
46         int DocBook(string & file);
47         /// Updates needed features for this inset.
48         void Validate(LaTeXFeatures & features) const;
49
50         /// what appears in the minibuffer when opening
51         char const * EditMessage() const { return _("Opened figure"); }
52         ///
53         void Edit(int, int);
54         ///
55         unsigned char Editable() const;
56         ///
57         bool Deletable() const;
58         ///
59         Inset::Code LyxCode() const;
60         ///
61         Inset * Clone() const;
62         ///
63         void CallbackFig(long arg);
64         ///
65         void Preview(char const * p);
66         /// browse for file
67         void BrowseFile();
68
69         /// form for user input
70         FD_Figure * form;
71         /// width and height in pixels on screen
72         int wid, hgh;
73         /// width and height in postscript units (1/72 inch)
74         int pswid, pshgh;
75         /// width of raw figure w/o rotation
76         int raw_wid;
77         /// heigt of raw figure w/o rotation
78         int raw_hgh;
79         /// x and y coordinate in ps units
80         int psx, psy;
81
82         /// .eps file name
83         string fname;
84         /// changed filename -> for recompute
85         bool changedfname;
86
87         ///
88         enum HWTYPE {
89                 ///
90                 DEF,
91                 ///
92                 CM,
93                 ///
94                 IN,
95                 ///
96                 PER_PAGE,
97                 ///
98                 PER_COL
99         };
100         
101         /// width and height types: 0-default, 1-cm, 2-in, 3-%of page
102         /// For width, there is also: 4-% of col
103         HWTYPE wtype;
104         ///
105         HWTYPE htype;
106
107         /// temporary w and h type
108         HWTYPE twtype;
109         ///
110         HWTYPE thtype;
111
112         /// width and height
113         float xwid, xhgh;
114
115         /// rotation angle
116         float angle;
117         
118         /// graphics command, latex version
119         string cmd;
120         
121         /// Caption for subfigure package
122         string subcaption;
123
124         /// various flags
125         int flags;
126         bool subfigure : 1;
127         /// figure reference
128         Figref * figure;
129         /// temporary flags
130         int pflags;
131         bool psubfigure : 1;
132 private:
133
134         ///
135         Buffer * owner;
136         /// restore values on the form
137         void RestoreForm();
138         /// recompute screen params
139         void Recompute();
140         /// regenerate \includegraphics{} command
141         void Regenerate();
142         /// regenerate \inlcudegraphics{} command in temporary buffer
143         void TempRegenerate();
144         /// get sizes from .eps file
145         void GetPSSizes();
146 };
147
148
149 ///
150 struct figdata {
151         /// bitmap data
152         Pixmap bitmap;
153         /// reference count for this bitmap
154         int ref;
155         /// rotation angle
156         float angle;
157         /// width of raw figure w/o rotation
158         int raw_wid;
159         /// heigt of raw figure w/o rotation
160         int raw_hgh;
161         /// width and height on screen
162         int wid, hgh;
163         /// pointer to file name
164         string fname;
165         /// type; 0-none, 1-B/W, 2-Grayscale, 3-Color
166         char flags;
167         /// reading request is pending on this figure
168         bool reading;
169         /// could not read it, because it's broken
170         bool broken;
171         /// when gs was killed, this says that image is ok
172         bool gsdone;
173         /// gs pid for reading
174         int gspid;
175 };
176
177
178 ///
179 struct Figref {
180         /// figure data (image)
181         figdata * data;
182         /// inset of this figure
183         InsetFig * inset;
184 };
185
186 #endif