]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/xformsImage.h
namespace grfx -> lyx::graphics
[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
20 #include "graphics/GraphicsImage.h"
21
22 #include <X11/X.h>
23
24 struct flimage_;
25 typedef flimage_ FL_IMAGE;
26
27 namespace lyx {
28 namespace graphics {
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 graphics
109 } // namespace lyx
110
111 #endif // XFORMSIMAGE_H