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