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