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