]> git.lyx.org Git - lyx.git/blob - src/insets/figinset.h
866cce2882129cf43eeb90a3dd47693a3e181edb
[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 #endif
23
24 ///
25 class InsetFig: public Inset, public Object {
26 public:
27         ///
28         InsetFig(int tmpx, int tmpy, Buffer const &);
29         ///
30         ~InsetFig();
31         ///
32         int ascent(BufferView *, LyXFont const & font) const;
33         ///
34         int descent(BufferView *, LyXFont const & font) const;
35         ///
36         int width(BufferView *, LyXFont const & font) const;
37         ///
38         void draw(BufferView *, LyXFont const &, int, float &, bool) const;
39         ///
40         void Write(Buffer const *, std::ostream &) const;
41         ///
42         void Read(Buffer const *, LyXLex & lex);
43         ///
44         int Latex(Buffer const *, std::ostream &, bool fragile, bool free_space) const;
45         ///
46         int Ascii(Buffer const *, std::ostream &, int linelen) const;
47         ///
48         int Linuxdoc(Buffer const *, std::ostream &) const;
49         ///
50         int DocBook(Buffer const *, std::ostream &) const;
51         /// Updates needed features for this inset.
52         void Validate(LaTeXFeatures & features) const;
53
54         /// what appears in the minibuffer when opening
55         string const EditMessage() const;
56         
57         ///
58         void Edit(BufferView *, int, int, unsigned int);
59         ///
60         EDITABLE Editable() const;
61         ///
62         bool Deletable() const;
63         ///
64         Inset::Code LyxCode() const;
65         ///
66         Inset * Clone(Buffer const &) const;
67         ///
68         void CallbackFig(long arg);
69         ///
70         void Preview(string const & p);
71         /// browse for file
72         void BrowseFile();
73
74         /// form for user input
75         FD_Figure * form;
76         /// width and height in pixels on screen
77         int wid, hgh;
78         /// width and height in postscript units (1/72 inch)
79         int pswid, 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, psy;
86
87         /// .eps file name
88         string fname;
89         /// changed filename -> for recompute
90         bool changedfname;
91
92         ///
93         enum HWTYPE {
94                 ///
95                 DEF,
96                 ///
97                 CM,
98                 ///
99                 IN,
100                 ///
101                 PER_PAGE,
102                 ///
103                 PER_COL
104         };
105         
106         /// width and height types: 0-default, 1-cm, 2-in, 3-%of page
107         /// For width, there is also: 4-% of col
108         HWTYPE wtype;
109         ///
110         HWTYPE htype;
111
112         /// temporary w and h type
113         HWTYPE twtype;
114         ///
115         HWTYPE thtype;
116
117         /// width and height
118         float xwid, 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