]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/xformsImage.h
fix crash with "save as"
[lyx.git] / src / frontends / xforms / xformsImage.h
1 // -*- C++ -*-
2 /**
3  *  \file xformsImage.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  *  \author Angus Leeming 
8  *
9  * Full author contact details are available in file CREDITS
10  */
11
12 /* An instantiation of Image that makes use of the xforms lirary routines
13  * to load and store the image in memory.
14  */
15
16 #ifndef XFORMSIMAGE_H
17 #define XFORMSIMAGE_H
18
19 #ifdef __GNUG__
20 #pragma interface
21 #endif
22
23 #include "graphics/GraphicsImage.h"
24
25 #include <X11/X.h>
26
27 struct flimage_;
28 typedef flimage_ FL_IMAGE;
29  
30 namespace grfx {
31
32 class xformsImage : public Image
33 {
34 public:
35         /// Access to this class is through this static method.
36         static ImagePtr newImage();
37
38         /// Return the list of loadable formats.
39         static FormatList loadableFormats();
40
41         ///
42         ~xformsImage();
43
44         /// Create a copy
45         Image * clone() const;
46
47         ///
48         Pixmap getPixmap() const;
49
50         /// Get the image width
51         unsigned int getWidth() const;
52
53         /// Get the image height
54         unsigned int getHeight() const;
55
56         virtual bool isDrawable() const;
57  
58         /** Load the image file into memory.
59          *  The process is asynchronous, so this method starts the loading.
60          *  When finished, the Image::finishedLoading signal is emitted.
61          */
62         void load(string const & filename);
63
64         /** Generate the pixmap, based on the current state of
65          *  image_ (clipped, rotated, scaled etc).
66          *  Uses the params to decide on color, grayscale etc.
67          *  Returns true if the pixmap is created.
68          */
69         bool setPixmap(Params const & params);
70
71         /// Clip the image using params.
72         void clip(Params const & params);
73
74         /// Rotate the image using params.
75         void rotate(Params const & params);
76
77         /// Scale the image using params.
78         void scale(Params const & params);
79
80         /// Internal callbacks.
81         void statusCB(string const &);
82         ///
83         void errorCB(string const &);
84
85 private:
86         /// Access to the class is through newImage() and clone.
87         xformsImage();
88         ///
89         xformsImage(xformsImage const &);
90
91         /// The xforms container.
92         FL_IMAGE * image_;
93
94         /// The pixmap itself.
95         Pixmap pixmap_;
96
97         /// Is the pixmap initialized?
98         enum PixmapStatus {
99                 ///
100                 PIXMAP_UNINITIALISED,
101                 ///
102                 PIXMAP_FAILED,
103                 ///
104                 PIXMAP_SUCCESS
105         };
106
107         PixmapStatus pixmap_status_;
108 };
109
110 } // namespace grfx
111
112 #endif // XFORMSIMAGE_H