]> git.lyx.org Git - lyx.git/blob - src/insets/figinset.h
f8ee925ab6a84bf2013e62d4e3ed136e00dac88d
[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 *);
24         ///
25         ~InsetFig();
26         ///
27         int ascent(Painter &, LyXFont const & font) const;
28         ///
29         int descent(Painter &, LyXFont const & font) const;
30         ///
31         int width(Painter &, LyXFont const & font) const;
32         ///
33         void draw(Painter &, LyXFont const & font,
34                   int baseline, float & x) const;
35         ///
36         void Write(std::ostream &) const;
37         ///
38         void Read(LyXLex & lex);
39         ///
40         int Latex(std::ostream &, signed char fragile, bool free_space) const;
41         ///
42         int Linuxdoc(std::ostream &) const;
43         ///
44         int DocBook(std::ostream &) const;
45         /// Updates needed features for this inset.
46         void Validate(LaTeXFeatures & features) const;
47
48         /// what appears in the minibuffer when opening
49         char const * EditMessage() const;
50         
51         ///
52         void Edit(BufferView *, int, int, unsigned int);
53         ///
54         EDITABLE Editable() const;
55         ///
56         bool Deletable() const;
57         ///
58         Inset::Code LyxCode() const;
59         ///
60         Inset * Clone() const;
61         ///
62         void CallbackFig(long arg);
63         ///
64         void Preview(char const * p);
65         /// browse for file
66         void BrowseFile();
67
68         /// form for user input
69         FD_Figure * form;
70         /// width and height in pixels on screen
71         int wid, hgh;
72         /// width and height in postscript units (1/72 inch)
73         int pswid, pshgh;
74         /// width of raw figure w/o rotation
75         int raw_wid;
76         /// heigt of raw figure w/o rotation
77         int raw_hgh;
78         /// x and y coordinate in ps units
79         int psx, psy;
80
81         /// .eps file name
82         string fname;
83         /// changed filename -> for recompute
84         bool changedfname;
85
86         ///
87         enum HWTYPE {
88                 ///
89                 DEF,
90                 ///
91                 CM,
92                 ///
93                 IN,
94                 ///
95                 PER_PAGE,
96                 ///
97                 PER_COL
98         };
99         
100         /// width and height types: 0-default, 1-cm, 2-in, 3-%of page
101         /// For width, there is also: 4-% of col
102         HWTYPE wtype;
103         ///
104         HWTYPE htype;
105
106         /// temporary w and h type
107         HWTYPE twtype;
108         ///
109         HWTYPE thtype;
110
111         /// width and height
112         float xwid, xhgh;
113
114         /// rotation angle
115         float angle;
116         
117         /// graphics command, latex version
118         mutable string cmd;
119         
120         /// Caption for subfigure package
121         string subcaption;
122
123         /// various flags
124         int flags;
125         ///
126         bool subfigure;
127         /// figure reference
128         Figref * figure;
129         /// temporary flags
130         int pflags;
131         ///
132         bool psubfigure;
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