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