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