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