]> git.lyx.org Git - lyx.git/blob - src/insets/figinset.h
clear()->erase() ; lots of using directives for cxx
[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 &, bool fragile, bool free_space) const;
41         ///
42         int Ascii(std::ostream &) const;
43         ///
44         int Linuxdoc(std::ostream &) const;
45         ///
46         int DocBook(std::ostream &) const;
47         /// Updates needed features for this inset.
48         void Validate(LaTeXFeatures & features) const;
49
50         /// what appears in the minibuffer when opening
51         char const * EditMessage() const;
52         
53         ///
54         void Edit(BufferView *, int, int, unsigned int);
55         ///
56         EDITABLE 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         ///
128         bool subfigure;
129         /// figure reference
130         Figref * figure;
131         /// temporary flags
132         int pflags;
133         ///
134         bool psubfigure;
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