]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/xformsImage.h
Asymptotic approach to a well-designed graphics loader.
[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 struct flimage_;
24 typedef flimage_ FL_IMAGE;
25
26 namespace grfx {
27
28 class xformsImage : public Image
29 {
30 public:
31         /// Access to this class is through this static method.
32         static ImagePtr newImage();
33
34         /// Return the list of loadable formats.
35         static FormatList loadableFormats();
36
37         ///
38         ~xformsImage();
39
40         /// Create a copy
41         Image * clone() const;
42
43         ///
44         Pixmap getPixmap() const;
45
46         /// Get the image width
47         unsigned int getWidth() const;
48
49         /// Get the image height
50         unsigned int getHeight() const;
51
52         /** Load the image file into memory.
53          *  The process is asynchronous, so this method starts the loading.
54          *  When finished, the Image::finishedLoading signal is emitted.
55          */
56         void load(string const & filename);
57
58         /** Generate the pixmap, based on the current state of
59          *  image_ (clipped, rotated, scaled etc).
60          *  Uses the params to decide on color, grayscale etc.
61          *  Returns true if the pixmap is created.
62          */
63         bool setPixmap(Params const & params);
64
65         /// Clip the image using params.
66         void clip(Params const & params);
67
68         /// Rotate the image using params.
69         void rotate(Params const & params);
70
71         /// Scale the image using params.
72         void scale(Params const & params);
73
74         /// Internal callbacks.
75         void statusCB(string const &);
76         ///
77         void errorCB(string const &);
78
79 private:
80         /// Access to the class is through newImage() and clone.
81         xformsImage();
82         ///
83         xformsImage(xformsImage const &);
84
85         /// The xforms container.
86         FL_IMAGE * image_;
87
88         /// The pixmap itself.
89         Pixmap pixmap_;
90
91         /// Is the pixmap initialized?
92         enum PixmapStatus {
93                 ///
94                 PIXMAP_UNINITIALISED,
95                 ///
96                 PIXMAP_FAILED,
97                 ///
98                 PIXMAP_SUCCESS
99         };
100
101         PixmapStatus pixmap_status_;
102 };
103
104 } // namespace grfx
105
106 #endif // XFORMSIMAGE_H