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