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