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