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