]> git.lyx.org Git - lyx.git/blob - src/insets/figinset.h
2001-12-28 Lars Gullik Bj�nnes <larsbj@birdstep.com>
[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         void edit(BufferView * bv, bool front = true);
57         ///
58         EDITABLE editable() const;
59         ///
60         bool deletable() const;
61         ///
62         Inset::Code lyxCode() const;
63         ///
64         Inset * clone(Buffer const &, bool same_id = false) const;
65         ///
66         void callbackFig(long arg);
67         ///
68         void preview(string 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;
76         int hgh;
77         /// width and height in postscript units (1/72 inch)
78         int pswid;
79         int pshgh;
80         /// width of raw figure w/o rotation
81         int raw_wid;
82         /// heigt of raw figure w/o rotation
83         int raw_hgh;
84         /// x and y coordinate in ps units
85         int psx;
86         int psy;
87
88         /// .eps file name
89         string fname;
90         /// changed filename -> for recompute
91         bool changedfname;
92
93         ///
94         enum HWTYPE {
95                 ///
96                 DEF,
97                 ///
98                 CM,
99                 ///
100                 IN,
101                 ///
102                 PER_PAGE,
103                 ///
104                 PER_COL
105         };
106         
107         /// width and height types: 0-default, 1-cm, 2-in, 3-%of page
108         /// For width, there is also: 4-% of col
109         HWTYPE wtype;
110         ///
111         HWTYPE htype;
112
113         /// temporary w and h type
114         HWTYPE twtype;
115         ///
116         HWTYPE thtype;
117
118         /// width and height
119         float xwid;
120         float xhgh;
121
122         /// rotation angle
123         float angle;
124         
125         /// graphics command, latex version
126         mutable string cmd;
127         
128         /// Caption for subfigure package
129         string subcaption;
130
131         /// various flags
132         int flags;
133         ///
134         bool subfigure;
135         /// figure reference
136         Figref * figure;
137         /// temporary flags
138         int pflags;
139         ///
140         bool psubfigure;
141 private:
142         /** Redraw the form (on receipt of a Signal indicating, for example,
143             that the xform colors have been re-mapped).
144         */
145         void redraw();
146
147         ///
148         Buffer const * owner;
149         /// restore values on the form
150         void restoreForm();
151         /// recompute screen params
152         void recompute();
153         /// regenerate \includegraphics{} command
154         void regenerate() const;
155         /// regenerate \inlcudegraphics{} command in temporary buffer
156         void tempRegenerate();
157         /// get sizes from .eps file
158         void getPSSizes();
159         /// Redraw connection.
160         SigC::Connection r_;
161 };
162
163
164 ///
165 struct figdata {
166         /// bitmap data
167         Pixmap bitmap;
168         /// reference count for this bitmap
169         int ref;
170         /// rotation angle
171         float angle;
172         /// width of raw figure w/o rotation
173         int raw_wid;
174         /// heigt of raw figure w/o rotation
175         int raw_hgh;
176         /// width and height on screen
177         int wid, hgh;
178         /// pointer to file name
179         string fname;
180         /// type; 0-none, 1-B/W, 2-Grayscale, 3-Color
181         char flags;
182         /// reading request is pending on this figure
183         bool reading;
184         /// could not read it, because it's broken
185         bool broken;
186         /// when gs was killed, this says that image is ok
187         bool gsdone;
188         /// gs pid for reading
189         int gspid;
190 };
191
192
193 ///
194 struct Figref {
195         /// figure data (image)
196         figdata * data;
197         /// inset of this figure
198         InsetFig * inset;
199 };
200
201 #endif