]> git.lyx.org Git - lyx.git/blob - src/insets/figinset.h
updates to minipage inset
[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 #include <sigc++/signal_system.h>
16 /* the rest is figure stuff */
17
18 struct Figref;
19
20 #ifdef SIGC_CXX_NAMESPACES
21 using SigC::Object;
22 using SigC::Connection;
23 #endif
24
25 ///
26 class InsetFig: public Inset, public Object {
27 public:
28         ///
29         InsetFig(int tmpx, int tmpy, Buffer const &);
30         ///
31         ~InsetFig();
32         ///
33         int ascent(BufferView *, LyXFont const & font) const;
34         ///
35         int descent(BufferView *, LyXFont const & font) const;
36         ///
37         int width(BufferView *, LyXFont const & font) const;
38         ///
39         void draw(BufferView *, LyXFont const &, int, float &, bool) const;
40         ///
41         void Write(Buffer const *, std::ostream &) const;
42         ///
43         void Read(Buffer const *, LyXLex & lex);
44         ///
45         int Latex(Buffer const *, std::ostream &, bool fragile, bool free_space) const;
46         ///
47         int Ascii(Buffer const *, std::ostream &, int linelen) const;
48         ///
49         int Linuxdoc(Buffer const *, std::ostream &) const;
50         ///
51         int DocBook(Buffer const *, std::ostream &) const;
52         /// Updates needed features for this inset.
53         void Validate(LaTeXFeatures & features) const;
54
55         /// what appears in the minibuffer when opening
56         string const EditMessage() const;
57         
58         ///
59         void Edit(BufferView *, int, int, unsigned int);
60         ///
61         EDITABLE Editable() const;
62         ///
63         bool Deletable() const;
64         ///
65         Inset::Code LyxCode() const;
66         ///
67         Inset * Clone(Buffer const &) const;
68         ///
69         void CallbackFig(long arg);
70         ///
71         void Preview(string const & p);
72         /// browse for file
73         void BrowseFile();
74
75         /// form for user input
76         FD_Figure * form;
77         /// width and height in pixels on screen
78         int wid, hgh;
79         /// width and height in postscript units (1/72 inch)
80         int pswid, 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, 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, xhgh;
120
121         /// rotation angle
122         float angle;
123         
124         /// graphics command, latex version
125         mutable string cmd;
126         
127         /// Caption for subfigure package
128         string subcaption;
129
130         /// various flags
131         int flags;
132         ///
133         bool subfigure;
134         /// figure reference
135         Figref * figure;
136         /// temporary flags
137         int pflags;
138         ///
139         bool psubfigure;
140 private:
141         /** Redraw the form (on receipt of a Signal indicating, for example,
142             that the xform colors have been re-mapped).
143         */
144         void redraw();
145
146         ///
147         Buffer const * owner;
148         /// restore values on the form
149         void RestoreForm();
150         /// recompute screen params
151         void Recompute();
152         /// regenerate \includegraphics{} command
153         void Regenerate() const;
154         /// regenerate \inlcudegraphics{} command in temporary buffer
155         void TempRegenerate();
156         /// get sizes from .eps file
157         void GetPSSizes();
158         /// Redraw connection.
159         Connection r_;
160 };
161
162
163 ///
164 struct figdata {
165         /// bitmap data
166         Pixmap bitmap;
167         /// reference count for this bitmap
168         int ref;
169         /// rotation angle
170         float angle;
171         /// width of raw figure w/o rotation
172         int raw_wid;
173         /// heigt of raw figure w/o rotation
174         int raw_hgh;
175         /// width and height on screen
176         int wid, hgh;
177         /// pointer to file name
178         string fname;
179         /// type; 0-none, 1-B/W, 2-Grayscale, 3-Color
180         char flags;
181         /// reading request is pending on this figure
182         bool reading;
183         /// could not read it, because it's broken
184         bool broken;
185         /// when gs was killed, this says that image is ok
186         bool gsdone;
187         /// gs pid for reading
188         int gspid;
189 };
190
191
192 ///
193 struct Figref {
194         /// figure data (image)
195         figdata * data;
196         /// inset of this figure
197         InsetFig * inset;
198 };
199
200 #endif