]> git.lyx.org Git - lyx.git/blob - src/insets/figinset.h
Added using directive.
[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 "figure_form.h"
11 #include "LString.h"
12 #include "buffer.h"
13 #include "LaTeXFeatures.h"
14 #include "insets/inset.h"
15 #include <sigc++/signal_system.h>
16 /* the rest is figure stuff */
17
18 struct Figref;
19
20 ///
21 class InsetFig: public Inset, public SigC::Object {
22 public:
23         ///
24         InsetFig(int tmpx, int tmpy, Buffer const &);
25         ///
26         ~InsetFig();
27         ///
28         int ascent(BufferView *, LyXFont const & font) const;
29         ///
30         int descent(BufferView *, LyXFont const & font) const;
31         ///
32         int width(BufferView *, LyXFont const & font) const;
33         ///
34         void draw(BufferView *, LyXFont const &, int, float &, bool) const;
35         ///
36         void write(Buffer const *, std::ostream &) const;
37         ///
38         void read(Buffer const *, LyXLex & lex);
39         ///
40         int latex(Buffer const *, std::ostream &, bool fragile, bool free_space) const;
41         ///
42         int ascii(Buffer const *, std::ostream &, int linelen) const;
43         ///
44         int linuxdoc(Buffer const *, std::ostream &) const;
45         ///
46         int docBook(Buffer const *, 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         string 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(Buffer const &) const;
63         ///
64         void callbackFig(long arg);
65         ///
66         void preview(string 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;
74         int hgh;
75         /// width and height in postscript units (1/72 inch)
76         int pswid;
77         int 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;
84         int psy;
85
86         /// .eps file name
87         string fname;
88         /// changed filename -> for recompute
89         bool changedfname;
90
91         ///
92         enum HWTYPE {
93                 ///
94                 DEF,
95                 ///
96                 CM,
97                 ///
98                 IN,
99                 ///
100                 PER_PAGE,
101                 ///
102                 PER_COL
103         };
104         
105         /// width and height types: 0-default, 1-cm, 2-in, 3-%of page
106         /// For width, there is also: 4-% of col
107         HWTYPE wtype;
108         ///
109         HWTYPE htype;
110
111         /// temporary w and h type
112         HWTYPE twtype;
113         ///
114         HWTYPE thtype;
115
116         /// width and height
117         float xwid;
118         float xhgh;
119
120         /// rotation angle
121         float angle;
122         
123         /// graphics command, latex version
124         mutable string cmd;
125         
126         /// Caption for subfigure package
127         string subcaption;
128
129         /// various flags
130         int flags;
131         ///
132         bool subfigure;
133         /// figure reference
134         Figref * figure;
135         /// temporary flags
136         int pflags;
137         ///
138         bool psubfigure;
139 private:
140         /** Redraw the form (on receipt of a Signal indicating, for example,
141             that the xform colors have been re-mapped).
142         */
143         void redraw();
144
145         ///
146         Buffer const * owner;
147         /// restore values on the form
148         void restoreForm();
149         /// recompute screen params
150         void recompute();
151         /// regenerate \includegraphics{} command
152         void regenerate() const;
153         /// regenerate \inlcudegraphics{} command in temporary buffer
154         void tempRegenerate();
155         /// get sizes from .eps file
156         void getPSSizes();
157         /// Redraw connection.
158         SigC::Connection r_;
159 };
160
161
162 ///
163 struct figdata {
164         /// bitmap data
165         Pixmap bitmap;
166         /// reference count for this bitmap
167         int ref;
168         /// rotation angle
169         float angle;
170         /// width of raw figure w/o rotation
171         int raw_wid;
172         /// heigt of raw figure w/o rotation
173         int raw_hgh;
174         /// width and height on screen
175         int wid, hgh;
176         /// pointer to file name
177         string fname;
178         /// type; 0-none, 1-B/W, 2-Grayscale, 3-Color
179         char flags;
180         /// reading request is pending on this figure
181         bool reading;
182         /// could not read it, because it's broken
183         bool broken;
184         /// when gs was killed, this says that image is ok
185         bool gsdone;
186         /// gs pid for reading
187         int gspid;
188 };
189
190
191 ///
192 struct Figref {
193         /// figure data (image)
194         figdata * data;
195         /// inset of this figure
196         InsetFig * inset;
197 };
198
199 #endif